From 31eacd1f31223d880a04fdc7c4f5b24f843d8d94 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Tue, 3 Nov 2020 22:30:08 +0200 Subject: [PATCH] temporary dictionary add workaround --- .../app/common/filter/utils/filter-utils.ts | 2 +- apps/red-ui/src/app/dialogs/dialog.service.ts | 2 +- .../file/service/manual-annotation.service.ts | 43 ++++++------------- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/apps/red-ui/src/app/common/filter/utils/filter-utils.ts b/apps/red-ui/src/app/common/filter/utils/filter-utils.ts index 5c9bcf287..31e40ef20 100644 --- a/apps/red-ui/src/app/common/filter/utils/filter-utils.ts +++ b/apps/red-ui/src/app/common/filter/utils/filter-utils.ts @@ -1,7 +1,7 @@ import { FilterModel } from '../model/filter.model'; export function handleCheckedValue(filter: FilterModel) { - if (filter.filters) { + if (filter.filters && filter.filters.length) { filter.checked = filter.filters.reduce((acc, next) => acc && next.checked, true); if (filter.checked) { filter.indeterminate = false; diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 21fe9ce1a..f414861e7 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -110,7 +110,7 @@ export class DialogService { ref.afterClosed().subscribe((result) => { if (result) { this._manualAnnotationService - .acceptSuggestion(annotation) + .acceptSuggestion(annotation.id) .subscribe((acceptResult) => { if (callback) { callback(acceptResult); diff --git a/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts b/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts index b0d598246..c613bac6b 100644 --- a/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts +++ b/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts @@ -44,28 +44,33 @@ export class ManualAnnotationService { } public makeDictionaryEntry(manualRedactionEntry: ManualRedactionEntry) { - // if (this._appStateService.isActiveProjectOwner) { - // return this._makeDictionaryEntry(manualRedactionEntry); - // } else { - return this._makeDictionaryRequest(manualRedactionEntry); - // } + manualRedactionEntry.addToDictionary = true; + return this.makeRedaction(manualRedactionEntry); } public makeRedaction(manualRedactionEntry: ManualRedactionEntry) { - if (this._appStateService.isActiveProjectOwner) { - return this._makeRedaction(manualRedactionEntry); + if (this._appStateService.isActiveProjectOwnerAndManager) { + if (!manualRedactionEntry.addToDictionary) { + return this._makeRedaction(manualRedactionEntry); + } else { + return this._makeRedactionRequest(manualRedactionEntry).pipe( + mergeMap((response) => { + return this.acceptSuggestion(response.annotationId); + }) + ); + } } else { return this._makeRedactionRequest(manualRedactionEntry); } } - public acceptSuggestion(annotationWrapper: AnnotationWrapper) { + public acceptSuggestion(annotationId: string) { // for only here - approve the request return this._manualRedactionControllerService .approveRequest( this._appStateService.activeProjectId, this._appStateService.activeFile.fileId, - annotationWrapper.id + annotationId ) .pipe( tap( @@ -108,26 +113,6 @@ export class ManualAnnotationService { public removeRedaction(annotationWrapper: AnnotationWrapper) {} - private _makeDictionaryRequest(manualRedactionEntry: ManualRedactionEntry) { - return this._makeRedactionRequest(manualRedactionEntry); - } - - private _makeDictionaryEntry(manualRedactionEntry: ManualRedactionEntry) { - return this._dictionaryControllerService - .addEntry([manualRedactionEntry.value], manualRedactionEntry.type) - .pipe( - tap( - () => this._notify('manual-annotation.dictionary-add.success'), - () => { - this._notify( - 'manual-annotation.dictionary-add.error', - NotificationType.ERROR - ); - } - ) - ); - } - private _makeRedactionRequest(manualRedactionEntry: ManualRedactionEntry) { return this._manualRedactionControllerService .requestAddRedaction(