-
Notifications
You must be signed in to change notification settings - Fork 29
Bulk Edit: Changes are applied very slowly, one by one #3451
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8d0b8d9
integrate confirmation dialog for bulk edit progress indication
Abhinegi2 947c754
lint fixes
Abhinegi2 13cc91c
Merge branch 'master' into refactor/bulk-edit-save
Abhinegi2 79dcfb7
implement bulk operation handling in entities table and related compo…
Abhinegi2 8dbdc62
use readonly
Abhinegi2 403be69
added ngondestroy
Abhinegi2 74236f6
refactor: optimize entity update handling with buffered updates
Abhinegi2 1785ca0
refactor bulk operation handling and progress tracking in entity comp…
Abhinegi2 4ec6c61
remove legecy code
Abhinegi2 b8b6c0d
Merge branch 'master' into refactor/bulk-edit-save
Abhinegi2 88dcb1e
refactoring + enhance bulk operation handling
Abhinegi2 c76811f
fix test + qlty fix
Abhinegi2 b1ca5ca
updated other actions
Abhinegi2 c29db26
fix test cae
Abhinegi2 151f9ee
fix qlty checks
Abhinegi2 30171e0
Merge branch 'master' into refactor/bulk-edit-save
Abhinegi2 054e003
cleanups
Abhinegi2 3bf24ec
fix coderabbit feedback
Abhinegi2 3adedc3
Merge branch 'master' into refactor/bulk-edit-save
sleidig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...core/common-components/confirmation-dialog/progress-dialog/progress-dialog.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <h1 mat-dialog-title> | ||
| {{ data.message }} | ||
| {{ message() }} | ||
| </h1> | ||
|
|
||
| <div mat-dialog-content> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
src/app/core/entity/entity-actions/bulk-operation-state.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import { | ||
| inject, | ||
| Injectable, | ||
| OnDestroy, | ||
| signal, | ||
| WritableSignal, | ||
| } from "@angular/core"; | ||
| import { BehaviorSubject } from "rxjs"; | ||
| import { ConfirmationDialogService } from "../../common-components/confirmation-dialog/confirmation-dialog.service"; | ||
| import { MatDialogRef } from "@angular/material/dialog"; | ||
|
|
||
| /** | ||
| * Service to communicate bulk operation status between edit service and list components | ||
| */ | ||
| @Injectable({ | ||
| providedIn: "root", | ||
| }) | ||
| export class BulkOperationStateService implements OnDestroy { | ||
| private readonly confirmationDialog = inject(ConfirmationDialogService); | ||
|
|
||
| private readonly operationInProgress = new BehaviorSubject<boolean>(false); | ||
| private progressDialogRef: MatDialogRef<any> | null = null; | ||
Abhinegi2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private readonly progressDialogMessage: WritableSignal<string> = signal( | ||
| $localize`:Bulk edit progress message:Preparing bulk action ...`, | ||
| ); | ||
| private expectedUpdateCount = 0; | ||
| private processedUpdateCount = 0; | ||
|
|
||
| isBulkOperationInProgress$ = this.operationInProgress.asObservable(); | ||
| isBulkOperationInProgress(): boolean { | ||
| return this.operationInProgress.value; | ||
| } | ||
|
|
||
| /** | ||
| * Start a bulk operation | ||
| */ | ||
| startBulkOperation(expectedCount?: number) { | ||
| this.expectedUpdateCount = expectedCount || 0; | ||
| this.processedUpdateCount = 0; | ||
| this.operationInProgress.next(true); | ||
| this.updateProgressDialog(); | ||
| this.progressDialogRef = this.confirmationDialog.showProgressDialog( | ||
| this.progressDialogMessage, | ||
| ); | ||
| } | ||
Abhinegi2 marked this conversation as resolved.
Show resolved
Hide resolved
sleidig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Update bulk operation progress based on received entity updates. | ||
| * Called by list components when they receive entity update events. | ||
| * | ||
| * @return boolean - whether the bulk operation is still in progress | ||
| */ | ||
| updateBulkOperationProgress( | ||
| count: number, | ||
| autoCompleteBulkOperation?: boolean, | ||
| ): boolean { | ||
| if (!this.operationInProgress.value) { | ||
| return false; | ||
| } | ||
|
|
||
| this.processedUpdateCount += count; | ||
| this.updateProgressDialog(); | ||
|
|
||
| if (this.processedUpdateCount >= this.expectedUpdateCount) { | ||
| if (autoCompleteBulkOperation) { | ||
| this.completeBulkOperation(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Get expected update count | ||
| */ | ||
| getExpectedUpdateCount(): number { | ||
| return this.expectedUpdateCount; | ||
| } | ||
|
|
||
| /** | ||
| * Get current processed update count | ||
| */ | ||
| getProcessedUpdateCount(): number { | ||
| return this.processedUpdateCount; | ||
| } | ||
|
|
||
| /** | ||
| * Update progress dialog with current progress | ||
| */ | ||
| private updateProgressDialog() { | ||
| this.progressDialogMessage.set( | ||
| $localize`:Bulk edit progress message:Updated ${this.processedUpdateCount} of ${this.expectedUpdateCount} records...`, | ||
| ); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Complete a bulk operation. | ||
| * | ||
| * Called automatically, unless there is errors during the bulk operation, | ||
| * in which case the caller should close the operation manually | ||
| */ | ||
| completeBulkOperation() { | ||
| this.operationInProgress.next(false); | ||
| this.processedUpdateCount = 0; | ||
| this.expectedUpdateCount = 0; | ||
| if (this.progressDialogRef) { | ||
| this.progressDialogRef.close(); | ||
| this.progressDialogRef = null; | ||
| } | ||
| } | ||
|
|
||
| ngOnDestroy() { | ||
| if (this.operationInProgress.value) { | ||
| this.completeBulkOperation(); | ||
| } | ||
|
|
||
| this.operationInProgress.complete(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.