dmp discard fix

This commit is contained in:
amentis 2024-04-17 17:13:36 +03:00
parent 1961973971
commit d6e447eb53
3 changed files with 52 additions and 3 deletions

View File

@ -11,8 +11,8 @@
</div>
<div class="ml-auto d-flex flex-row">
<div class="col-auto d-flex align-items-center">
<button [disabled]="saving" *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discard()">
{{'DMP-EDITOR.ACTIONS.DISCARD' | translate}}
<button [disabled]="saving" *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discardChanges()">
{{'DMP-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
</button>
<button [disabled]="saving" *ngIf="isNew" mat-raised-button type="button" (click)="formSubmit()" class="save-btn">
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}

View File

@ -271,6 +271,47 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
}
}
discardChanges() {
let messageText = "";
let confirmButtonText = "";
let cancelButtonText = "";
let isDeleteConfirmation = false;
if (this.isNew) {
messageText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE');
confirmButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM');
cancelButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY');
isDeleteConfirmation = true;
} else {
messageText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE');
confirmButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM');
cancelButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY');
isDeleteConfirmation = false;
}
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false,
data: {
message: messageText,
confirmButton: confirmButtonText,
cancelButton: cancelButtonText,
isDeleteConfirmation: true
},
maxWidth: '40em'
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
setTimeout(x => {
this.step = this.step > 0 ? this.step - 1 : 0;
this.ngOnInit();
});
}
});
}
public delete() {
const value = this.formGroup.value;
if (value.id) {

View File

@ -1412,7 +1412,15 @@
"DMP-BLUEPRINT-VERSION": "Version"
},
"ACTIONS": {
"DISCARD": {
"DISCARD": "Discard",
"DISCARD-NEW-MESSAGE": "All unsaved changes will be lost. Would you like to proceed?",
"DISCARD-NEW-CONFIRM": "Yes, revert changes.",
"DISCARD-NEW-DENY": "No.",
"DISCARD-EDITED-MESSAGE": "All unsaved changes will be lost. Would you like to proceed?",
"DISCARD-EDITED-CONFIRM": "Yes, revert changes.",
"DISCARD-EDITED-DENY": "No."
},
"SAVE": "Save",
"DELETE": "Delete",
"ADD-DESCRIPTION-IN-SECTION": "Add Description",