From 4489fc895c8cc90dffa81df9f8e0a5ef1d8b591b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 9 Aug 2021 19:15:30 +0300 Subject: [PATCH 01/10] Refactor dossiers dialog service: add dossier --- .../screens/trash/trash-screen.component.ts | 14 +++++------ .../dossier-details.component.ts | 3 +-- .../dossier-listing-screen.component.ts | 4 ++-- .../file-preview-screen.component.ts | 4 ++-- .../services/dossiers-dialog.service.ts | 24 +++++++------------ apps/red-ui/src/assets/i18n/en.json | 4 ++++ 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts index 93e074a6b..f8d283271 100644 --- a/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/trash/trash-screen.component.ts @@ -27,11 +27,9 @@ interface DossierListItem extends Dossier { }) export class TrashScreenComponent extends BaseListingComponent implements OnInit { readonly itemSize = 80; - protected readonly _primaryKey = 'dossierName'; readonly circleButtonTypes = CircleButtonTypes; - readonly tableHeaderLabel = 'trash.table-header.title'; + readonly tableHeaderLabel = _('trash.table-header.title'); readonly canRestoreSelected$ = this._canRestoreSelected$; - private readonly _deleteRetentionHours = this._appConfigService.getConfig(AppConfigKey.DELETE_RETENTION_HOURS); readonly tableColumnConfigs: TableColumnConfig[] = [ { label: _('trash.table-col-names.name'), @@ -53,6 +51,8 @@ export class TrashScreenComponent extends BaseListingComponent column: 'softDeletedTime' } ]; + protected readonly _primaryKey = 'dossierName'; + private readonly _deleteRetentionHours = this._appConfigService.getConfig(AppConfigKey.DELETE_RETENTION_HOURS); constructor( readonly permissionsService: PermissionsService, @@ -78,10 +78,6 @@ export class TrashScreenComponent extends BaseListingComponent this._loadingService.stop(); } - private _getRestoreDate(softDeletedTime: string): string { - return moment(softDeletedTime).add(this._deleteRetentionHours, 'hours').toISOString(); - } - hardDelete(dossiers = this.entitiesService.selected) { const data = new ConfirmationDialogInput({ title: dossiers.length > 1 ? _('confirmation-dialog.delete-dossier.title-alt') : _('confirmation-dialog.delete-dossier.title'), @@ -105,6 +101,10 @@ export class TrashScreenComponent extends BaseListingComponent this._loadingService.loadWhile(this._restore(dossiers)); } + private _getRestoreDate(softDeletedTime: string): string { + return moment(softDeletedTime).add(this._deleteRetentionHours, 'hours').toISOString(); + } + private async _loadDossiersData(): Promise { this.entitiesService.setEntities(this._toListItems(await this._dossiersService.getDeleted())); } diff --git a/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.ts b/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.ts index 70d4f0b6e..eb2ab0ab2 100644 --- a/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/dossier-details/dossier-details.component.ts @@ -87,7 +87,6 @@ export class DossierDetailsComponent implements OnInit { const ownerName = this._userService.getNameForId(this.owner.id); const dossierName = this.appStateService.activeDossier.name; - const msg = 'Successfully assigned ' + ownerName + ' to dossier: ' + dossierName; - this._toaster.info(msg); + this._toaster.info(_('assignment.owner'), { params: { ownerName, dossierName } }); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts index d270095ce..da559d2f5 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-listing-screen/dossier-listing-screen.component.ts @@ -42,7 +42,6 @@ export class DossierListingScreenComponent implements OnInit, AfterViewInit, OnDestroy, OnAttach, OnDetach { readonly itemSize = 85; - protected readonly _primaryKey = 'dossierName'; readonly currentUser = this._userService.currentUser; readonly tableHeaderLabel = _('dossier-listing.table-header.title'); readonly buttonConfigs: ButtonConfig[] = [ @@ -74,6 +73,7 @@ export class DossierListingScreenComponent ]; dossiersChartData: DoughnutChartConfig[] = []; documentsChartData: DoughnutChartConfig[] = []; + protected readonly _primaryKey = 'dossierName'; private _lastScrollPosition: number; @ViewChild('needsWorkTemplate', { read: TemplateRef, static: true }) private readonly _needsWorkTemplate: TemplateRef; @@ -147,7 +147,7 @@ export class DossierListingScreenComponent } openAddDossierDialog(): void { - this._dialogService.openAddDossierDialog(async addResponse => { + this._dialogService.openDialog('addDossier', null, null, async addResponse => { await this._router.navigate([`/main/dossiers/${addResponse.dossier.dossierId}`]); if (addResponse.addMembers) { this._dialogService.openDialog('editDossier', null, { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 670215425..7050ca463 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -36,6 +36,7 @@ import { TranslateService } from '@ngx-translate/core'; import { AutoUnsubscribeComponent, CircleButtonTypes, NestedFilter, processFilters } from '@iqser/common-ui'; import { fileStatusTranslations } from '../../translations/file-status-translations'; import { handleFilterDelta } from '@shared/components/filters/popup-filter/utils/filter-utils'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f']; @@ -471,8 +472,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme const { dossierId, fileId, filename } = this.fileData.fileStatus; await this._statusControllerService.setFileReviewer(dossierId, fileId, reviewerId).toPromise(); - const msg = `Successfully assigned ${reviewerName} to file: ${filename}`; - this._toaster.info(msg); + this._toaster.info(_('assignment.reviewer'), { params: { reviewerName, filename } }); await this.appStateService.reloadActiveFile(); this._updateCanPerformActions(); this.editingReviewer = false; diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index ac926d292..fd6b05f57 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -30,7 +30,7 @@ const dialogConfig = { // TODO: Continue refactor -type DialogType = 'confirm' | 'documentInfo' | 'editDossier'; +type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier'; type DossiersDialogConfig = { [key in DialogType]: { @@ -52,6 +52,14 @@ export class DossiersDialogService extends DialogService { editDossier: { component: EditDossierDialogComponent, dialogConfig: { ...largeDialogConfig } + }, + addDossier: { + component: AddDossierDialogComponent, + dialogConfig: { + ...dialogConfig, + width: '900px', + autoFocus: true + } } }; @@ -199,18 +207,4 @@ export class DossiersDialogService extends DialogService { return ref; } - - openAddDossierDialog(cb?: Function): MatDialogRef { - const ref = this._dialog.open(AddDossierDialogComponent, { - ...dialogConfig, - width: '900px', - autoFocus: true - }); - - ref.afterClosed().subscribe(result => { - if (result && cb) cb(result); - }); - - return ref; - } } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 371e05607..6f12c9bcd 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -266,6 +266,10 @@ "cancel": "Cancel", "save": "Save" }, + "assignment": { + "owner": "Successfully assigned {ownerName} to dossier: {dossierName}.", + "reviewer": "Successfully assigned {reviewerName} to file: {filename}." + }, "audit": "Audit", "audit-screen": { "all-users": "All Users", From f2694e88536549a3847b297d810265444d7743cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 9 Aug 2021 19:45:53 +0300 Subject: [PATCH 02/10] Refactor dossiers dialog service: assign file to me --- .../dossier/services/dossiers-dialog.service.ts | 16 +--------------- .../dossier/services/file-action.service.ts | 8 +++++++- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index fd6b05f57..b4968e016 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -4,7 +4,7 @@ import { AddDossierDialogComponent } from '../dialogs/add-dossier-dialog/add-dos import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations-dialog/remove-annotations-dialog.component'; import { ForceRedactionDialogComponent } from '../dialogs/force-redaction-dialog/force-redaction-dialog.component'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { ConfirmationDialogComponent, ConfirmationDialogInput } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; +import { ConfirmationDialogComponent } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; import { DossierWrapper } from '@state/model/dossier.wrapper'; import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component'; import { AppStateService } from '@state/app-state.service'; @@ -20,7 +20,6 @@ import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-d import { RecategorizeImageDialogComponent } from '../dialogs/recategorize-image-dialog/recategorize-image-dialog.component'; import { DialogService, largeDialogConfig } from '@shared/services/dialog.service'; import { ComponentType } from '@angular/cdk/portal'; -import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; const dialogConfig = { width: '662px', @@ -177,19 +176,6 @@ export class DossiersDialogService extends DialogService { return ref; } - openAssignFileToMeDialog(cb?: Function) { - const ref = this._dialog.open(ConfirmationDialogComponent, { - ...dialogConfig, - data: new ConfirmationDialogInput({ - title: _('confirmation-dialog.assign-file-to-me.title'), - question: _('confirmation-dialog.assign-file-to-me.question') - }) - }); - ref.afterClosed().subscribe(result => { - if (result && cb) cb(result); - }); - } - openAssignFileToUserDialog( files: FileStatusWrapper[], mode: 'reviewer' | 'approver', diff --git a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts index 438182380..c1d1f6272 100644 --- a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts @@ -6,6 +6,8 @@ import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { PermissionsService } from '@services/permissions.service'; import { isArray } from 'rxjs/internal-compatibility'; import { DossiersDialogService } from './dossiers-dialog.service'; +import { ConfirmationDialogInput } from '../../shared/dialogs/confirmation-dialog/confirmation-dialog.component'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @Injectable() export class FileActionService { @@ -83,7 +85,11 @@ export class FileActionService { const atLeastOneFileHasReviewer = fileStatus.reduce((acc, fs) => acc || !!fs.currentReviewer, false); if (atLeastOneFileHasReviewer) { - this._dialogService.openAssignFileToMeDialog(async () => { + const data = new ConfirmationDialogInput({ + title: _('confirmation-dialog.assign-file-to-me.title'), + question: _('confirmation-dialog.assign-file-to-me.question') + }); + this._dialogService.openDialog('confirm', null, data, async () => { await this._assignReviewerToCurrentUser(fileStatus, callback); }); } else { From d18359aa6ce268da8f4cdfcfe642d403867d93a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 9 Aug 2021 20:36:38 +0300 Subject: [PATCH 03/10] Refactor dossiers dialog service: assign file to user --- ...dossier-overview-bulk-actions.component.ts | 17 +++----- .../file-actions/file-actions.component.ts | 20 +++++---- ...sign-reviewer-approver-dialog.component.ts | 2 +- .../services/dossiers-dialog.service.ts | 24 ++--------- .../dossier/services/file-action.service.ts | 42 ++----------------- 5 files changed, 27 insertions(+), 78 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts index 95c6f8616..bb42177ab 100644 --- a/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -154,16 +154,7 @@ export class DossierOverviewBulkActionsComponent { setToUnderApproval() { // If more than 1 approver - show dialog and ask who to assign if (this._appStateService.activeDossier.approverIds.length > 1) { - this._dialogService.openAssignFileToUserDialog( - this.selectedFiles, - 'approver', - () => { - this._loadingService.start(); - this.reload.emit(); - this._loadingService.stop(); - }, - true - ); + this._assignFiles('approver', true); } else { this._performBulkAction( this._fileActionService.setFileUnderApproval(this.selectedFiles, this._appStateService.activeDossier.approverIds[0]) @@ -196,8 +187,12 @@ export class DossierOverviewBulkActionsComponent { assign() { const mode = this.selectedFiles[0].isUnderApproval ? 'approver' : 'reviewer'; + this._assignFiles(mode); + } - this._dialogService.openAssignFileToUserDialog(this.selectedFiles, mode, () => { + private _assignFiles(mode: 'reviewer' | 'approver', ignoreChanged = false) { + const data = { mode, files: this.selectedFiles, ignoreChanged }; + this._dialogService.openDialog('assignFile', null, data, () => { this._loadingService.start(); this.reload.emit(); this._loadingService.stop(); diff --git a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts index e8396a9fa..7e1657a6b 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts @@ -139,11 +139,9 @@ export class FileActionsComponent implements OnInit { } assign($event: MouseEvent) { - $event.stopPropagation(); - const mode = this.fileStatus.isUnderApproval ? 'approver' : 'reviewer'; - - this._dialogService.openAssignFileToUserDialog([this.fileStatus], mode, () => { + const files = [this.fileStatus]; + this._dialogService.openDialog('assignFile', $event, { mode, files }, () => { this.actionPerformed.emit('assign-reviewer'); }); } @@ -164,9 +162,14 @@ export class FileActionsComponent implements OnInit { } setFileUnderApproval($event: MouseEvent) { - $event.stopPropagation(); if (this.appStateService.activeDossier.approverIds.length > 1) { - this._fileActionService.assignDossierApprover(this.fileStatus, () => this.actionPerformed.emit('assign-reviewer'), true); + this._fileActionService.assignFile( + 'approver', + $event, + this.fileStatus, + () => this.actionPerformed.emit('assign-reviewer'), + true + ); } else { this._fileActionService.setFileUnderApproval(this.fileStatus).subscribe(() => { this.reloadDossiers('set-under-approval'); @@ -189,8 +192,9 @@ export class FileActionsComponent implements OnInit { } setFileUnderReview($event: MouseEvent, ignoreDialogChanges = false) { - $event.stopPropagation(); - this._fileActionService.assignDossierReviewer( + this._fileActionService.assignFile( + 'reviewer', + $event, this.fileStatus, () => this.actionPerformed.emit('assign-reviewer'), ignoreDialogChanges diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts index 22a8c241b..3eeb90183 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts @@ -93,7 +93,7 @@ export class AssignReviewerApproverDialogComponent { this._toaster.error('Failed: ' + error.error ? error.error.message : error); } - this._dialogRef.close(); + this._dialogRef.close(true); } private _loadData() { diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index b4968e016..0a52aaf22 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -13,7 +13,6 @@ import { ManualAnnotationService } from './manual-annotation.service'; import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component'; import { DossierDictionaryDialogComponent } from '../dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component'; import { EditDossierDialogComponent } from '../dialogs/edit-dossier-dialog/edit-dossier-dialog.component'; -import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { AssignReviewerApproverDialogComponent } from '../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component'; import { AppConfigService } from '@app-config/app-config.service'; import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component'; @@ -29,7 +28,7 @@ const dialogConfig = { // TODO: Continue refactor -type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier'; +type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile'; type DossiersDialogConfig = { [key in DialogType]: { @@ -59,6 +58,9 @@ export class DossiersDialogService extends DialogService { width: '900px', autoFocus: true } + }, + assignFile: { + component: AssignReviewerApproverDialogComponent } }; @@ -175,22 +177,4 @@ export class DossiersDialogService extends DialogService { }); return ref; } - - openAssignFileToUserDialog( - files: FileStatusWrapper[], - mode: 'reviewer' | 'approver', - cb?: Function, - ignoreDialogChanges = false - ): MatDialogRef { - const ref = this._dialog.open(AssignReviewerApproverDialogComponent, { - ...dialogConfig, - data: { mode: mode, files: files, ignoreChanged: ignoreDialogChanges } - }); - - ref.afterClosed().subscribe(() => { - if (cb) cb(); - }); - - return ref; - } } diff --git a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts index c1d1f6272..cde315c4a 100644 --- a/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/file-action.service.ts @@ -42,42 +42,6 @@ export class FileActionService { ); } - async assignDossierReviewerFromOverview(file?: FileStatusWrapper, callback?: Function) { - if (this._permissionsService.isOwner()) { - this._openAssignReviewerDialog(file, callback); - } else { - await this.assignToMe(file, callback); - } - } - - assignDossierApprover(file?: FileStatusWrapper, callback?: Function, ignoreDialogChanges = false) { - this._dialogService.openAssignFileToUserDialog( - file ? [file] : [this._appStateService.activeFile], - 'approver', - async () => { - await this._appStateService.reloadActiveDossierFiles(); - if (callback) { - callback(); - } - }, - ignoreDialogChanges - ); - } - - assignDossierReviewer(file?: FileStatusWrapper, callback?: Function, ignoreDialogChanges = false) { - this._dialogService.openAssignFileToUserDialog( - file ? [file] : [this._appStateService.activeFile], - 'reviewer', - async () => { - await this._appStateService.reloadActiveDossierFiles(); - if (callback) { - callback(); - } - }, - ignoreDialogChanges - ); - } - async assignToMe(fileStatus?: FileStatusWrapper | FileStatusWrapper[], callback?: Function) { if (!isArray(fileStatus)) { fileStatus = [fileStatus]; @@ -143,8 +107,10 @@ export class FileActionService { ); } - private _openAssignReviewerDialog(file?: FileStatusWrapper, callback?: Function) { - this._dialogService.openAssignFileToUserDialog(file ? [file] : [this._appStateService.activeFile], 'reviewer', async () => { + assignFile(mode: 'reviewer' | 'approver', $event: MouseEvent, file?: FileStatusWrapper, callback?: Function, ignoreChanged = false) { + const files = file ? [file] : [this._appStateService.activeFile]; + const data = { mode, files, ignoreChanged }; + this._dialogService.openDialog('assignFile', $event, data, async () => { await this._appStateService.reloadActiveDossierFiles(); if (callback) { callback(); From 40a361a6896a7669c2dcce8f06e716d7158483aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 9 Aug 2021 20:44:40 +0300 Subject: [PATCH 04/10] Refactor dossiers dialog service: recategorize image --- .../annotation-actions.component.html | 2 +- .../services/annotation-actions.service.ts | 6 ++--- .../services/dossiers-dialog.service.ts | 23 ++++--------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html index 34385181d..1be35c2eb 100644 --- a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html @@ -45,7 +45,7 @@ > ) { - this._dialogService.openRecategorizeImageDialog($event, annotations, (data: { type: string; comment: string }) => { + recategorizeImages($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter) { + this._dialogService.openDialog('recategorizeImage', $event, annotations, (data: { type: string; comment: string }) => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.recategorizeImage(annotation.annotationId, data.type, data.comment), @@ -147,7 +147,7 @@ export class AnnotationActionsService { title: this._translateService.instant('annotation-actions.recategorize-image'), onClick: () => { this._ngZone.run(() => { - this.recategorizeImage(null, annotations, annotationsChanged); + this.recategorizeImages(null, annotations, annotationsChanged); }); } }); diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index 0a52aaf22..f583df392 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -28,7 +28,7 @@ const dialogConfig = { // TODO: Continue refactor -type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile'; +type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile' | 'recategorizeImage'; type DossiersDialogConfig = { [key in DialogType]: { @@ -61,6 +61,9 @@ export class DossiersDialogService extends DialogService { }, assignFile: { component: AssignReviewerApproverDialogComponent + }, + recategorizeImage: { + component: RecategorizeImageDialogComponent } }; @@ -120,24 +123,6 @@ export class DossiersDialogService extends DialogService { return ref; } - openRecategorizeImageDialog( - $event: MouseEvent, - annotations: AnnotationWrapper[], - cb?: Function - ): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(RecategorizeImageDialogComponent, { - ...dialogConfig, - data: annotations - }); - ref.afterClosed().subscribe(async result => { - if (result && cb) { - cb(result); - } - }); - return ref; - } - openRemoveFromDictionaryDialog( $event: MouseEvent, annotations: AnnotationWrapper[], From dc810ae4910bf239152dbee7c486134e26ca083f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 9 Aug 2021 20:47:44 +0300 Subject: [PATCH 05/10] Refactor dossiers dialog service: change legal basis --- .../services/annotation-actions.service.ts | 2 +- .../services/dossiers-dialog.service.ts | 23 ++++--------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 316bde88a..3d381b8ee 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -59,7 +59,7 @@ export class AnnotationActionsService { } changeLegalBasis($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter) { - this._dialogService.openChangeLegalBasisDialog($event, annotations, (data: { comment: string; legalBasis: string }) => { + this._dialogService.openDialog('changeLegalBasis', $event, annotations, (data: { comment: string; legalBasis: string }) => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.changeLegalBasis(annotation.annotationId, data.legalBasis, data.comment), diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index f583df392..f7ffb1d87 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -28,7 +28,7 @@ const dialogConfig = { // TODO: Continue refactor -type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile' | 'recategorizeImage'; +type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile' | 'recategorizeImage' | 'changeLegalBasis'; type DossiersDialogConfig = { [key in DialogType]: { @@ -64,6 +64,9 @@ export class DossiersDialogService extends DialogService { }, recategorizeImage: { component: RecategorizeImageDialogComponent + }, + changeLegalBasis: { + component: ChangeLegalBasisDialogComponent } }; @@ -105,24 +108,6 @@ export class DossiersDialogService extends DialogService { return ref; } - openChangeLegalBasisDialog( - $event: MouseEvent, - annotations: AnnotationWrapper[], - cb?: Function - ): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(ChangeLegalBasisDialogComponent, { - ...dialogConfig, - data: annotations - }); - ref.afterClosed().subscribe(async result => { - if (result && cb) { - cb(result); - } - }); - return ref; - } - openRemoveFromDictionaryDialog( $event: MouseEvent, annotations: AnnotationWrapper[], From df54ab3fc2da4f815d5ccf1e8a28fc8f267edc8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 10 Aug 2021 15:18:07 +0300 Subject: [PATCH 06/10] Refactor dossiers dialog service: dossier dictionary --- .../dossier-overview-screen.component.ts | 8 ++-- .../services/dossiers-dialog.service.ts | 42 +++++++------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index 7d85260a9..bb2517e42 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -44,12 +44,9 @@ export class DossierOverviewScreenComponent implements OnInit, OnDestroy, OnDetach, OnAttach { readonly itemSize = 80; - protected readonly _primaryKey = 'filename'; readonly circleButtonTypes = CircleButtonTypes; readonly currentUser = this._userService.currentUser; readonly tableHeaderLabel = _('dossier-overview.table-header.title'); - private readonly _lastOpenedFileKey = 'Dossier-Recent-' + this.activeDossier.dossierId; - readonly actionConfigs: ActionConfig[] = [ { label: this._translateService.instant('dossier-overview.header-actions.edit'), @@ -90,9 +87,10 @@ export class DossierOverviewScreenComponent column: 'statusSort' } ]; - collapsedDetails = false; dossierAttributes: DossierAttributeWithValue[] = []; + protected readonly _primaryKey = 'filename'; + private readonly _lastOpenedFileKey = 'Dossier-Recent-' + this.activeDossier.dossierId; @ViewChild(DossierDetailsComponent, { static: false }) private readonly _dossierDetailsComponent: DossierDetailsComponent; private _lastScrollPosition: number; @@ -260,7 +258,7 @@ export class DossierOverviewScreenComponent } openDossierDictionaryDialog() { - this._dialogService.openDossierDictionaryDialog(null, this.activeDossier, () => { + this._dialogService.openDialog('dossierDictionary', null, this.activeDossier, () => { this.reloadDossiers(); }); } diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index f7ffb1d87..24540213a 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -5,7 +5,6 @@ import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations- import { ForceRedactionDialogComponent } from '../dialogs/force-redaction-dialog/force-redaction-dialog.component'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { ConfirmationDialogComponent } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; -import { DossierWrapper } from '@state/model/dossier.wrapper'; import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component'; import { AppStateService } from '@state/app-state.service'; import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper'; @@ -28,7 +27,15 @@ const dialogConfig = { // TODO: Continue refactor -type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile' | 'recategorizeImage' | 'changeLegalBasis'; +type DialogType = + | 'confirm' + | 'documentInfo' + | 'editDossier' + | 'addDossier' + | 'assignFile' + | 'recategorizeImage' + | 'changeLegalBasis' + | 'dossierDictionary'; type DossiersDialogConfig = { [key in DialogType]: { @@ -53,11 +60,7 @@ export class DossiersDialogService extends DialogService { }, addDossier: { component: AddDossierDialogComponent, - dialogConfig: { - ...dialogConfig, - width: '900px', - autoFocus: true - } + dialogConfig: { width: '900px', autoFocus: true } }, assignFile: { component: AssignReviewerApproverDialogComponent @@ -67,6 +70,10 @@ export class DossiersDialogService extends DialogService { }, changeLegalBasis: { component: ChangeLegalBasisDialogComponent + }, + dossierDictionary: { + component: DossierDictionaryDialogComponent, + dialogConfig: { width: '90vw', height: '90vh' } } }; @@ -126,25 +133,4 @@ export class DossiersDialogService extends DialogService { }); return ref; } - - openDossierDictionaryDialog( - $event: MouseEvent, - dossier: DossierWrapper, - cb?: Function - ): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(DossierDictionaryDialogComponent, { - ...dialogConfig, - width: '90vw', - height: '90vh', - autoFocus: false, - data: dossier - }); - ref.afterClosed().subscribe(result => { - if (cb) { - cb(result); - } - }); - return ref; - } } From 92fcc329ba2dfe0048a69d4a7bf04d2ab3aef216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 10 Aug 2021 15:35:10 +0300 Subject: [PATCH 07/10] Refactor dossiers dialog service: remove annotations, force redaction --- .../services/annotation-actions.service.ts | 6 +-- .../services/dossiers-dialog.service.ts | 43 ++++--------------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 3d381b8ee..538be18ea 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -43,8 +43,7 @@ export class AnnotationActionsService { } forceRedaction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter) { - $event?.stopPropagation(); - this._dialogService.openForceRedactionDialog($event, request => { + this._dialogService.openDialog('forceRedaction', $event, null, request => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.forceRedaction({ @@ -76,7 +75,8 @@ export class AnnotationActionsService { removeFromDictionary: boolean, annotationsChanged: EventEmitter ) { - this._dialogService.openRemoveFromDictionaryDialog($event, annotations, removeFromDictionary, result => { + const data = { annotationsToRemove: annotations, removeFromDictionary }; + this._dialogService.openDialog('removeAnnotations', $event, data, result => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.removeOrSuggestRemoveAnnotation(annotation, removeFromDictionary, result.comment), diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index 24540213a..96adebc58 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -3,7 +3,6 @@ import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dial import { AddDossierDialogComponent } from '../dialogs/add-dossier-dialog/add-dossier-dialog.component'; import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations-dialog/remove-annotations-dialog.component'; import { ForceRedactionDialogComponent } from '../dialogs/force-redaction-dialog/force-redaction-dialog.component'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { ConfirmationDialogComponent } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component'; import { AppStateService } from '@state/app-state.service'; @@ -35,7 +34,9 @@ type DialogType = | 'assignFile' | 'recategorizeImage' | 'changeLegalBasis' - | 'dossierDictionary'; + | 'dossierDictionary' + | 'removeAnnotations' + | 'forceRedaction'; type DossiersDialogConfig = { [key in DialogType]: { @@ -74,6 +75,12 @@ export class DossiersDialogService extends DialogService { dossierDictionary: { component: DossierDictionaryDialogComponent, dialogConfig: { width: '90vw', height: '90vh' } + }, + removeAnnotations: { + component: RemoveAnnotationsDialogComponent + }, + forceRedaction: { + component: ForceRedactionDialogComponent } }; @@ -101,36 +108,4 @@ export class DossiersDialogService extends DialogService { return ref; } - - openForceRedactionDialog($event: MouseEvent, cb?: Function): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(ForceRedactionDialogComponent, { - ...dialogConfig - }); - ref.afterClosed().subscribe(async result => { - if (result && cb) { - cb(result); - } - }); - return ref; - } - - openRemoveFromDictionaryDialog( - $event: MouseEvent, - annotations: AnnotationWrapper[], - removeFromDictionary: boolean, - cb?: Function - ): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(RemoveAnnotationsDialogComponent, { - ...dialogConfig, - data: { annotationsToRemove: annotations, removeFromDictionary: removeFromDictionary } - }); - ref.afterClosed().subscribe(async result => { - if (result) { - if (cb) cb(result); - } - }); - return ref; - } } From 50455186eb4e1f4981c56303fe1ec9dde13c2d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 10 Aug 2021 15:39:15 +0300 Subject: [PATCH 08/10] Refactor dossiers dialog service: manual annotation --- .../file-preview-screen.component.ts | 32 ++++++++++------- .../services/dossiers-dialog.service.ts | 34 ++++--------------- 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 7050ca463..d19f81fe7 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -323,21 +323,27 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme this._workloadComponent?.scrollAnnotationsToPage(pageNumber, 'always'); } - openManualAnnotationDialog($event: ManualRedactionEntryWrapper) { + openManualAnnotationDialog(entryWrapper: ManualRedactionEntryWrapper) { this._ngZone.run(() => { - this.dialogRef = this._dialogService.openManualAnnotationDialog($event, async (response: ManualAnnotationResponse) => { - if (response?.annotationId) { - const annotation = this._instance.annotManager.getAnnotationById(response.manualRedactionEntryWrapper.rectId); - this._instance.annotManager.deleteAnnotation(annotation); - this.fileData.fileStatus = await this.appStateService.reloadActiveFile(); - const distinctPages = $event.manualRedactionEntry.positions - .map(p => p.page) - .filter((item, pos, self) => self.indexOf(item) === pos); - distinctPages.forEach(page => { - this._cleanupAndRedrawManualAnnotationsForEntirePage(page); - }); + console.log({ entryWrapper }); + this.dialogRef = this._dialogService.openDialog( + 'manualAnnotation', + null, + entryWrapper, + async (response: ManualAnnotationResponse) => { + if (response?.annotationId) { + const annotation = this._instance.annotManager.getAnnotationById(response.manualRedactionEntryWrapper.rectId); + this._instance.annotManager.deleteAnnotation(annotation); + this.fileData.fileStatus = await this.appStateService.reloadActiveFile(); + const distinctPages = entryWrapper.manualRedactionEntry.positions + .map(p => p.page) + .filter((item, pos, self) => self.indexOf(item) === pos); + distinctPages.forEach(page => { + this._cleanupAndRedrawManualAnnotationsForEntirePage(page); + }); + } } - }); + ); }); } diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index 96adebc58..33e1eb7a8 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -1,12 +1,11 @@ import { Injectable } from '@angular/core'; -import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog'; +import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { AddDossierDialogComponent } from '../dialogs/add-dossier-dialog/add-dossier-dialog.component'; import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations-dialog/remove-annotations-dialog.component'; import { ForceRedactionDialogComponent } from '../dialogs/force-redaction-dialog/force-redaction-dialog.component'; import { ConfirmationDialogComponent } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component'; import { AppStateService } from '@state/app-state.service'; -import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper'; import { ManualAnnotationService } from './manual-annotation.service'; import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component'; import { DossierDictionaryDialogComponent } from '../dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component'; @@ -18,14 +17,6 @@ import { RecategorizeImageDialogComponent } from '../dialogs/recategorize-image- import { DialogService, largeDialogConfig } from '@shared/services/dialog.service'; import { ComponentType } from '@angular/cdk/portal'; -const dialogConfig = { - width: '662px', - maxWidth: '90vw', - autoFocus: false -} as const; - -// TODO: Continue refactor - type DialogType = | 'confirm' | 'documentInfo' @@ -36,7 +27,8 @@ type DialogType = | 'changeLegalBasis' | 'dossierDictionary' | 'removeAnnotations' - | 'forceRedaction'; + | 'forceRedaction' + | 'manualAnnotation'; type DossiersDialogConfig = { [key in DialogType]: { @@ -81,6 +73,10 @@ export class DossiersDialogService extends DialogService { }, forceRedaction: { component: ForceRedactionDialogComponent + }, + manualAnnotation: { + component: ManualAnnotationDialogComponent, + dialogConfig: { autoFocus: true } } }; @@ -92,20 +88,4 @@ export class DossiersDialogService extends DialogService { ) { super(_dialog); } - - openManualAnnotationDialog($event: ManualRedactionEntryWrapper, cb?: Function): MatDialogRef { - const ref = this._dialog.open(ManualAnnotationDialogComponent, { - ...dialogConfig, - autoFocus: true, - data: $event - }); - - ref.afterClosed().subscribe(result => { - if (cb) { - cb(result); - } - }); - - return ref; - } } From fa9134b490aaef30c9f4853c329891eaf48be9d8 Mon Sep 17 00:00:00 2001 From: Bamboo Date: Tue, 10 Aug 2021 14:54:07 +0200 Subject: [PATCH 09/10] chore(release) --- libs/common-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common-ui b/libs/common-ui index 98ae1d569..f1e8d9011 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 98ae1d5698a838ed1e3febf0b30dfa81f44b2c16 +Subproject commit f1e8d9011cff19f684d4681ee2cce3e3e980c3c3 From cd5a39407b2a99f34a8ac50f74b65ec4ccfdabc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 10 Aug 2021 15:56:40 +0300 Subject: [PATCH 10/10] Styles fix --- apps/red-ui/src/assets/styles/red-text-styles.scss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/red-ui/src/assets/styles/red-text-styles.scss b/apps/red-ui/src/assets/styles/red-text-styles.scss index 52c509f6a..554f5a160 100644 --- a/apps/red-ui/src/assets/styles/red-text-styles.scss +++ b/apps/red-ui/src/assets/styles/red-text-styles.scss @@ -94,11 +94,6 @@ pre { white-space: nowrap; } -.primary { - color: $primary; - opacity: 1; -} - .no-wrap { white-space: nowrap; }