refactor(admin): fix and unify selection across list components supporting server-pagination
Description
This merge request contains initial part of selection overhaul with the goal of fixing issues and unifying behavior across all tables in Perun GUI that allow selection.
This overhaul was in the end decided to be split into two phases:
- Tables supporting server-pagination (this MR)
- Rest of the tables ( !1596 (merged))
The goal of the overhaul is to achieve behavior mostly outlined in this breakdown, with an exception of the option to select all items in the whole table.
Here is a summary of the desired behavior:
- Bulk operations are executed only for data displayed on current page
- Selected items are cached when changing pages
- Selected items are restored upon :
- Returning to a page with previously selected items
- Changing page size
- Sorting change
- Selected items are cleared when any filter is applied or the table is refreshed
- Master checkbox (and its state) corresponds to state of the current page and none other
- Master checkbox is disabled with an explanatory tool-tip, if none of the items on current page can be selected
- Both server-side pagination and client-side pagination behave exactly the same
Changes summarized
-
NOTE:
- All the modified list components have been changed to use table-checkbox-modified service instead of table-checkbox service. This is to allow the changes to be applied to only the modified list components without affecting those that have not yet been touched. These two services will be merged back into one after.
- Because of this, GIT won't show only the changes made, but the whole file as added. For this reason I would probably suggest using a text compare tool of some sorts on the original and modified services for true display of changes to this service, however inconvenient that may be.
- All the modified list components have been changed to use table-checkbox-modified service instead of table-checkbox service. This is to allow the changes to be applied to only the modified list components without affecting those that have not yet been touched. These two services will be merged back into one after.
-
(This change has been incorporated and merged in !1596 (merged))
-
table-wrapper~~ component now emits an event on page change~~
-
- 5 list components that support both server-pagination and selection have been modified (applications-list, members-list, users-list, blocked-logins-list, groups-list)
- Changed to temporarily use the modified version of TableCheckbox service
- selection now does not have a default value and only gains one when used as input
- Created cachedSelection to store all selected items. It is only initialized in ngOnInit() if selection has been given as an input
- ngOnChanges reacts to changes of source data and text filter
- pageChanged() function processes page changes in client-side paginated tables
- Added logic to handle disabled checkboxes in lists that support it (members-list, groups-list)
- Each of the 5 components' parent components (containing selection) have been modified to accommodate the changes.(1 parent component for applications-list, 7 for members-list, 6 for users-list, 1 for blocked-logins-list and 19 for groups-list)
- Selection is fully defined with compareWith function
- Any changes in visibility of elements now only happen when the component is not loading
- For pages where it is needed, a new BehaviorSubject named cacheSubject has been created to communicate the need to clear cachedSelection in the child component
-
(These changes have been incorporated and merged in !1596 (merged))
-
table-checkbox-modified~~ service~~contains logic supporting the new functionality and now works with cachedSelection in functions that already existed
-
How to test
Check the changed tables in GUI, their functionality and keep an eye out for errors (notably ExpressionChangedAfterItHasBeenCheckedError).
Also check if changes to the list components did not break instances where they are used without selection.
Author's checklist
-
I have followed the contribution guidelines -
This MR has been tested or does not change functionality -
I have added relevant merge request dependencies (if this MR has any) -
I have added the correct labels -
I have assigned reviewers (if any are relevant) -
I have edited the documentation (if the changes require it) or I have noted the need for the change if I do not have access to the documentation -
I have marked all introduced BREAKING CHANGES or necessary DEPLOYMENT NOTES in the commit message(s)
Reviewer's checklist
-
This MR has been tested or does not change functionality -
This MR has correct commit message format
Related issues
Edited by Michal Berky