From 699df081e03d976445f7bcb0b154afb65b412511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Fri, 3 Jun 2022 18:28:52 +0300 Subject: [PATCH] RED-4151: download dictionary / false positives / false recommendations --- .../dictionary-screen.component.html | 2 + .../dictionary/dictionary-screen.component.ts | 17 ++++--- .../dictionary-manager.component.html | 48 +++++++++++-------- .../dictionary-manager.component.ts | 12 ++++- .../src/app/services/permissions.service.ts | 4 ++ apps/red-ui/src/assets/i18n/de.json | 7 +-- apps/red-ui/src/assets/i18n/en.json | 7 +-- libs/common-ui | 2 +- 8 files changed, 59 insertions(+), 40 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/entities/screens/dictionary/dictionary-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/entities/screens/dictionary/dictionary-screen.component.html index 30e79e8e4..ff89234fd 100644 --- a/apps/red-ui/src/app/modules/admin/screens/entities/screens/dictionary/dictionary-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/entities/screens/dictionary/dictionary-screen.component.html @@ -1,7 +1,9 @@ ([]); isLeavingPage = false; readonly type: DictionaryType; + readonly entityType: string; readonly #dossierTemplateId: string; - readonly #entityType: string; @ViewChild('dictionaryManager', { static: false }) private readonly _dictionaryManager: DictionaryManagerComponent; constructor( - route: ActivatedRoute, - userService: UserService, + readonly route: ActivatedRoute, + readonly userService: UserService, + readonly permissionsService: PermissionsService, private readonly _loadingService: LoadingService, private readonly _dictionaryService: DictionaryService, ) { this.currentUser = userService.currentUser; this.#dossierTemplateId = route.parent.snapshot.paramMap.get(DOSSIER_TEMPLATE_ID); - this.#entityType = route.parent.snapshot.paramMap.get(ENTITY_TYPE); + this.entityType = route.parent.snapshot.paramMap.get(ENTITY_TYPE); this.type = route.snapshot.routeConfig.path as DictionaryType; } @@ -51,7 +54,7 @@ export class DictionaryScreenComponent implements OnInit { entries, this.initialEntries$.value, this.#dossierTemplateId, - this.#entityType, + this.entityType, null, true, DICTIONARY_TO_ENTRY_TYPE_MAP[this.type], @@ -66,7 +69,7 @@ export class DictionaryScreenComponent implements OnInit { private async _loadEntries() { this._loadingService.start(); try { - const data = await firstValueFrom(this._dictionaryService.getForType(this.#dossierTemplateId, this.#entityType)); + const data = await firstValueFrom(this._dictionaryService.getForType(this.#dossierTemplateId, this.entityType)); const entries: List = data[DICTIONARY_TYPE_KEY_MAP[this.type]]; this.initialEntries$.next([...entries].sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' }))); this._loadingService.stop(); diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html index 4dfa09fe4..cadf3b027 100644 --- a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html +++ b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html @@ -1,28 +1,38 @@
-
- +
+
+ -
-
- -
-
-
- {{ currentMatch + '/' + findMatches.length }} +
+
+ +
+
+
+ {{ currentMatch + '/' + findMatches.length }} +
+ + +
- - -
+ +
diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts index 004482d7f..1c9a9bca7 100644 --- a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts @@ -9,6 +9,7 @@ import { ActiveDossiersService } from '@services/dossiers/active-dossiers.servic import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { EditorComponent } from '@shared/components/editor/editor.component'; import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; +import { saveAs } from 'file-saver'; import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration; import FindMatch = monaco.editor.FindMatch; @@ -23,14 +24,15 @@ export class DictionaryManagerComponent implements OnChanges { readonly iconButtonTypes = IconButtonTypes; @Input() type: DictionaryType = 'dictionary'; + @Input() entityType?: string; @Input() withFloatingActions = true; @Input() filterByDossierTemplate = false; @Input() initialEntries: List; @Input() canEdit = false; + @Input() canDownload = false; @Input() isLeavingPage = false; @Output() readonly saveDictionary = new EventEmitter(); @ViewChild(EditorComponent) readonly editor: EditorComponent; - currentMatch = 0; findMatches: FindMatch[] = []; diffEditorText = ''; @@ -151,6 +153,14 @@ export class DictionaryManagerComponent implements OnChanges { return this.dossier.dossierName === this.selectDossier.dossierName; } + download(): void { + const content = this.editor.currentEntries.join('\n'); + const blob = new Blob([content], { + type: 'text/plain;charset=utf-8', + }); + saveAs(blob, `${this.entityType}-${this.type}.txt`); + } + revert() { this.editor?.revert(); this.searchChanged(''); diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index e0ace6220..8462ab5b4 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -16,6 +16,10 @@ export class PermissionsService { return this._userService.currentUser.id; } + canDownloadEntityDictionary(): boolean { + return this.isAdmin() || this.isManager(); + } + canEditEntities(): boolean { return this.isAdmin(); } diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index 973f53c6d..3fa044f0e 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -564,12 +564,6 @@ "title": "{count, plural, one{{justificationName}} other{ausgewählte Begründungen}} löschen" }, "input-label": "Bitte geben Sie unten Folgendes ein, um fortzufahren", - "keep-manual-redactions": { - "confirmation-text": "", - "deny-text": "", - "question": "", - "title": "" - }, "report-template-same-name": { "confirmation-text": "Ja. Hochladen fortsetzen", "deny-text": "Nein. Hochladen abbrechen", @@ -635,6 +629,7 @@ "select-dossier": "Dossier auswählen", "select-dossier-template": "Dossiervorlage auswählen" }, + "download": "", "error": { "entries-too-short": "Einige Einträge im Wörterbuch unterschreiten die Mindestlänge von 2 Zeichen. Diese sind rot markiert.", "generic": "Es ist ein Fehler aufgetreten ... Das Wörterbuch konnte nicht aktualisiert werden!" diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 559b167d6..74ed57195 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -564,12 +564,6 @@ "title": "Delete {count, plural, one{{justificationName}} other{Selected Justifications}}" }, "input-label": "To proceed please type below", - "keep-manual-redactions": { - "confirmation-text": "Keep", - "deny-text": "Clear", - "question": "At least one of the files you're overwriting has manual changes, do you wish to keep them?", - "title": "Keep Manual Redactions?" - }, "report-template-same-name": { "confirmation-text": "Yes. Continue upload", "deny-text": "No. Cancel Upload", @@ -635,6 +629,7 @@ "select-dossier": "Select Dossier", "select-dossier-template": "Select Dossier Template" }, + "download": "Download current entries", "error": { "entries-too-short": "Some entries of the dictionary are below the minimum length of 2. These are highlighted with red!", "generic": "Something went wrong... Dictionary update failed!" diff --git a/libs/common-ui b/libs/common-ui index a814fc8aa..43a9067bf 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit a814fc8aa7a16c9acdaa9b7dd749e4493a54e1c2 +Subproject commit 43a9067bf3c712316c78223a243ae98868e46932