RED-4403: Enable add to dictionary for hint entities

This commit is contained in:
Adina Țeudan 2022-06-28 17:39:48 +03:00
parent eb2b3f4280
commit 5dd30633ea

View File

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