From eb7816ab72df9b067fc18bec7cbdd203f50a406c Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 10 Mar 2023 20:12:56 +0200 Subject: [PATCH] RED-6377: fix redaction toggle --- ...dossier-overview-bulk-actions.component.ts | 6 ++- .../table-item/table-item.component.ts | 3 +- .../workflow-item/workflow-item.component.ts | 3 +- .../file-actions/file-actions.component.html | 2 +- .../file-actions/file-actions.component.ts | 43 ++++++++++--------- .../expandable-file-actions.component.ts | 2 +- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts index 443ed5c06..4245fb641 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -48,7 +48,7 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { ) {} private get _buttons(): Action[] { - return [ + const actions: Action[] = [ { id: 'delete-files-btn', type: ActionTypes.circleBtn, @@ -161,7 +161,9 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { checked: !this.#allFilesAreExcluded, show: this.#canToggleAnalysis, }, - ].filter(btn => btn.show); + ]; + + return actions.filter(btn => btn.show); } ngOnChanges() { diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/table-item/table-item.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/table-item/table-item.component.ts index 657dead78..3cce7aa73 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/table-item/table-item.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/table-item/table-item.component.ts @@ -1,11 +1,10 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { Dossier, File, IFileAttributeConfig } from '@red/domain'; @Component({ selector: 'redaction-table-item [file] [dossier] [displayedAttributes] [dossierTemplateId]', templateUrl: './table-item.component.html', styleUrls: ['./table-item.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class TableItemComponent { @Input() file: File; diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/workflow-item/workflow-item.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/workflow-item/workflow-item.component.ts index 35da040ca..f2a7488d8 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/workflow-item/workflow-item.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/workflow-item/workflow-item.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; +import { ChangeDetectorRef, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; import { Dossier, File, IFileAttributeConfig } from '@red/domain'; import { Debounce } from '@iqser/common-ui'; @@ -6,7 +6,6 @@ import { Debounce } from '@iqser/common-ui'; selector: 'redaction-workflow-item [file] [dossier] [displayedAttributes]', templateUrl: './workflow-item.component.html', styleUrls: ['./workflow-item.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class WorkflowItemComponent implements OnInit { @Input() file: File; diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.html b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.html index 9541fae3e..0fffc25b6 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.html +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts index 9e56ff3ec..b9d9fed90 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts @@ -120,9 +120,10 @@ export class FileActionsComponent implements OnChanges { } private get _buttons(): Action[] { - return [ + const fileId = this.file.fileId; + const actions: Action[] = [ { - id: 'delete-file-btn', + id: 'delete-file-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._openDeleteFileDialog($event), tooltip: _('dossier-overview.delete.action'), @@ -130,7 +131,7 @@ export class FileActionsComponent implements OnChanges { show: this.showDelete, }, { - id: 'assign-btn', + id: 'assign-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._assign($event), tooltip: this.assignTooltip, @@ -138,7 +139,7 @@ export class FileActionsComponent implements OnChanges { show: this.showAssign, }, { - id: 'assign-to-me-btn', + id: 'assign-to-me-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._assignToMe($event), tooltip: _('dossier-overview.assign-me'), @@ -146,7 +147,7 @@ export class FileActionsComponent implements OnChanges { show: this.showAssignToSelf, }, { - id: 'open-import-redactions-dialog-btn', + id: 'open-import-redactions-dialog-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._openImportRedactionsDialog($event), tooltip: _('dossier-overview.import-redactions'), @@ -154,7 +155,7 @@ export class FileActionsComponent implements OnChanges { show: this.showImportRedactions && !this._iqserPermissionsService.has(ROLES.getRss), }, { - id: 'download-file-btn', + id: 'download-file-btn-' + fileId, type: ActionTypes.downloadBtn, files: [this.file], dossier: this.dossier, @@ -163,7 +164,7 @@ export class FileActionsComponent implements OnChanges { disabled: this.file.processingStatus === ProcessingFileStatuses.ERROR, }, { - id: 'toggle-document-info-btn', + id: 'toggle-document-info-btn-' + fileId, type: ActionTypes.circleBtn, action: () => this._documentInfoService.toggle(), tooltip: _('file-preview.document-info'), @@ -172,7 +173,7 @@ export class FileActionsComponent implements OnChanges { show: !!this._documentInfoService, }, { - id: 'toggle-exclude-pages-btn', + id: 'toggle-exclude-pages-btn-' + fileId, type: ActionTypes.circleBtn, action: () => this._excludedPagesService.toggle(), tooltip: _('file-preview.exclude-pages'), @@ -185,7 +186,7 @@ export class FileActionsComponent implements OnChanges { !this._iqserPermissionsService.has(ROLES.getRss), }, { - id: 'set-file-to-new-btn', + id: 'set-file-to-new-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._setToNew($event), tooltip: _('dossier-overview.back-to-new'), @@ -193,7 +194,7 @@ export class FileActionsComponent implements OnChanges { show: this.showSetToNew, }, { - id: 'set-file-under-approval-btn', + id: 'set-file-under-approval-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._setFileUnderApproval($event), tooltip: _('dossier-overview.under-approval'), @@ -201,7 +202,7 @@ export class FileActionsComponent implements OnChanges { show: this.showUnderApproval, }, { - id: 'set-file-under-review-btn', + id: 'set-file-under-review-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._setFileUnderReview($event), tooltip: _('dossier-overview.under-review'), @@ -209,7 +210,7 @@ export class FileActionsComponent implements OnChanges { show: this.showUnderReview, }, { - id: 'set-file-approved-btn', + id: 'set-file-approved-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this.setFileApproved($event), tooltip: this.file.canBeApproved ? _('dossier-overview.approve') : _('dossier-overview.approve-disabled'), @@ -218,7 +219,7 @@ export class FileActionsComponent implements OnChanges { show: this.showApprove, }, { - id: 'toggle-automatic-analysis-btn', + id: 'toggle-automatic-analysis-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._toggleAutomaticAnalysis($event), tooltip: _('dossier-overview.stop-auto-analysis'), @@ -226,7 +227,7 @@ export class FileActionsComponent implements OnChanges { show: this.canDisableAutoAnalysis, }, { - id: 'reanalyse-file-preview-btn', + id: 'reanalyse-file-preview-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._reanalyseFile($event), tooltip: _('file-preview.reanalyse-notification'), @@ -236,7 +237,7 @@ export class FileActionsComponent implements OnChanges { disabled: this.file.isProcessing, }, { - id: 'toggle-automatic-analysis-btn', + id: 'toggle-automatic-analysis-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._toggleAutomaticAnalysis($event), tooltip: _('dossier-overview.start-auto-analysis'), @@ -245,7 +246,7 @@ export class FileActionsComponent implements OnChanges { show: this.canEnableAutoAnalysis, }, { - id: 'set-under-approval-btn', + id: 'set-under-approval-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._setFileUnderApproval($event), tooltip: _('dossier-overview.under-approval'), @@ -253,7 +254,7 @@ export class FileActionsComponent implements OnChanges { show: this.showUndoApproval, }, { - id: 'ocr-file-btn', + id: 'ocr-file-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._ocrFile($event), tooltip: _('dossier-overview.ocr-file'), @@ -261,7 +262,7 @@ export class FileActionsComponent implements OnChanges { show: this.showOCR, }, { - id: 'reanalyse-file-btn', + id: 'reanalyse-file-btn-' + fileId, type: ActionTypes.circleBtn, action: ($event: MouseEvent) => this._reanalyseFile($event), tooltip: _('dossier-overview.reanalyse.action'), @@ -269,7 +270,7 @@ export class FileActionsComponent implements OnChanges { show: this.showReanalyseDossierOverview, }, { - id: 'toggle-analysis-btn', + id: 'toggle-analysis-btn-' + fileId, type: ActionTypes.toggle, action: () => this._toggleAnalysis(), disabled: !this.canToggleAnalysis, @@ -278,7 +279,9 @@ export class FileActionsComponent implements OnChanges { checked: !this.file.excluded, show: this.showToggleAnalysis, }, - ].filter(btn => btn.show); + ]; + + return actions.filter(btn => btn.show); } ngOnChanges(changes: SimpleChanges) { diff --git a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts index 872e16569..62f6e255f 100644 --- a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts @@ -30,7 +30,7 @@ export class ExpandableFileActionsComponent implements OnChanges { expanded = false; @ViewChild(MatMenuTrigger) matMenu: MatMenuTrigger; - trackBy = trackByFactory(); + readonly trackBy = trackByFactory(); constructor( private readonly _fileDownloadService: FileDownloadService,