RED-4021: Hints can also be case (in)sensitive

This commit is contained in:
Adina Țeudan 2022-05-16 22:07:03 +03:00
parent 361dc6b022
commit 2b0b8b0786

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', 'caseSensitive', 'addToDictionaryAction'];
const REDACTION_FIELDS = ['defaultReason', 'addToDictionaryAction'];
@Component({
selector: 'redaction-add-edit-entity [entity] [dossierTemplateId]',
@ -38,10 +38,6 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
super();
}
get #caseSensitiveControl() {
return { value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged };
}
get #isSystemManaged(): boolean {
return !!this.entity?.systemManaged;
}
@ -91,12 +87,12 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
recommendationHexColor: [this.entity?.recommendationHexColor, [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) {
Object.assign(controlsConfig, {
defaultReason: [{ value: null, disabled: true }],
caseSensitive: [this.#caseSensitiveControl],
});
if (this.entity?.hasDictionary) {
@ -116,7 +112,6 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
REDACTION_FIELDS.forEach(field => form.removeControl(field));
} else {
form.addControl('defaultReason', new FormControl({ value: null, disabled: true }));
form.addControl('caseSensitive', new FormControl(this.#caseSensitiveControl));
if (form.get('hasDictionary').value) {
form.addControl('addToDictionaryAction', new FormControl(this.#addToDictionaryActionControl));
@ -167,7 +162,6 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
private _formToObject(): IDictionary {
// Fields that aren't set for hints, need additional check
const caseInsensitive = this.form.get('caseSensitive') ? !this.form.get('caseSensitive').value : null;
const addToDictionaryAction = !!this.form.get('addToDictionaryAction')?.value;
const hasDictionary = !!this.form.get('hasDictionary')?.value;
@ -180,7 +174,7 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
hint: this.form.get('hint').value,
rank: this.form.get('rank').value,
dossierTemplateId: this.dossierTemplateId,
caseInsensitive,
caseInsensitive: !this.form.get('caseSensitive').value,
addToDictionaryAction,
hasDictionary,
};