fixed description template type editor on finalized status

This commit is contained in:
Sofia Papacharalampous 2024-05-01 17:22:57 +03:00
parent 3af2642583
commit 0d0e23d240
3 changed files with 14 additions and 3 deletions

View File

@ -37,6 +37,7 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
isNew = true; isNew = true;
isDeleted = false; isDeleted = false;
isFinalized = false;
formGroup: UntypedFormGroup = null; formGroup: UntypedFormGroup = null;
showInactiveDetails = false; showInactiveDetails = false;
@ -46,11 +47,11 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
} }
protected get canSave(): boolean { protected get canSave(): boolean {
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditDescriptionTemplateType) && this.editorModel.belongsToCurrentTenant != false; return !this.isDeleted && !this.isFinalized && this.hasPermission(this.authService.permissionEnum.EditDescriptionTemplateType) && this.editorModel.belongsToCurrentTenant != false;
} }
protected get canFinalize(): boolean { protected get canFinalize(): boolean {
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditDescriptionTemplateType) && this.editorModel.belongsToCurrentTenant != false; return !this.isDeleted && !this.isFinalized && this.hasPermission(this.authService.permissionEnum.EditDescriptionTemplateType) && this.editorModel.belongsToCurrentTenant != false;
} }
@ -99,6 +100,7 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
try { try {
this.editorModel = data ? new DescriptionTemplateTypeEditorModel().fromModel(data) : new DescriptionTemplateTypeEditorModel(); this.editorModel = data ? new DescriptionTemplateTypeEditorModel().fromModel(data) : new DescriptionTemplateTypeEditorModel();
this.isDeleted = data ? data.isActive === IsActive.Inactive : false; this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.isFinalized = data ? data.status === DescriptionTemplateTypeStatus.Finalized : false;
this.buildForm(); this.buildForm();
} catch (error) { } catch (error) {
this.logger.error('Could not parse descriptionTemplateType item: ' + data + error); this.logger.error('Could not parse descriptionTemplateType item: ' + data + error);
@ -109,6 +111,10 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
buildForm() { buildForm() {
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditDescriptionTemplateType)); this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditDescriptionTemplateType));
this.descriptionTemplateTypeEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); this.descriptionTemplateTypeEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
if (this.isFinalized) {
this.formGroup.disable();
}
} }
refreshData(): void { refreshData(): void {

View File

@ -95,7 +95,7 @@
<mat-icon>more_horiz</mat-icon> <mat-icon>more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="['/description-template-type/' + row.id]"> <button *ngIf="!isFinalized(row)" mat-menu-item [routerLink]="['/description-template-type/' + row.id]">
<mat-icon>edit</mat-icon>{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.ACTIONS.EDIT' | translate}} <mat-icon>edit</mat-icon>{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.ACTIONS.EDIT' | translate}}
</button> </button>
<button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)"> <button *ngIf="row.belongsToCurrentTenant != false" mat-menu-item (click)="deleteType(row.id)">

View File

@ -130,6 +130,11 @@ export class DescriptionTemplateTypeListingComponent extends BaseListingComponen
// //
// Listing Component functions // Listing Component functions
// //
isFinalized(item: DescriptionTemplateType): boolean {
return item.status === DescriptionTemplateTypeStatus.Finalized
}
onColumnsChanged(event: ColumnsChangedEvent) { onColumnsChanged(event: ColumnsChangedEvent) {
super.onColumnsChanged(event); super.onColumnsChanged(event);
this.onColumnsChangedInternal(event.properties.map(x => x.toString())); this.onColumnsChangedInternal(event.properties.map(x => x.toString()));