+
{{ 'add-edit-entity.form.has-dictionary' | translate }}
diff --git a/apps/red-ui/src/app/modules/admin/shared/components/add-edit-entity/add-edit-entity.component.scss b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss
similarity index 100%
rename from apps/red-ui/src/app/modules/admin/shared/components/add-edit-entity/add-edit-entity.component.scss
rename to apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss
diff --git a/apps/red-ui/src/app/modules/admin/shared/components/add-edit-entity/add-edit-entity.component.ts b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts
similarity index 70%
rename from apps/red-ui/src/app/modules/admin/shared/components/add-edit-entity/add-edit-entity.component.ts
rename to apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts
index 2b5752c55..769080ed8 100644
--- a/apps/red-ui/src/app/modules/admin/shared/components/add-edit-entity/add-edit-entity.component.ts
+++ b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts
@@ -13,7 +13,7 @@ import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui';
const REDACTION_FIELDS = ['defaultReason'];
@Component({
- selector: 'redaction-add-edit-entity [entity] [dossierTemplateId]',
+ selector: 'redaction-add-edit-entity [entity] [dossierTemplateId] [readOnly]',
templateUrl: './add-edit-entity.component.html',
styleUrls: ['./add-edit-entity.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -21,6 +21,8 @@ const REDACTION_FIELDS = ['defaultReason'];
export class AddEditEntityComponent extends BaseFormComponent implements OnInit {
@Input() dossierTemplateId: string;
@Input() entity: Dictionary;
+ @Input() readOnly: boolean;
+ @Input() dossierId?: string;
technicalName$: Observable;
@@ -44,16 +46,20 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
super();
}
+ get #isDossierRedaction(): boolean {
+ return this.entity?.type === 'dossier_redaction';
+ }
+
get #isSystemManaged(): boolean {
return !!this.entity?.systemManaged;
}
get #addToDictionaryActionControl() {
- return { value: !!this.entity?.addToDictionaryAction, disabled: this.#isSystemManaged };
+ return { value: !!this.entity?.addToDictionaryAction, disabled: this.#isSystemManaged && !this.#isDossierRedaction };
}
get #isHint(): boolean {
- return this.form.get('hint').value;
+ return !!this.form.get('hint')?.value;
}
revert(): void {
@@ -71,7 +77,10 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
try {
if (this.entity) {
// edit mode
- await firstValueFrom(this._dictionaryService.updateDictionary(dictionary, this.dossierTemplateId, dictionary.type));
+ console.log({ dossierId: this.dossierId });
+ await firstValueFrom(
+ this._dictionaryService.updateDictionary(dictionary, this.dossierTemplateId, dictionary.type, this.dossierId),
+ );
this._toaster.success(_('add-edit-entity.success.edit'));
} else {
// create mode
@@ -114,20 +123,26 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
}
private _initializeForm(): void {
- const controlsConfig = {
- type: [this.entity?.type],
+ let controlsConfig: Record = {
label: [this.entity?.label, [Validators.required, Validators.minLength(3)]],
- description: [this.entity?.description],
- rank: [{ value: this.entity?.rank, disabled: this.#isSystemManaged }, Validators.required],
hexColor: [this.entity?.hexColor, [Validators.required, Validators.minLength(7)]],
recommendationHexColor: [this.entity?.recommendationHexColor, [Validators.required, Validators.minLength(7)]],
skippedHexColor: [this.entity?.skippedHexColor, [Validators.required, Validators.minLength(7)]],
- hint: [{ value: !!this.entity?.hint, disabled: this.#isSystemManaged }],
- hasDictionary: [{ value: !!this.entity?.hasDictionary, disabled: this.#isSystemManaged }],
- caseSensitive: [{ value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged }],
};
- if (!this.entity?.hint) {
+ if (!this.#isDossierRedaction) {
+ controlsConfig = {
+ ...controlsConfig,
+ type: [this.entity?.type],
+ description: [this.entity?.description],
+ rank: [{ value: this.entity?.rank, disabled: this.#isSystemManaged }, Validators.required],
+ hint: [{ value: !!this.entity?.hint, disabled: this.#isSystemManaged }],
+ hasDictionary: [{ value: !!this.entity?.hasDictionary, disabled: this.#isSystemManaged }],
+ caseSensitive: [{ value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged }],
+ };
+ }
+
+ if (!this.entity?.hint && !this.#isDossierRedaction) {
Object.assign(controlsConfig, {
defaultReason: [{ value: null, disabled: true }],
});
@@ -144,29 +159,31 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
this.#initializeColors(form);
this.technicalName$ = form.get('label').valueChanges.pipe(map((value: string) => this._toTechnicalName(value)));
- form.get('hint').valueChanges.subscribe(isHint => {
- if (isHint) {
- REDACTION_FIELDS.forEach(field => form.removeControl(field));
- } else {
- form.addControl('defaultReason', new UntypedFormControl({ value: null, disabled: true }));
- }
- });
-
- form.get('hasDictionary').valueChanges.subscribe(hasDictionary => {
- if (hasDictionary) {
- form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl));
- } else {
- form.removeControl('addToDictionaryAction');
- }
- });
-
- if (!this.entity) {
- form.get('label').valueChanges.subscribe((label: string) => {
- form.get('type').setValue(this._toTechnicalName(label));
+ if (!this.#isDossierRedaction) {
+ form.get('hint').valueChanges.subscribe(isHint => {
+ if (isHint) {
+ REDACTION_FIELDS.forEach(field => form.removeControl(field));
+ } else {
+ form.addControl('defaultReason', new UntypedFormControl({ value: null, disabled: true }));
+ }
});
+
+ form.get('hasDictionary').valueChanges.subscribe(hasDictionary => {
+ if (hasDictionary) {
+ form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl));
+ } else {
+ form.removeControl('addToDictionaryAction');
+ }
+ });
+
+ if (!this.entity) {
+ form.get('label').valueChanges.subscribe((label: string) => {
+ form.get('type').setValue(this._toTechnicalName(label));
+ });
+ }
}
- if (!this._permissionsService.canEditEntities()) {
+ if (this.readOnly) {
form.disable();
}
@@ -198,19 +215,28 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
const addToDictionaryAction = !!this.form.get('addToDictionaryAction')?.value;
const hasDictionary = !!this.form.get('hasDictionary')?.value;
- return {
- type: this.form.get('type').value,
+ let entity = {
+ ...this.entity,
label: this.form.get('label').value,
- description: this.form.get('description').value,
hexColor: this.form.get('hexColor').value,
recommendationHexColor: this.form.get('recommendationHexColor').value,
skippedHexColor: this.form.get('skippedHexColor').value,
- hint: this.#isHint,
- rank: this.form.get('rank').value,
dossierTemplateId: this.dossierTemplateId,
- caseInsensitive: !this.form.get('caseSensitive').value,
addToDictionaryAction,
- hasDictionary,
};
+
+ if (this.entity.type !== 'dossier_redaction') {
+ entity = {
+ ...entity,
+ type: this.form.get('type').value,
+ description: this.form.get('description').value,
+ hint: this.#isHint,
+ rank: this.form.get('rank').value,
+ caseInsensitive: !this.form.get('caseSensitive').value,
+ hasDictionary,
+ };
+ }
+
+ return entity;
}
}
diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts
index 2107a41bc..beba57d71 100644
--- a/apps/red-ui/src/app/modules/shared/shared.module.ts
+++ b/apps/red-ui/src/app/modules/shared/shared.module.ts
@@ -36,6 +36,8 @@ import { RouterModule } from '@angular/router';
import { AddDossierDialogComponent } from '@shared/dialogs/add-dossier-dialog/add-dossier-dialog.component';
import { SharedDialogService } from '@shared/services/dialog.service';
import { DossierWatermarkSelectorComponent } from '@components/dossier-watermark-selector/dossier-watermark-selector.component';
+import { AddEditEntityComponent } from '@shared/components/add-edit-entity/add-edit-entity.component';
+import { ColorPickerModule } from 'ngx-color-picker';
const buttons = [FileDownloadBtnComponent, UserButtonComponent];
@@ -59,6 +61,8 @@ const components = [
DossiersTypeSwitchComponent,
AddDossierDialogComponent,
DossierWatermarkSelectorComponent,
+ AddEditEntityComponent,
+
...buttons,
];
@@ -66,7 +70,7 @@ const utils = [DatePipe, NamePipe, NavigateLastDossiersScreenDirective, LongPres
const services = [SharedDialogService];
-const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, CommonUiModule];
+const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, CommonUiModule, ColorPickerModule];
@NgModule({
declarations: [...components, ...utils, EditorComponent],
diff --git a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts
index 9421115f1..e32c06b02 100644
--- a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts
+++ b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts
@@ -1,6 +1,6 @@
import { Injectable, Injector } from '@angular/core';
import { firstValueFrom, forkJoin, Observable, of, throwError } from 'rxjs';
-import { EntitiesService, List, log, QueryParam, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
+import { EntitiesService, List, QueryParam, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
import { Dictionary, DictionaryEntryType, DictionaryEntryTypes, IColors, IDictionary, IUpdateDictionary } from '@red/domain';
import { catchError, map, switchMap, tap } from 'rxjs/operators';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@@ -170,11 +170,10 @@ export class DictionaryService extends EntitiesService
},
),
);
- } else {
- this._toaster.error(_('dictionary-overview.error.entries-too-short'));
-
- return throwError('Entries too short');
}
+ this._toaster.error(_('dictionary-overview.error.entries-too-short'));
+
+ return throwError('Entries too short');
}
async getDictionariesOptions(dossierTemplateId: string, dossierId: string): Promise {
diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts
index fceea66d7..c5285512f 100644
--- a/apps/red-ui/src/app/services/permissions.service.ts
+++ b/apps/red-ui/src/app/services/permissions.service.ts
@@ -221,11 +221,7 @@ export class PermissionsService {
return dossier.isActive && this.isDossierMember(dossier);
}
- canEditDossierDictionaryDisplayName(dossier: Dossier): boolean {
- return dossier.isActive && this.isOwner(dossier);
- }
-
- canEditDossierDictionaryAddAction(dossier: Dossier): boolean {
+ canEditDossierDictionaryProperties(dossier: Dossier): boolean {
return dossier.isActive && this.isOwner(dossier);
}
diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json
index 5382fc037..b4bdd2972 100644
--- a/apps/red-ui/src/assets/i18n/de.json
+++ b/apps/red-ui/src/assets/i18n/de.json
@@ -618,6 +618,13 @@
},
"dev-mode": "DEV",
"dictionary": "Wörterbuch",
+ "dictionary-details": {
+ "actions": {
+ "cancel": "",
+ "save": ""
+ },
+ "title": ""
+ },
"dictionary-overview": {
"compare": {
"compare": "Vergleichen",
@@ -1061,16 +1068,13 @@
"change-successful": "Dossier wurde aktualisiert.",
"delete-successful": "Dossier wurde gelöscht.",
"dictionary": {
- "add-to-dictionary-action": "",
"display-name": {
- "cancel": "Abbrechen",
- "edit": "Anzeigenamen bearbeiten",
"error": "Anzeigename des Wörterbuchs konnte nicht aktualisiert werden.",
- "placeholder": "Anzeigenamen eingeben",
- "save": "Anzeigenamen speichern",
"success": "Anzeigename des Wörterbuchs erfolgreich aktualisiert."
},
- "entries": "{length} {length, plural, one{entry} other{entries}}"
+ "edit": "",
+ "entries": "{length} {length, plural, one{entry} other{entries}}",
+ "info": ""
},
"general-info": {
"form": {
diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json
index 720241ed3..a94eb7d76 100644
--- a/apps/red-ui/src/assets/i18n/en.json
+++ b/apps/red-ui/src/assets/i18n/en.json
@@ -618,6 +618,13 @@
},
"dev-mode": "DEV",
"dictionary": "Dictionary",
+ "dictionary-details": {
+ "actions": {
+ "cancel": "Cancel",
+ "save": "Save"
+ },
+ "title": "Edit Dossier Dictionary"
+ },
"dictionary-overview": {
"compare": {
"compare": "Compare",
@@ -1061,16 +1068,13 @@
"change-successful": "Dossier {dossierName} was updated.",
"delete-successful": "Dossier {dossierName} was deleted.",
"dictionary": {
- "add-to-dictionary-action": "Enable 'Add to dictionary'",
"display-name": {
- "cancel": "Cancel",
- "edit": "Edit Display Name",
"error": "Failed to update dictionary display name.",
- "placeholder": "Enter Display Name",
- "save": "Save Display Name",
"success": "Successfully updated dictionary display name."
},
- "entries": "{length} {length, plural, one{entry} other{entries}}"
+ "edit": "Edit",
+ "entries": "{length} {length, plural, one{entry} other{entries}}",
+ "info": "Info"
},
"general-info": {
"form": {
diff --git a/libs/common-ui b/libs/common-ui
index 17fc935e0..738c38cf5 160000
--- a/libs/common-ui
+++ b/libs/common-ui
@@ -1 +1 @@
-Subproject commit 17fc935e0815f0d151a2674e7b4c77886319da71
+Subproject commit 738c38cf5f13de9542facd84d8c70f9929b980e6