From e463bb9e5a72f2c1fd4d9c8843c96380c8c11164 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 20 Oct 2021 23:07:42 +0300 Subject: [PATCH] remove typevalue --- apps/red-ui/src/app/models/dictionary.ts | 18 ++++-- .../src/app/models/file/file-data.model.ts | 4 +- apps/red-ui/src/app/models/file/type-value.ts | 41 ------------- .../add-edit-dictionary-dialog.component.ts | 16 ++--- .../dictionary-listing-screen.component.html | 2 +- .../dictionary-listing-screen.component.ts | 12 ++-- .../dictionary-overview-screen.component.ts | 6 +- .../edit-dossier-dictionary.component.ts | 4 +- .../manual-annotation-dialog.component.ts | 6 +- .../services/manual-annotation.service.ts | 2 +- .../annotation-icon.component.html | 2 +- .../annotation-icon.component.ts | 12 ++-- .../dictionary-annotation-icon.component.ts | 5 +- .../dictionary-manager.component.ts | 14 ++--- .../shared/services/dictionary.service.ts | 14 ++--- .../red-ui/src/app/state/app-state.service.ts | 60 +++++++++---------- libs/red-ui-http/src/lib/model/dictionary.ts | 6 +- libs/red-ui-http/src/lib/model/models.ts | 3 +- libs/red-ui-http/src/lib/model/typeValue.ts | 57 ------------------ ...updateTypeValue.ts => updateDictionary.ts} | 2 +- 20 files changed, 98 insertions(+), 188 deletions(-) delete mode 100644 apps/red-ui/src/app/models/file/type-value.ts delete mode 100644 libs/red-ui-http/src/lib/model/typeValue.ts rename libs/red-ui-http/src/lib/model/{updateTypeValue.ts => updateDictionary.ts} (97%) diff --git a/apps/red-ui/src/app/models/dictionary.ts b/apps/red-ui/src/app/models/dictionary.ts index 53f4d6350..01e7a327f 100644 --- a/apps/red-ui/src/app/models/dictionary.ts +++ b/apps/red-ui/src/app/models/dictionary.ts @@ -6,31 +6,37 @@ export class Dictionary implements IDictionary, IListable { readonly caseInsensitive: boolean; readonly description?: string; readonly dossierTemplateId?: string; - readonly entries?: List; + entries: List; readonly hexColor?: string; readonly hint: boolean; readonly label: string; readonly rank?: number; readonly recommendation: boolean; + readonly type: string; - constructor(dictionary: IDictionary) { + constructor(dictionary: IDictionary, readonly virtual = false) { this.addToDictionaryAction = !!dictionary.addToDictionaryAction; this.caseInsensitive = !!dictionary.caseInsensitive; this.description = dictionary.description; this.dossierTemplateId = dictionary.dossierTemplateId; - this.entries = dictionary.entries; + this.entries = dictionary.entries ?? []; this.hexColor = dictionary.hexColor; this.hint = !!dictionary.hint; - this.label = dictionary.label; + this.label = dictionary.label ?? dictionary.type; this.rank = dictionary.rank; this.recommendation = !!dictionary.recommendation; + this.type = dictionary.type; } get id(): string { - return this.label; + return this.type; } get searchKey(): string { - return this.label; + return this.label ?? this.type; + } + + get routerLink(): string { + return `/main/admin/dossier-templates/${this.dossierTemplateId}/dictionaries/${this.type}`; } } diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index b11200841..9056d7d37 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -4,8 +4,8 @@ import { AnnotationWrapper } from './annotation.wrapper'; import { RedactionLogEntryWrapper } from './redaction-log-entry.wrapper'; import { ViewMode } from './view-mode'; import * as moment from 'moment'; -import { TypeValue } from './type-value'; import { User } from '@models/user'; +import { Dictionary } from '@models/dictionary'; export class AnnotationData { visibleAnnotations: AnnotationWrapper[]; @@ -20,7 +20,7 @@ export class FileDataModel { constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: ViewedPages) {} getAnnotations( - dictionaryData: { [p: string]: TypeValue }, + dictionaryData: { [p: string]: Dictionary }, currentUser: User, viewMode: ViewMode, areDevFeaturesEnabled: boolean, diff --git a/apps/red-ui/src/app/models/file/type-value.ts b/apps/red-ui/src/app/models/file/type-value.ts deleted file mode 100644 index d9c3a5b04..000000000 --- a/apps/red-ui/src/app/models/file/type-value.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { IListable } from '@iqser/common-ui'; -import { ITypeValue } from '@redaction/red-ui-http'; - -export class TypeValue implements ITypeValue, IListable { - readonly type: string; - readonly addToDictionaryAction: boolean; - readonly caseInsensitive: boolean; - readonly description?: string; - readonly dossierTemplateId?: string; - readonly hexColor?: string; - readonly label?: string; - readonly hint: boolean; - readonly rank?: number; - readonly recommendation: boolean; - entries: string[] = []; - - constructor(typeValue: ITypeValue, readonly virtual = false) { - this.type = typeValue.type; - this.addToDictionaryAction = !!typeValue.addToDictionaryAction; - this.caseInsensitive = !!typeValue.caseInsensitive; - this.description = typeValue.description; - this.dossierTemplateId = typeValue.dossierTemplateId; - this.hexColor = typeValue.hexColor; - this.hint = !!typeValue.hint; - this.rank = typeValue.rank; - this.recommendation = !!typeValue.recommendation; - this.label = typeValue.label; - } - - get id(): string { - return this.type; - } - - get searchKey(): string { - return this.type; - } - - get routerLink(): string { - return `/main/admin/dossier-templates/${this.dossierTemplateId}/dictionaries/${this.type}`; - } -} diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts index 9a7ad256d..1b513895a 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts @@ -1,15 +1,15 @@ import { Component, Inject } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ITypeValue } from '@redaction/red-ui-http'; import { Observable } from 'rxjs'; import { Toaster } from '@iqser/common-ui'; import { TranslateService } from '@ngx-translate/core'; -import { TypeValue } from '@models/file/type-value'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { AppStateService } from '@state/app-state.service'; import { toKebabCase } from '@utils/functions'; import { DictionaryService } from '@shared/services/dictionary.service'; +import { IDictionary } from '@redaction/red-ui-http'; +import { Dictionary } from '@models/dictionary'; @Component({ selector: 'redaction-add-edit-dictionary-dialog', @@ -18,7 +18,7 @@ import { DictionaryService } from '@shared/services/dictionary.service'; }) export class AddEditDictionaryDialogComponent { dictionaryForm: FormGroup; - readonly dictionary: TypeValue; + readonly dictionary: Dictionary; technicalName = ''; private readonly _dossierTemplateId: string; @@ -30,7 +30,7 @@ export class AddEditDictionaryDialogComponent { private readonly _translateService: TranslateService, private readonly _dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) - private readonly _data: { dictionary: TypeValue; dossierTemplateId: string }, + private readonly _data: { dictionary: Dictionary; dossierTemplateId: string }, ) { this.dictionary = _data.dictionary; this._dossierTemplateId = _data.dossierTemplateId; @@ -83,15 +83,15 @@ export class AddEditDictionaryDialogComponent { } saveDictionary(): void { - const typeValue: ITypeValue = this._formToObject(); + const dictionary = this._formToObject(); let observable: Observable; if (this.dictionary) { // edit mode - observable = this._dictionaryService.updateType(typeValue, this._dossierTemplateId, typeValue.type); + observable = this._dictionaryService.updateDictionary(dictionary, this._dossierTemplateId, dictionary.type); } else { // create mode - observable = this._dictionaryService.addType({ ...typeValue, dossierTemplateId: this._dossierTemplateId }); + observable = this._dictionaryService.addDictionary({ ...dictionary, dossierTemplateId: this._dossierTemplateId }); } observable.subscribe( @@ -120,7 +120,7 @@ export class AddEditDictionaryDialogComponent { this.technicalName = technicalName; } - private _formToObject(): ITypeValue { + private _formToObject(): IDictionary { return { type: this.dictionary?.type || this.technicalName, label: this.dictionaryForm.get('label').value, diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html index 5e0a5c4ca..d311fb1ad 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html @@ -103,7 +103,7 @@
- +
diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts index 9e1335baa..f7380fb6f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts @@ -4,7 +4,6 @@ import { AppStateService } from '@state/app-state.service'; import { catchError, defaultIfEmpty, tap } from 'rxjs/operators'; import { forkJoin, of } from 'rxjs'; import { ActivatedRoute } from '@angular/router'; -import { TypeValue } from '@models/file/type-value'; import { TranslateService } from '@ngx-translate/core'; import { CircleButtonTypes, @@ -19,8 +18,9 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { UserService } from '@services/user.service'; import { DictionaryService } from '@shared/services/dictionary.service'; import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service'; +import { Dictionary } from '@models/dictionary'; -const toChartConfig = (dict: TypeValue): DoughnutChartConfig => ({ +const toChartConfig = (dict: Dictionary): DoughnutChartConfig => ({ value: dict.entries?.length ?? 0, color: dict.hexColor, label: dict.label, @@ -32,12 +32,12 @@ const toChartConfig = (dict: TypeValue): DoughnutChartConfig => ({ styleUrls: ['./dictionary-listing-screen.component.scss'], providers: [...DefaultListingServices, { provide: ListingComponent, useExisting: forwardRef(() => DictionaryListingScreenComponent) }], }) -export class DictionaryListingScreenComponent extends ListingComponent implements OnInit { +export class DictionaryListingScreenComponent extends ListingComponent implements OnInit { readonly iconButtonTypes = IconButtonTypes; readonly circleButtonTypes = CircleButtonTypes; readonly currentUser = this._userService.currentUser; readonly tableHeaderLabel = _('dictionary-listing.table-header.title'); - readonly tableColumnConfigs: TableColumnConfig[] = [ + readonly tableColumnConfigs: TableColumnConfig[] = [ { label: _('dictionary-listing.table-col-names.type'), sortByKey: 'searchKey', width: '2fr' }, { label: _('dictionary-listing.table-col-names.order-of-importance'), sortByKey: 'rank', class: 'flex-center' }, { label: _('dictionary-listing.table-col-names.hint-redaction'), class: 'flex-center' }, @@ -67,7 +67,7 @@ export class DictionaryListingScreenComponent extends ListingComponent { this._loadingService.start(); await this._dictionaryService - .deleteTypes( + .deleteDictionaries( types.map(t => t.type), this._dossierTemplatesService.activeDossierTemplateId, ) @@ -79,7 +79,7 @@ export class DictionaryListingScreenComponent extends ListingComponent { - await this._dictionaryService.deleteTypes([this.dictionary.type], this.dictionary.dossierTemplateId).toPromise(); + await this._dictionaryService.deleteDictionaries([this.dictionary.type], this.dictionary.dossierTemplateId).toPromise(); await this._appStateService.loadDictionaryData(); await this._router.navigate([ '/main', diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/dictionary/edit-dossier-dictionary.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/dictionary/edit-dossier-dictionary.component.ts index 3cfc3e99e..b543c4916 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/dictionary/edit-dossier-dictionary.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/dictionary/edit-dossier-dictionary.component.ts @@ -46,9 +46,9 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa } async updateDisplayName(label: string) { - const typeValue: IDictionary = { ...this.dossier.type, label }; + const dictionary: IDictionary = { ...this.dossier.type, label }; await this._dictionaryService - .updateType(typeValue, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id) + .updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id) .toPromise(); await this._dossiersService.updateDossierDictionary(this.dossier.dossierTemplateId, this.dossier.id); this.updateDossier.emit(); diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 21c8fa4df..67ea29bb7 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -10,9 +10,9 @@ import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry import { ManualAnnotationService } from '../../services/manual-annotation.service'; import { ManualAnnotationResponse } from '@models/file/manual-annotation-response'; import { PermissionsService } from '@services/permissions.service'; -import { TypeValue } from '@models/file/type-value'; import { DossiersService } from '@services/entity-services/dossiers.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; +import { Dictionary } from '@models/dictionary'; export interface LegalBasisOption { label?: string; @@ -32,7 +32,7 @@ export class ManualAnnotationDialogComponent implements OnInit { isDictionaryRequest: boolean; isFalsePositiveRequest: boolean; - redactionDictionaries: TypeValue[] = []; + redactionDictionaries: Dictionary[] = []; legalOptions: LegalBasisOption[] = []; constructor( @@ -62,7 +62,7 @@ export class ManualAnnotationDialogComponent implements OnInit { }); for (const key of Object.keys(this._appStateService.dictionaryData[this._dossiersService.activeDossier.dossierTemplateId])) { - const dictionaryData = this._appStateService.getDictionaryTypeValue(key); + const dictionaryData = this._appStateService.getDictionary(key); if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) { this.redactionDictionaries.push(dictionaryData); } diff --git a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts index cdda0a666..54c60dfbf 100644 --- a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts @@ -69,7 +69,7 @@ export class ManualAnnotationService extends GenericService { this._toaster.error(this._getMessage(mode, modifyDictionary, true, isConflict), { error, params: { - dictionaryName: this._appStateService.getDictionaryTypeValue(body.type).label, + dictionaryName: this._appStateService.getDictionary(body.type).label, content: body.value, }, positionClass: 'toast-file-preview', diff --git a/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.html b/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.html index c5748ee0d..854591c74 100644 --- a/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.html +++ b/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.html @@ -6,5 +6,5 @@ [class.request]="isRequest" class="icon" > - {{ label || dictType.label.charAt(0) }} + {{ label || dictionary.label.charAt(0) }}
diff --git a/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.ts b/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.ts index af8909ecc..420dce889 100644 --- a/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/annotation-icon/annotation-icon.component.ts @@ -1,5 +1,5 @@ import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core'; -import { TypeValue } from '@models/file/type-value'; +import { Dictionary } from '@models/dictionary'; @Component({ selector: 'redaction-annotation-icon', @@ -10,24 +10,24 @@ export class AnnotationIconComponent implements OnChanges { @Input() color: string; @Input() type: 'square' | 'rhombus' | 'circle' | 'hexagon' | 'none'; @Input() label: string; - @Input() dictType: TypeValue; + @Input() dictionary: Dictionary; @ViewChild('icon', { static: true }) icon: ElementRef; get isHint() { - return this.type === 'circle' || this.dictType?.type === 'hint'; + return this.type === 'circle' || this.dictionary?.type === 'hint'; } get isRequest() { - return this.type === 'rhombus' || this.dictType?.type === 'redaction'; + return this.type === 'rhombus' || this.dictionary?.type === 'redaction'; } get isRecommendation() { - return this.type === 'hexagon' || this.dictType?.type === 'recommendation'; + return this.type === 'hexagon' || this.dictionary?.type === 'recommendation'; } get backgroundColor() { - return this.color || this.dictType?.hexColor; + return this.color || this.dictionary?.hexColor; } ngOnChanges() { diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-annotation-icon/dictionary-annotation-icon.component.ts b/apps/red-ui/src/app/modules/shared/components/dictionary-annotation-icon/dictionary-annotation-icon.component.ts index b4260759b..323c38b9b 100644 --- a/apps/red-ui/src/app/modules/shared/components/dictionary-annotation-icon/dictionary-annotation-icon.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/dictionary-annotation-icon/dictionary-annotation-icon.component.ts @@ -1,6 +1,5 @@ import { Component, Input, OnChanges } from '@angular/core'; import { AppStateService } from '@state/app-state.service'; -import { TypeValue } from '@models/file/type-value'; @Component({ selector: 'redaction-dictionary-annotation-icon', @@ -19,9 +18,9 @@ export class DictionaryAnnotationIconComponent implements OnChanges { ngOnChanges(): void { if (this.dictionaryKey) { - const typeValue: TypeValue = this._appStateService.getDictionaryTypeValue(this.dictionaryKey, this.dossierTemplateId); + const dictionary = this._appStateService.getDictionary(this.dictionaryKey, this.dossierTemplateId); this.color = this._appStateService.getDictionaryColor(this.dictionaryKey, this.dossierTemplateId); - this.type = typeValue.hint ? 'circle' : 'square'; + this.type = dictionary.hint ? 'circle' : 'square'; this.label = this.dictionaryKey[0].toUpperCase(); } } 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 1cec571f2..081de28a0 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 @@ -10,7 +10,7 @@ import { DossierTemplatesService } from '@services/entity-services/dossier-templ import { DossierTemplate } from '@models/file/dossier-template'; import { AppStateService } from '@state/app-state.service'; import { EditorComponent } from '@shared/components/editor/editor.component'; -import { TypeValue } from '@models/file/type-value'; +import { Dictionary } from '@models/dictionary'; import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration; import FindMatch = monaco.editor.FindMatch; @@ -39,10 +39,10 @@ export class DictionaryManagerComponent implements OnChanges { selectDossier = { dossierName: _('dictionary-overview.compare.select-dossier') } as Dossier; selectDictionary = { label: _('dictionary-overview.compare.select-dictionary'), - } as TypeValue; + } as Dictionary; selectDossierTemplate = { name: _('dictionary-overview.compare.select-dossier-template') } as DossierTemplate; compare: false; - dictionaries: List = this._dictionaries; + dictionaries: List = this._dictionaries; private _searchDecorations: string[] = []; constructor( @@ -94,7 +94,7 @@ export class DictionaryManagerComponent implements OnChanges { return this._dictionary; } - set dictionary(dictionary: TypeValue) { + set dictionary(dictionary: Dictionary) { this._dictionary = dictionary; if (dictionary.label === this.selectDictionary.label) { @@ -107,7 +107,7 @@ export class DictionaryManagerComponent implements OnChanges { this.appStateService.dictionaryData[this._dictionary.dossierTemplateId][this._dictionary.type].entries; if (entries.length) { - this.diffEditorText = this._toString(entries); + this.diffEditorText = this._toString([...entries]); this.showDiffEditor = true; return; } @@ -123,7 +123,7 @@ export class DictionaryManagerComponent implements OnChanges { ) .toPromise() .then(() => { - this.diffEditorText = this._toString(this._dictionary.entries); + this.diffEditorText = this._toString([...this._dictionary.entries]); this.showDiffEditor = true; }); } @@ -132,7 +132,7 @@ export class DictionaryManagerComponent implements OnChanges { if (!this._dossierTemplate || this._dossierTemplate.name === this.selectDossierTemplate.name) { return; } - return Object.values(this.appStateService.dictionaryData[this.dossierTemplate?.dossierTemplateId]).filter(dict => !!dict.label); + return Object.values(this.appStateService.dictionaryData[this.dossierTemplate?.dossierTemplateId]).filter(dict => !dict.virtual); } get dossierTemplateIsNotSelected() { diff --git a/apps/red-ui/src/app/modules/shared/services/dictionary.service.ts b/apps/red-ui/src/app/modules/shared/services/dictionary.service.ts index 878642f38..4151cb0b2 100644 --- a/apps/red-ui/src/app/modules/shared/services/dictionary.service.ts +++ b/apps/red-ui/src/app/modules/shared/services/dictionary.service.ts @@ -1,7 +1,7 @@ import { Injectable, Injector } from '@angular/core'; import { Observable, throwError } from 'rxjs'; import { EntitiesService, List, QueryParam, RequiredParam, Toaster, Validate } from '@iqser/common-ui'; -import { Colors, IDictionary, ITypeValue, UpdateTypeValue } from '@redaction/red-ui-http'; +import { Colors, IDictionary, UpdateDictionary } from '@redaction/red-ui-http'; import { tap } from 'rxjs/operators'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { Dictionary } from '@models/dictionary'; @@ -29,7 +29,7 @@ export class DictionaryService extends EntitiesService * Deletes entry types */ @Validate() - deleteTypes(@RequiredParam() body: List, @RequiredParam() dossierTemplateId: string, dossierId?: string) { + deleteDictionaries(@RequiredParam() body: List, @RequiredParam() dossierTemplateId: string, dossierId?: string) { const queryParams = dossierId ? [{ key: 'dossierId', value: dossierId }] : undefined; const url = `${this._defaultModelPath}/type/${dossierTemplateId}/delete`; return this._post(body, url, queryParams); @@ -39,9 +39,9 @@ export class DictionaryService extends EntitiesService * Retrieve all entry types */ @Validate() - getAllTypes(@RequiredParam() dossierTemplateId: string, dossierId?: string) { + getAllDictionaries(@RequiredParam() dossierTemplateId: string, dossierId?: string) { const queryParams = dossierId ? [{ key: 'dossierId', value: dossierId }] : undefined; - return this._getOne<{ types: ITypeValue[] }>(['type', dossierTemplateId], this._defaultModelPath, queryParams); + return this._getOne<{ types: IDictionary[] }>(['type', dossierTemplateId], this._defaultModelPath, queryParams); } /** @@ -56,8 +56,8 @@ export class DictionaryService extends EntitiesService * Updates colors, hint and caseInsensitive of an entry type. */ @Validate() - updateType( - @RequiredParam() body: UpdateTypeValue, + updateDictionary( + @RequiredParam() body: UpdateDictionary, @RequiredParam() dossierTemplateId: string, @RequiredParam() type: string, dossierId?: string, @@ -79,7 +79,7 @@ export class DictionaryService extends EntitiesService * Creates entry type with colors, hint and caseInsensitive */ @Validate() - addType(@RequiredParam() body: ITypeValue, dossierId?: string) { + addDictionary(@RequiredParam() body: IDictionary, dossierId?: string) { const queryParams = dossierId ? [{ key: 'dossierId', value: dossierId }] : undefined; return this._post(body, `${this._defaultModelPath}/type`, queryParams); } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 2d7694ec3..37799078f 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -7,7 +7,6 @@ import { catchError, filter, first, map, tap } from 'rxjs/operators'; import { currentComponentRoute, FALLBACK_COLOR, hexToRgb } from '@utils/functions'; import { File } from '@models/file/file'; import { Dossier } from './model/dossier'; -import { TypeValue } from '@models/file/type-value'; import { DossierTemplate } from '@models/file/dossier-template'; import { DossiersService } from '@services/entity-services/dossiers.service'; import { UserPreferenceService } from '@services/user-preference.service'; @@ -16,6 +15,7 @@ import { DictionaryService } from '@shared/services/dictionary.service'; import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service'; import { FileAttributesService } from '@services/entity-services/file-attributes.service'; import { ReanalysisService } from '@services/reanalysis.service'; +import { Dictionary } from '@models/dictionary'; export interface AppState { activeFileId?: string; @@ -65,9 +65,9 @@ export class AppStateService { }); } - private _dictionaryData?: { [key: string]: { [key: string]: TypeValue } }; + private _dictionaryData?: { [key: string]: { [key: string]: Dictionary } }; - get dictionaryData(): { [key: string]: { [key: string]: TypeValue } } | undefined { + get dictionaryData(): { [key: string]: { [key: string]: Dictionary } } | undefined { return this._dictionaryData; } @@ -79,7 +79,7 @@ export class AppStateService { return this._appState.activeDictionaryType; } - get activeDictionary(): TypeValue | undefined { + get activeDictionary(): Dictionary | undefined { const activeDossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId; return activeDossierTemplateId && this.activeDictionaryType && this.dictionaryData && this.dictionaryData[activeDossierTemplateId] ? this.dictionaryData[activeDossierTemplateId][this.activeDictionaryType] @@ -114,7 +114,7 @@ export class AppStateService { return color ?? this._dictionaryData[dossierTemplateId]['default'].hexColor; } - getDictionaryTypeValue(key: string, dossierTemplateId = this._dossiersService.activeDossier.dossierTemplateId): TypeValue | undefined { + getDictionary(key: string, dossierTemplateId = this._dossiersService.activeDossier.dossierTemplateId): Dictionary | undefined { if (!dossierTemplateId) { dossierTemplateId = this.dossierTemplates.length > 0 ? this.dossierTemplates[0].dossierTemplateId : undefined; } @@ -289,10 +289,10 @@ export class AppStateService { private _getDictionaryDataForDossierTemplate$(dossierTemplateId: string): Observable<{ [key: string]: any }> { const dictionaryData: { [key: string]: any } = {}; - const typeObs = this._dictionaryService.getAllTypes(dossierTemplateId).pipe( + const typeObs = this._dictionaryService.getAllDictionaries(dossierTemplateId).pipe( tap(typesResponse => { for (const type of typesResponse.types) { - dictionaryData[type.type] = new TypeValue(type); + dictionaryData[type.type] = new Dictionary(type); } }), ); @@ -311,7 +311,7 @@ export class AppStateService { } } - dictionaryData['declined-suggestion'] = new TypeValue( + dictionaryData['declined-suggestion'] = new Dictionary( { hexColor: colors.notRedacted || FALLBACK_COLOR, type: 'declined-suggestion', @@ -319,7 +319,7 @@ export class AppStateService { true, ); - dictionaryData['manual'] = new TypeValue( + dictionaryData['manual'] = new Dictionary( { hexColor: colors.manualRedactionColor || FALLBACK_COLOR, type: 'manual', @@ -327,7 +327,7 @@ export class AppStateService { true, ); - dictionaryData['manual-redaction'] = new TypeValue( + dictionaryData['manual-redaction'] = new Dictionary( { hexColor: colors.manualRedactionColor || FALLBACK_COLOR, type: 'manual-redaction', @@ -335,7 +335,7 @@ export class AppStateService { true, ); // dictionary actions - dictionaryData['recommendation'] = new TypeValue( + dictionaryData['recommendation'] = new Dictionary( { hexColor: '#c5d3eb', type: 'recommendation', @@ -343,21 +343,21 @@ export class AppStateService { true, ); // dictionary actions - dictionaryData['add-dictionary'] = new TypeValue( + dictionaryData['add-dictionary'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'add-dictionary', }, true, ); - dictionaryData['remove-dictionary'] = new TypeValue( + dictionaryData['remove-dictionary'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'remove-dictionary', }, true, ); - dictionaryData['remove-only-here'] = new TypeValue( + dictionaryData['remove-only-here'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'remove-only-here', @@ -365,7 +365,7 @@ export class AppStateService { true, ); // generic suggestions - dictionaryData['suggestion'] = new TypeValue( + dictionaryData['suggestion'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, type: 'suggestion', @@ -373,7 +373,7 @@ export class AppStateService { true, ); - dictionaryData['suggestion-add'] = new TypeValue( + dictionaryData['suggestion-add'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, type: 'suggestion-add', @@ -381,21 +381,21 @@ export class AppStateService { true, ); // add suggestions - dictionaryData['suggestion-change-legal-basis'] = new TypeValue( + dictionaryData['suggestion-change-legal-basis'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, type: 'suggestion-change-legal-basis', }, true, ); - dictionaryData['suggestion-recategorize-image'] = new TypeValue( + dictionaryData['suggestion-recategorize-image'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, type: 'suggestion-recategorize-image', }, true, ); - dictionaryData['suggestion-add-dictionary'] = new TypeValue( + dictionaryData['suggestion-add-dictionary'] = new Dictionary( { hexColor: colors.dictionaryRequestColor || FALLBACK_COLOR, type: 'suggestion-add', @@ -403,7 +403,7 @@ export class AppStateService { true, ); - dictionaryData['suggestion-remove'] = new TypeValue( + dictionaryData['suggestion-remove'] = new Dictionary( { hexColor: colors.requestRemove || FALLBACK_COLOR, type: 'suggestion-add', @@ -411,7 +411,7 @@ export class AppStateService { true, ); - dictionaryData['suggestion-remove-dictionary'] = new TypeValue( + dictionaryData['suggestion-remove-dictionary'] = new Dictionary( { hexColor: colors.dictionaryRequestColor || FALLBACK_COLOR, type: 'suggestion-add', @@ -419,7 +419,7 @@ export class AppStateService { true, ); - dictionaryData['skipped'] = new TypeValue( + dictionaryData['skipped'] = new Dictionary( { hexColor: colors.notRedacted || FALLBACK_COLOR, type: 'skipped', @@ -427,7 +427,7 @@ export class AppStateService { true, ); - dictionaryData['default'] = new TypeValue( + dictionaryData['default'] = new Dictionary( { hexColor: colors.defaultColor || FALLBACK_COLOR, type: 'default', @@ -435,7 +435,7 @@ export class AppStateService { true, ); - dictionaryData['add'] = new TypeValue( + dictionaryData['add'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, type: 'add', @@ -443,7 +443,7 @@ export class AppStateService { true, ); - dictionaryData['analysis'] = new TypeValue( + dictionaryData['analysis'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'analysis', @@ -451,7 +451,7 @@ export class AppStateService { true, ); - dictionaryData['pending-analysis'] = new TypeValue( + dictionaryData['pending-analysis'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'analysis', @@ -459,7 +459,7 @@ export class AppStateService { true, ); - dictionaryData['change-legal-basis'] = new TypeValue( + dictionaryData['change-legal-basis'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, type: 'analysis', @@ -467,7 +467,7 @@ export class AppStateService { true, ); - dictionaryData['hint'] = new TypeValue( + dictionaryData['hint'] = new Dictionary( { hexColor: '#fa98f7', type: 'hint', @@ -476,7 +476,7 @@ export class AppStateService { true, ); - dictionaryData['redaction'] = new TypeValue( + dictionaryData['redaction'] = new Dictionary( { hexColor: colors.previewColor || FALLBACK_COLOR, type: 'redaction', @@ -484,7 +484,7 @@ export class AppStateService { true, ); - dictionaryData['updated'] = new TypeValue( + dictionaryData['updated'] = new Dictionary( { hexColor: colors.updatedColor || FALLBACK_COLOR, type: 'updated', diff --git a/libs/red-ui-http/src/lib/model/dictionary.ts b/libs/red-ui-http/src/lib/model/dictionary.ts index 24ccfd10c..2f00a869c 100644 --- a/libs/red-ui-http/src/lib/model/dictionary.ts +++ b/libs/red-ui-http/src/lib/model/dictionary.ts @@ -32,6 +32,10 @@ export interface IDictionary { * The DossierTemplate Id for this type */ readonly dossierTemplateId?: string; + /** + * The nonnull entry type. + */ + readonly type: string; /** * The list of dictionary entries of an entry type. */ @@ -47,7 +51,7 @@ export interface IDictionary { /** * Label of the type */ - readonly label: string; + readonly label?: string; /** * The rank of this dictionary, higher rank means higher importance. */ diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index cdcb149a3..8c96b9aeb 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -62,10 +62,9 @@ export * from './searchRequest'; export * from './searchResult'; export * from './sectionGrid'; export * from './sectionRectangle'; -export * from './typeValue'; export * from './updateMyProfileRequest'; export * from './updateProfileRequest'; -export * from './updateTypeValue'; +export * from './updateDictionary'; export * from './user'; export * from './viewedPage'; export * from './viewedPages'; diff --git a/libs/red-ui-http/src/lib/model/typeValue.ts b/libs/red-ui-http/src/lib/model/typeValue.ts deleted file mode 100644 index 1eccf2099..000000000 --- a/libs/red-ui-http/src/lib/model/typeValue.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * API Documentation for Redaction Gateway - * Description for redaction - * - * OpenAPI spec version: 1.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -/** - * Object containing entry type with an array of r-g-b colors. - */ -export interface ITypeValue { - /** - * If true the ui will add a action to add values to dictionary - */ - readonly addToDictionaryAction?: boolean; - /** - * True if the entries in this type should be matched case insensitively, default is false. - */ - readonly caseInsensitive?: boolean; - /** - * The description of the dictionary type - */ - readonly description?: string; - /** - * The DossierTemplate Id for this type - */ - readonly dossierTemplateId?: string; - /** - * The value of color must be a correct hex color - */ - readonly hexColor?: string; - /** - * True if the type just for hint, not for redaction, default is false. - */ - readonly hint?: boolean; - /** - * The rank of this dictionary, higher rank means higher importance. - */ - readonly rank?: number; - /** - * True if the type just for recommendations, not for redaction, default is false. - */ - readonly recommendation?: boolean; - /** - * The nonnull entry type. - */ - readonly type?: string; - /** - * The label of this type - */ - readonly label?: string; -} diff --git a/libs/red-ui-http/src/lib/model/updateTypeValue.ts b/libs/red-ui-http/src/lib/model/updateDictionary.ts similarity index 97% rename from libs/red-ui-http/src/lib/model/updateTypeValue.ts rename to libs/red-ui-http/src/lib/model/updateDictionary.ts index 4ff9cb059..0240ad3e3 100644 --- a/libs/red-ui-http/src/lib/model/updateTypeValue.ts +++ b/libs/red-ui-http/src/lib/model/updateDictionary.ts @@ -13,7 +13,7 @@ /** * Object containing information of type to be updated. */ -export interface UpdateTypeValue { +export interface UpdateDictionary { /** * If true the ui will add a action to add values to dictionary */