human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Partner social media changes

Open Learningstuff98 opened this issue 3 years ago • 3 comments

Resolves #3032

Description

This PR adds an Instagram field to the media information section for partners along with a "No Social Media Presence" checkbox. The checkbox must be checked if none of the social media fields are filled in.

List any dependencies that are required for this change. (gems, js libraries, etc.)

Rspec, Factorybot

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Visual confirmation and I wrote some tests.

Screenshots

Screenshot (555)

Screenshot (556)

Screenshot (557)

If anything needs to change, please let me know.

Learningstuff98 avatar Sep 17 '22 00:09 Learningstuff98

@cielf I've been attempting to change the error message, but I'm running into difficulties with getting the attribute name "no social media presence" out of the error message. Would it be possible to have an error message that starts with "No social media presence"? I've tried the following resource but I can't get it to work.

Section 3.7 Configuring Active Model link

Learningstuff98 avatar Sep 23 '22 02:09 Learningstuff98

@Learningstuff98 I'm not an expert in this area, by any means -- my notes are from a business pov more than a technical. That being said, one approach that I've found useful is treating it as a translation problem -- i.e. the text that we want is the english version of the text (that could also have other languages). Is that in line with what you're trying to do?

cielf avatar Sep 23 '22 18:09 cielf

I do keep forgetting that error messages that read nicely is one of the the things that ends up being harder in rails G I want to figure this out too -- I'll try to take a look tonight, if not, then probably Monday.

cielf avatar Sep 23 '22 18:09 cielf

@Learningstuff98 Have you looked at using errors[:base] -- since it is a validation that goes across several fields?

https://guides.rubyonrails.org/active_record_validations.html#errors-base

cielf avatar Sep 23 '22 20:09 cielf

@cielf I'll look at this again today, including the errors[:base] suggestion

Learningstuff98 avatar Sep 23 '22 20:09 Learningstuff98

I have an update. I tried this approach again but I still wasn't able to get it to work, so I ended up using the errors[:base] approach. Here's a screenshot of the current behavior:

Screenshot (564)

I'm going to be busy all day tomorrow, so I'm hoping to send this change when its ready either Thursday or Friday.

Learningstuff98 avatar Sep 28 '22 01:09 Learningstuff98

@cielf I accidently changed the PG_PASSWORD value in the database.yml, then changed it back to match what it is in main in the "Added a test for the custom error message" commit. No changes to the database.yml file are being proposed in this PR from what I can see.

Learningstuff98 avatar Oct 05 '22 20:10 Learningstuff98

@Learningstuff98

Hrm. Hrm. Hrm. Argh.
I think where we're running into trouble and confusion is that if we use :base, we would normally display it at the top of the form, because it is considered an error across the whole object, right.

Since it's such a monster form (and it is a huge ungainly beast of a form), it would be nice to keep it near where the error is.

Argh. There has to be a way to do this without jumping through quite as many hoops as you are. Because some of the things you are doing (like checking for the actual text of the error message before displaying it) are not how things are done at all (and sorry I missed that one on the first go through).

Either we'll figure it out, or I'll give up on my dream of having a reasonable error message. G

cielf avatar Oct 07 '22 00:10 cielf

@Learningstuff98 If we go back to the other method... Is this basically what you were trying? (with appropriate indentation, which doesn't seem to be coming through in this comment)

In en.yml.... en: activemodel: # or activerecord: errors: models: partner: attributes: no_social_media_presence: format: "%{message}"

and then in your model

validates :no_social_media_presence, acceptance: {message: "You must either provide a social media site or indicate that you have no social media presence"}, if: :verified_and_has_no_social_media?

cielf avatar Oct 07 '22 00:10 cielf

@cielf I'll try the en.yml approach again. The way that I've been trying definitely isn't ideal.

Learningstuff98 avatar Oct 07 '22 01:10 Learningstuff98

@Learningstuff98 Yeah -- sorry to have led you down that particular path. It was an idea, but it turns out, it wasn't the best idea I've ever had.

cielf avatar Oct 07 '22 01:10 cielf

@cielf No worries. I'll try the en.yml approach again and hopefully get back soon with some good results.

Learningstuff98 avatar Oct 07 '22 01:10 Learningstuff98

@cielf I'm back. Unfortunately I wasn't able to change the error message format through the en.yml file. If you want I can remove the code that's related to the current error message functionality.

Learningstuff98 avatar Oct 10 '22 20:10 Learningstuff98

@Learningstuff98 Yeah, I think that's probably for the best for now. So -- the best error message that begins with "No social media presence" How about: "No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram."

cielf avatar Oct 11 '22 13:10 cielf

@Learningstuff98 I'm going to try to look at this today.

cielf avatar Oct 14 '22 14:10 cielf

@cielf Is this what you mean?

With social media and no social media presence is unchecked: Screenshot (579)

Without social media and no social media presence is checked: Screenshot (580)

Learningstuff98 avatar Oct 15 '22 20:10 Learningstuff98

@Learningstuff98 I'd like to see "No Social Media Presence" treated the same way as other checkboxes on the profile form -- for clarity: with the prompt "No Social Media Presence" and then "Yes" , if checked, and "No" if not checked. See checkboxes such as "Case Management" for the pattern. thanks.

cielf avatar Oct 16 '22 00:10 cielf

@Learningstuff98 That looks like it should be right . Please also address "**** you should not be able to successfully submit for approval with the media information in this state (no fields in media information filled in)" from my comments a couple of days ago.

cielf avatar Oct 16 '22 08:10 cielf

@Learningstuff98 Also make it so that when the bank views the partner, they see all the media fields [see http://localhost:3000/diaper_bank/partners/1 , signed in as [email protected]]

cielf avatar Oct 16 '22 12:10 cielf

@cielf I believe I addressed everything that you mentioned. Can you pull down these changes and test it locally and tell me if anything needs to change?

Learningstuff98 avatar Oct 16 '22 21:10 Learningstuff98

@Learningstuff98 Will do, but probably tomorrow at this point.

cielf avatar Oct 16 '22 22:10 cielf

@Learningstuff98 Hi! I'll add separate comments for each thing I find from testing from now on. 1/ The banks view of the partner still does not show the new fields: see http://localhost:3000/diaper_bank/partners/1 The view in question is: app/views/profiles/_show.html.erb

cielf avatar Oct 17 '22 13:10 cielf

@Learningstuff98 2/ The partner can submit for approval with an entirely blank media section. They shouldn't be able to.

cielf avatar Oct 17 '22 14:10 cielf

@Learningstuff98 Argh. I don't think I pulled it down again. Morning brain. Will retest.

cielf avatar Oct 17 '22 15:10 cielf

@Learningstuff98 #1 passes. #2 doesn't. However, that requirement was not in the issue as described.

cielf avatar Oct 17 '22 15:10 cielf

@cielf I'm willing to work on said new issue.

Learningstuff98 avatar Oct 25 '22 23:10 Learningstuff98

@Learningstuff98 Have created the issue and assigned it to you. Thanks!

cielf avatar Oct 26 '22 21:10 cielf