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

4745: Disable deactivate button for storage locations not deactivatable #4775

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Nov 11, 2024

Resolves #4745

Description

We should only be able to deactivate storage locations with no inventory items.

Type of change

I guess a new feature?

How Has This Been Tested?

Added request specs for both paths (when read_events feature flag is enabled or disabled).

Screenshots

Here are before and after screenshots. Note the red deactivate buttons become disabled for locations with nonzero inventory items.

Before:
image
After:
image

@coalest coalest force-pushed the 4745-disable-deactivate-button-unless-storage-location-is-deactibatable branch 6 times, most recently from c94abee to 3b71eca Compare November 12, 2024 14:50
@coalest coalest force-pushed the 4745-disable-deactivate-button-unless-storage-location-is-deactibatable branch from 3b71eca to f6028f8 Compare November 12, 2024 14:51
@cielf cielf requested review from dorner and cielf November 15, 2024 19:34
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Looks great from a functional 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.

Looks pretty good - had a suggestion.

<td><%= number_to_currency(storage_location.inventory_total_value_in_dollars(@inventory)) %></td>
<td class="text-right">
<%= view_button_to storage_location %>
<%= edit_button_to edit_storage_location_path(storage_location) %>
<% if storage_location.discarded? %>
<%= reactivate_button_to storage_location_reactivate_path(storage_location), { confirm: confirm_reactivate_msg(storage_location.name) } %>
<% else %>
<%= deactivate_button_to storage_location_deactivate_path(storage_location), { confirm: confirm_deactivate_msg(storage_location.name) } %>
<%= deactivate_button_to storage_location_deactivate_path(storage_location),
{ confirm: confirm_deactivate_msg(storage_location.name), enabled: @inventory_item_totals[storage_location.id].zero? } %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Calculating the inventory total is super quick since it's all in memory. I think I'd rather not have the extra instance variable and do this check live.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed that new instance variable.

@coalest coalest requested a review from dorner November 19, 2024 11:54
@dorner
Copy link
Collaborator

dorner commented Nov 22, 2024

Thanks!

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

@coalest: Your PR 4745: Disable deactivate button for storage locations not deactivatable 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.

Storage location deactivate button should be disabled unless the storage location is deactivatable
3 participants