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

Added ability to bulk delete locations #14304

Merged
merged 19 commits into from
Feb 20, 2024
Merged

Added ability to bulk delete locations #14304

merged 19 commits into from
Feb 20, 2024

Conversation

snipe
Copy link
Owner

@snipe snipe commented Feb 20, 2024

This PR is a bit bigger and messier than I'd like, but as I was testing this, I found a few inconsistencies and bugs elsewhere. Sorry, @uberbrady - I know it's going to make this much harder to review.

I added some JS to selectively allow checkboxes to be checkable. I want this to be a LOT more nuanced, but there are some UI challenges with how bulk actions currently work that will make that a little tricksy. For example, the way I had originally done this, I added a sort of selectability object to the API response, which we could potentially use to determine which checkboxes should be selectable and which ones shouldn't. Problem is, the context is important, and we need to change that selectability based on the bulk actions dropdown options we present. This PR just covers bulk deleting locations, but down the line, I want this behavior to be a lot more ubiquitous for bulk actions. It gets complicated because without knowing the users' intents, we can't really decide what should be checkable or not checkable. I still think it can be done, but it started to get way out of scope for this PR, which is already a bit out of scope for what I wanted to accomplish.

  • Removed a bunch of debugging code from other sections because it was kinda pooping up my logs. I know this wasn't the right place for it, but it had to be done at some point.
  • Fixed an incorrect gate on the models bulk edit dropdown - again, out of scope, but it was broken
  • Fixed a missing parameter for the isDeletable() model method for locations. We were not accounting for child locations when deciding whether or not a location was deletable
  • Made a few changes where instead of using the asset count for a location, we actually use the isDeletable() method, which should make this easier to maintain moving forward
  • Did some crazy mojo magic for translations which should set the stage for being able to pass more variables via trans_choice() for strings and cut down on duplicated (or almost duplicated) strings. This should make life a lot easier on our translators.
  • Fixed a few @return statements that were incorrect or incomplete
  • BONUS: Added manager_id to the locations API filter, which then let me switch us over to using the API for "Managed Locations" within the user detail view (no more client-side sorting, which speeds up page load quite a bit)
    • Which then also let me apply the location bulk delete on the user's view under "Managed Locations", same as we do for asset/model bulk editing
Screen.Recording.2024-02-20.at.5.45.00.PM.mov

User View Before

Screenshot 2024-02-20 at 5 48 36 PM

User View After

Screenshot 2024-02-20 at 5 48 55 PM
Screen.Recording.2024-02-20.at.5.46.58.PM.mov

snipe added 18 commits February 16, 2024 18:57
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Copy link

@snipe snipe requested a review from uberbrady February 20, 2024 17:51
Copy link

what-the-diff bot commented Feb 20, 2024

PR Summary

  • Added attribute and functionality to Location Model
    An attribute 'children_count' has been added, enabling record of how many 'sub locations' associate with each location.

  • New Parameters in LocationsController
    A new parameter 'manager_id' is now part of the index method in the LocationsController, giving the ability to fetch locations based on managers' ID.

  • Enhancements to Bulk Delete in LocationsController
    A new feature of Bulk delete has been introduced, with methods postBulkDelete and postBulkDeleteStore implemented.

  • Locations View Update & Bulk Delete
    A new view locations/bulk-delete.blade.php has been created specifically for bulk delete actions.

  • New methods for LocationsController
    Methods print_all_assigned and print_assigned have been added to provide the capability of printing all or specific assigned locations.

  • Improvements to UI Interaction
    Selected checkboxes are now enhanced with the selected class in assets-models. The DataTableLayout function and other formatters in bootstrap-table.blade.php have been updated to improve table layouts and functionalities.

  • User Experience Improvements
    There have been updates to the User view file, allowing a more intuitive presentation.

  • Enhancements to UserTransformer and LocationTransformer
    The UserTransformer class now has the getUserManagerLocations attribute and the Location transformer includes the user_can_checkout attribute.

  • Bulk Edit & Delete Classes
    The bulk-edit and bulk-delete classes have been added to improve bulk operations in user.view, models.index and locations.index files.

  • UserPresenter Updates
    An edit_fieldset attribute has been added to the UserPresenter class for improved user information editing.

  • SelectAllRows Method
    The method selectAllRows has been added to the User view.blade.php file, allowing selection of all rows with a single click.

  • ModelsController Bulk Delete Enhancements
    The postBulkDeleteStore and postBulkDelete methods have been added to the ModelsController to improve bulk delete functionality.

Signed-off-by: snipe <[email protected]>
Copy link
Collaborator

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

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

This is an excellent change, and because it was BIG I was a little bit rigorous as I went through in review. Every change here seems warranted, and good, and good for the future and good for the product. This is some very excellent work, and I know it was painstaking and hard, and I think all of that effort paid off. Thank you, and I definitely approve.

app/Http/Controllers/Api/UsersController.php Show resolved Hide resolved
app/Models/Location.php Show resolved Hide resolved
resources/lang/en-US/general.php Show resolved Hide resolved
resources/views/users/view.blade.php Show resolved Hide resolved
@snipe snipe merged commit 71610fb into develop Feb 20, 2024
8 checks passed
@snipe snipe deleted the feature/sc-24018 branch February 20, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants