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');