From 5dd30633eaa9a98dd2364f61ff247162d0294a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 28 Jun 2022 17:39:48 +0300 Subject: [PATCH] RED-4403: Enable add to dictionary for hint entities --- .../add-edit-entity.component.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) 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/admin/shared/components/add-edit-entity/add-edit-entity.component.ts index 88e8bdd58..3addc970e 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/admin/shared/components/add-edit-entity/add-edit-entity.component.ts @@ -10,7 +10,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { DictionaryService } from '@services/entity-services/dictionary.service'; import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui'; -const REDACTION_FIELDS = ['defaultReason', 'addToDictionaryAction']; +const REDACTION_FIELDS = ['defaultReason']; @Component({ selector: 'redaction-add-edit-entity [entity] [dossierTemplateId]', @@ -94,13 +94,14 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit Object.assign(controlsConfig, { defaultReason: [{ value: null, disabled: true }], }); - - if (this.entity?.hasDictionary) { - Object.assign(controlsConfig, { - addToDictionaryAction: [this.#addToDictionaryActionControl], - }); - } } + + if (this.entity?.hasDictionary) { + Object.assign(controlsConfig, { + addToDictionaryAction: [this.#addToDictionaryActionControl], + }); + } + const form = this._formBuilder.group(controlsConfig); this.hasHexColor$ = this._colorEmpty$(form, 'hexColor'); @@ -112,15 +113,11 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit REDACTION_FIELDS.forEach(field => form.removeControl(field)); } else { form.addControl('defaultReason', new UntypedFormControl({ value: null, disabled: true })); - - if (form.get('hasDictionary').value) { - form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl)); - } } }); form.get('hasDictionary').valueChanges.subscribe(hasDictionary => { - if (hasDictionary && !form.get('hint').value) { + if (hasDictionary) { form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl)); } else { form.removeControl('addToDictionaryAction');