-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
#4398: Support units in requests #4510
Conversation
If anyone wants to grab this and finish writing the specs before I can get to it, feel free :) |
# Conflicts: # db/migrate/20240704214509_backfill_partner_child_requested_items.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. I'm not sure if that the first custom unit should be the default, or if it should be units. I think it's a question for the stakeholders. (The initial vision forced a choice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I was just playing around, and this sequence causes an Oops! Something went wrong.
Pick an item that does have units (e.g. Pads in our seed). Fill in the quantity. Then change to an item that does not have units and submit.
@cielf pushed the fix! |
The test that is failing has packs in its description, so might be a real failure? |
Should be fixed now! |
LGTM @awwaiid could you take a look? |
# hash of (item ID => hash of (request unit name => request unit plural name)) | ||
@item_units = current_partner.organization.items.to_h do |i| | ||
[i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is identical to the one in create
please extract it into a private method.
<td> | ||
<%= field.label :item_id, "Item Requested", {class: 'sr-only'} %> | ||
<%= field.select :item_id, @requestable_items, {include_blank: 'Select an item'}, {class: 'form-control'} %> | ||
<%= field.select :item_id, @requestable_items, {include_blank: 'Select an item'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we already only show the @requestable_items
in the item select drop-down, so that already narrows down what we might show in the units drop down. So the generated @item_units
having all possible items it works fine, but could be narrowed down to building off of @requestable_items
Further thoughts on the default -- if we have multiple custom units the first one may or may not be the most used. I'm wondering if we should default at all. (Or we may yet need to add a default unit indicator). We'll figure this out after talking to the business on Wednesday. |
@dorner We talked to the business Wednesday, and they said they'd rather have the units not initially selected, but that, of course, they have to select something. This is because a single bank will have partners who do packs and partners that don't and they want to avoid a default that would be a mistake. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and manual testing also worked; I triggered a re-run of the failing test in case it is a flake.
@dorner I keep trying combinations of re-running these failing tests and trying to get it to fail locally and so far no luck :( |
Ah, I got it to fail and then fixed it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sightly tricky since I added a bit, but looks good :)
@dorner: Your PR |
Resolves #4398
Description
This shows a Units field if the partner's organization has any custom request units.
If the selected item has any request units, the Unit drop-down is shown and the first custom request unit is selected. Otherwise, the drop-down is not shown.
If the enable_packs flag is off, no behavior change is shown.
Type of change
How Has This Been Tested?
Local testing. Still needs specs created.
Screenshots