-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
Prevent import of inventory if storage location already has items in it and double importing #4300
Prevent import of inventory if storage location already has items in it and double importing #4300
Conversation
<i class="fa fa-upload"></i> Import CSV | ||
<% end %> | ||
<li style="margin-bottom: 27px;">Then click the "Import CSV" button to import your <%= import_type.downcase %>.</li> | ||
<%= button_tag class: "btn btn-md btn-info", data: { disable_with: "Importing" } do %> |
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.
Only thing changed was adding data: { disable_with: "Importing" }
, otherwise rearranging the button tag to be in its own line.
Looked into writing a system spec for this but it's near impossible to trigger a double click the way we want . The various double click methods (.click.click
, double_click
, or using js trigger
or execute_script
) don't actually let you double click. Neither double clicks results in two backend calls, only once.
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.
I think that's fine - if we are validating this on the backend, that's the most important check. Frontend is more of a nice to have.
app/models/storage_location.rb
Outdated
@@ -132,6 +132,11 @@ def self.import_csv(csv, organization) | |||
# @param loc [Integer] StorageLocation ID | |||
# @return [void] | |||
def self.import_inventory(filename, org, loc) | |||
storage_location = StorageLocation.find(loc.to_i) | |||
storage_location_exists = storage_location.size > 0 |
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.
We need this to work both with and without event sourcing. Can you use the method empty_inventory?
instead to check this? That's works with both.
<i class="fa fa-upload"></i> Import CSV | ||
<% end %> | ||
<li style="margin-bottom: 27px;">Then click the "Import CSV" button to import your <%= import_type.downcase %>.</li> | ||
<%= button_tag class: "btn btn-md btn-info", data: { disable_with: "Importing" } do %> |
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.
I think that's fine - if we are validating this on the backend, that's the most important check. Frontend is more of a nice to have.
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.
Hey @vincent-truong-dev - I noticed that rubocop is failing with your latest -- you'll need to address that.
@cielf @dorner all green now. I encountered a transient system spec failure in https://github.com/rubyforgood/human-essentials/actions/runs/8882912643/job/24388616782, worth creating a ticket for? |
Thanks for pointing it out! I'm pretty sure that's the one that PR #4268 is addressing, so no need to create a ticket. |
All good! |
@vincent-truong-dev: Your PR |
Fixes #3687
Partially borrowed from #3696
Description
Importing storage location inventory can have 2 weird behaviours
Import CSV
is double clicked, there is double inventory when it should be just one import.The fix is
Import CSV
button with a greyed out look and text once clicked.Type of change
How Has This Been Tested?
Double tab issue
http://localhost:3000/diaper_bank/storage_locations/<id>
to show an individual storage location in both tabsImport CSV
in both tabsDouble click issue
http://localhost:3000/diaper_bank/storage_locations/<id>
to show an individual storage location in one tabImport CSV
in one tabImporting
like in screenshot.Screenshots