RED-3827: System managed entities disabled fields
This commit is contained in:
parent
0ccb68726e
commit
5aa2c4a355
@ -13,6 +13,7 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: 'info',
|
path: 'info',
|
||||||
component: InfoComponent,
|
component: InfoComponent,
|
||||||
|
canDeactivate: [PendingChangesGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'dictionary',
|
path: 'dictionary',
|
||||||
|
|||||||
@ -52,6 +52,10 @@ export class InfoComponent {
|
|||||||
this._addEditEntityComponent.revert();
|
this._addEditEntityComponent.revert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get changed(): boolean {
|
||||||
|
return this._addEditEntityComponent.changed;
|
||||||
|
}
|
||||||
|
|
||||||
@HostListener('window:keydown.Enter', ['$event'])
|
@HostListener('window:keydown.Enter', ['$event'])
|
||||||
async onEnter(event: KeyboardEvent): Promise<void> {
|
async onEnter(event: KeyboardEvent): Promise<void> {
|
||||||
event?.stopImmediatePropagation();
|
event?.stopImmediatePropagation();
|
||||||
|
|||||||
@ -42,23 +42,35 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
|||||||
this.form.patchValue(this.initialFormValue);
|
this.form.patchValue(this.initialFormValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get #caseSensitiveControl() {
|
||||||
|
return { value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged };
|
||||||
|
}
|
||||||
|
|
||||||
|
#addToDictionaryActionControl() {
|
||||||
|
return { value: this.entity?.addToDictionaryAction, disabled: this.#isSystemManaged };
|
||||||
|
}
|
||||||
|
|
||||||
|
get #isSystemManaged(): boolean {
|
||||||
|
return !!this.entity?.systemManaged;
|
||||||
|
}
|
||||||
|
|
||||||
private _initializeForm(): void {
|
private _initializeForm(): void {
|
||||||
const controlsConfig = {
|
const controlsConfig = {
|
||||||
type: [this.entity?.type],
|
type: [this.entity?.type],
|
||||||
label: [this.entity?.label, [Validators.required, Validators.minLength(3)]],
|
label: [this.entity?.label, [Validators.required, Validators.minLength(3)]],
|
||||||
description: [this.entity?.description],
|
description: [this.entity?.description],
|
||||||
rank: [this.entity?.rank, Validators.required],
|
rank: [{ value: this.entity?.rank, disabled: this.#isSystemManaged }, Validators.required],
|
||||||
hexColor: [this.entity?.hexColor, [Validators.required, Validators.minLength(7)]],
|
hexColor: [this.entity?.hexColor, [Validators.required, Validators.minLength(7)]],
|
||||||
recommendationHexColor: [this.entity?.recommendationHexColor, [Validators.required, Validators.minLength(7)]],
|
recommendationHexColor: [this.entity?.recommendationHexColor, [Validators.required, Validators.minLength(7)]],
|
||||||
hint: [!!this.entity?.hint],
|
hint: [{ value: !!this.entity?.hint, disabled: this.#isSystemManaged }],
|
||||||
hasDictionary: [!!this.entity?.hasDictionary],
|
hasDictionary: [{ value: !!this.entity?.hasDictionary, disabled: this.#isSystemManaged }],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.entity?.hint) {
|
if (!this.entity?.hint) {
|
||||||
Object.assign(controlsConfig, {
|
Object.assign(controlsConfig, {
|
||||||
defaultReason: [{ value: null, disabled: true }],
|
defaultReason: [{ value: null, disabled: true }],
|
||||||
caseSensitive: [this.entity ? !this.entity.caseInsensitive : false],
|
caseSensitive: [this.#caseSensitiveControl],
|
||||||
addToDictionaryAction: [this.entity?.addToDictionaryAction],
|
addToDictionaryAction: [this.#addToDictionaryActionControl],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const form = this._formBuilder.group(controlsConfig);
|
const form = this._formBuilder.group(controlsConfig);
|
||||||
@ -71,9 +83,9 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
|||||||
if (isHint) {
|
if (isHint) {
|
||||||
REDACTION_FIELDS.forEach(field => form.removeControl(field));
|
REDACTION_FIELDS.forEach(field => form.removeControl(field));
|
||||||
} else {
|
} else {
|
||||||
form.addControl('addToDictionaryAction', new FormControl(this.entity?.addToDictionaryAction));
|
|
||||||
form.addControl('caseSensitive', new FormControl(!this.entity?.caseInsensitive));
|
|
||||||
form.addControl('defaultReason', new FormControl({ value: null, disabled: true }));
|
form.addControl('defaultReason', new FormControl({ value: null, disabled: true }));
|
||||||
|
form.addControl('caseSensitive', new FormControl(this.#caseSensitiveControl));
|
||||||
|
form.addControl('addToDictionaryAction', new FormControl(this.#addToDictionaryActionControl));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user