Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't default an Item seletion in edit pulldowns if Item lookup fails #1088

Closed
mdworken opened this issue Jul 15, 2019 · 7 comments · Fixed by #1172
Closed

Don't default an Item seletion in edit pulldowns if Item lookup fails #1088

mdworken opened this issue Jul 15, 2019 · 7 comments · Fixed by #1172
Assignees
Labels
🐞 Bug Help Wanted Groomed + open to all!
Milestone

Comments

@mdworken
Copy link
Member

mdworken commented Jul 15, 2019

Summary

Sometimes item lookup for these edit views can fail. When this happens, the app defaults to the first item in the pulldown (Adult Diaper XXL in the seed data).

This is a big problem because it can cause the item to be switched unintentionally.

Preferred behavior would be to display the field as blank and force the user to select a choice before hitting submit.

Steps to Reproduce

(I think this will work -- @armahillo )

  • Create an Itemizable record (ie. Donation)
  • Add any item that isn't the first in the list to it (ie. "5T Diapers", quantity 10)
  • Save it
  • Go into Items and locate that item ("1T Diapers") and "delete" it (it will just deactivate it)
  • Go back to Donations and edit the record from earlier
  • If the bug occurs, you should see the first item in the list selected. "5T Diapers" should not be in the list

Desired Behavior

As above, but either:

  • (a) make the selection blank and indicate on that line or somewhere on the page that the specific item has been deleted, so they will need to choose a new one. Be sure the notice refers to the original item by name.
  • (b) append the original item to the collection but temporarily change its :name field to end with "(deleted)" (in this case, if they save the record it should persist the change correctly, even though the item is deactivated. The item should not be re-activated in the process.)
@jeduardo824
Copy link
Collaborator

I going to take a look at this

@jeduardo824
Copy link
Collaborator

I did some research about this issue, and I didn't find any solution to solve this using Rails' default form. An option to solve this would be using something like select2

@mdworken mdworken added the Ruby For Good 2019 DC Created for Ruby for Good 2019 DC label Jul 26, 2019
@mdworken mdworken removed the Ruby For Good 2019 DC Created for Ruby for Good 2019 DC label Aug 3, 2019
@armahillo
Copy link
Collaborator

@jeduardo824 Thanks for investigating!

I think what @mdworken was suggesting was to have include_blank: true for that select element, and indicating selected: __the_item_that_was_chosen__, which should fix this behavior. I don't think we need to add any additional gems for this.

@armahillo armahillo added this to the Release 1.7 milestone Aug 4, 2019
@armahillo armahillo added 🐞 Bug Help Wanted Groomed + open to all! Good First Issue Suitable for users that are newer or less experienced and removed Good First Issue Suitable for users that are newer or less experienced labels Aug 4, 2019
@jeduardo824
Copy link
Collaborator

@armahillo Yeah! I thought that, but when I tested it, nothing fixed the behavior. Maybe I did something wrong...

@armahillo
Copy link
Collaborator

@jeduardo824 If you have opinions on how to implement this please push back, otherwise I think you can get by with:

  • add include_blank: true to the field
  • add selected: selected_item_id to the field
  • if you can get a test to work using the repro stuff I added to the description above, that's awesome, if not just manual test it and ensure that it works and create a test stub (write the example name and put a pending in the first line of it)

@jeduardo824
Copy link
Collaborator

I can make some tests this week!

@mdworken mdworken self-assigned this Aug 11, 2019
@mdworken
Copy link
Member Author

I've confirmed that @armahillo 's suggestion doesn't quite work, but found a work around. I'll push my code up once I'm in front of a computer again.

@mdworken mdworken changed the title Don't default an Item in (Donation/Purchase/Distribution/etc) edit pulldowns if Item lookup fails Don't default an Item seletion in edit pulldowns if Item lookup fails Aug 11, 2019
mdworken pushed a commit that referenced this issue Aug 11, 2019
mdworken pushed a commit that referenced this issue Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug Help Wanted Groomed + open to all!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants