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

4780: Fix item lookup issues on new kit page #4781

Merged
merged 7 commits into from
Nov 22, 2024

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Nov 13, 2024

Resolves #4780

Description

The new kit view was missing the bootstrap modal to add new barcode items, and the proper HTML id in order for a new item to be adding automatically after adding an item via barcode.

Note: Because the JS relies on the add another item button to have a certain id, I moved that into the helper method, for future error proofing.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added a new system test. (Not sure how else to test this behavior because it relies on JS)

@cielf cielf requested a review from dorner November 15, 2024 20:00
@cielf
Copy link
Collaborator

cielf commented Nov 15, 2024

Looks good to me from a funcitonal pov. Over to @dorner for technical comments

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this existed before - but in previous usages, the ID was added in the calling code, which "knew" that the IDs were unique. In this case we're moving it to the helper, so we need to be a bit more careful.

@@ -14,6 +14,7 @@ def add_element_button(label, container_selector:, **html_attrs, &block)
add_dest_selector: container_selector,
action: "click->form-input#addItem:prevent" },
role: "button",
id: "__add_line_item",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes we'd never have more than one "add element button" on a page. Can we key off something other than ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I will move the id back to being passed in as an argument.

While we could change it to being an .add_line_item class here, we would have to modify the JS that clicks this button automatically to find the element by class rather than id. And then use some logic to determine which (or all) of the add element buttons to click. Which feels like coding for some hypothetical future case of having mutliple add item buttons, which doesn't exist yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this id back to being an argument.

@@ -22,7 +22,7 @@
</div>
<div class="row links">
<div class="col-xs-12 p-3">
<%= add_element_button "Add Another Item", container_selector: "#audit_line_items" do %>
<%= add_element_button "Add Another Item", container_selector: "#audit_line_items", id: "__add_line_item" do %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that this method call was also missing the id option.

I added some corresponding system specs, but I can remove them if you think the coverage isn't worth the extra weight of system specs.

@coalest coalest requested a review from dorner November 18, 2024 18:57
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dorner dorner merged commit f0b9f80 into rubyforgood:main Nov 22, 2024
11 checks passed
Copy link
Contributor

@coalest: Your PR 4780: Fix item lookup issues on new kit page is part of today's Human Essentials production release: 2024.11.24.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Item lookup fails when adding items in a new kit
3 participants