added finalize function for description template type

This commit is contained in:
Sofia Papacharalampous 2024-04-30 13:00:53 +03:00
parent 7ed9a59595
commit f2cf61938d
4 changed files with 40 additions and 4 deletions

View File

@ -17,7 +17,7 @@
</button> </button>
</div> </div>
<div class="col-auto" *ngIf="canFinalize"> <div class="col-auto" *ngIf="canFinalize">
<button mat-button class="action-btn" (click)="finalize(); formSubmit()"> <button mat-button class="action-btn" (click)="save(); finalize()">
<mat-icon>save</mat-icon> <mat-icon>save</mat-icon>
{{'DESCRIPTION-TEMPLATE-TYPE-EDITOR.ACTIONS.FINALIZE' | translate}} {{'DESCRIPTION-TEMPLATE-TYPE-EDITOR.ACTIONS.FINALIZE' | translate}}
</button> </button>

View File

@ -25,6 +25,8 @@ import { DescriptionTemplateTypeEditorResolver } from './description-template-ty
import { DescriptionTemplateTypeEditorService } from './description-template-type-editor.service'; import { DescriptionTemplateTypeEditorService } from './description-template-type-editor.service';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
import { LockService } from '@app/core/services/lock/lock.service'; import { LockService } from '@app/core/services/lock/lock.service';
import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component';
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
@Component({ @Component({
templateUrl: './description-template-type-editor.component.html', templateUrl: './description-template-type-editor.component.html',
@ -175,4 +177,33 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
this.editorModel.validationErrorModel.clear(); this.editorModel.validationErrorModel.clear();
this.formService.validateAllFormFields(this.formGroup); this.formService.validateAllFormFields(this.formGroup);
} }
finalize(): void {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) {
this.dialog.open(FormValidationErrorsDialogComponent, {
data: {
errorMessages: [this.language.instant('DESCRIPTION-TEMPLATE-TYPE-EDITOR.MESSAGES.MISSING-FIELDS')]
}
})
this.formService.touchAllFormFields(this.formGroup);
return;
}
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false,
data: {
message: this.language.instant('DESCRIPTION-TEMPLATE-TYPE-EDITOR.FINALIZE-DIALOG.TITLE'),
confirmButton: this.language.instant('DESCRIPTION-TEMPLATE-TYPE-EDITOR.FINALIZE-DIALOG.CONFIRM'),
cancelButton: this.language.instant('DESCRIPTION-TEMPLATE-TYPE-EDITOR.FINALIZE-DIALOG.NEGATIVE'),
isDeleteConfirmation: false
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.formGroup.get('status').setValue(DescriptionTemplateTypeStatus.Finalized);
this.persistEntity();
}});
}
} }

View File

@ -1249,6 +1249,14 @@
"FINALIZE": "Finalize", "FINALIZE": "Finalize",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"DELETE": "Delete" "DELETE": "Delete"
},
"MESSAGES": {
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the Template and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color)"
},
"FINALIZE-DIALOG": {
"TITLE": "Finalize this item?",
"CONFIRM": "Confirm",
"NEGATIVE": "Cancel"
} }
}, },
"REFERENCE-TYPE-EDITOR": { "REFERENCE-TYPE-EDITOR": {

View File

@ -110,9 +110,6 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
onCallbackSuccess(data?: any): void { onCallbackSuccess(data?: any): void {
console.log("Success:", data);
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.refreshOnNavigateToData(data ? data.id : null); this.refreshOnNavigateToData(data ? data.id : null);
} }