description discard button fix
This commit is contained in:
parent
be1b6df610
commit
56efe184c9
|
@ -46,7 +46,7 @@
|
|||
|
||||
<div *ngIf="isDirty() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
|
||||
<button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()">
|
||||
{{'DESCRIPTION-EDITOR.ACTIONS.DISCARD' | translate}}
|
||||
{{'DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
|
@ -63,9 +63,9 @@
|
|||
</span>
|
||||
</button>
|
||||
<mat-menu #menu="matMenu">
|
||||
<button [disabled]="saving" mat-menu-item (click)="save(saveAnd.close)" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
|
||||
<button [disabled]="saving" mat-menu-item (click)="save(saveAnd.addNew)" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-ADD-NEW' | translate }}</button>
|
||||
<button [disabled]="saving" mat-menu-item (click)="save()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
|
||||
<button [disabled]="saving" mat-menu-item (click)="saveAndClose()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
|
||||
<button [disabled]="saving" mat-menu-item (click)="saveAndAddNew()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-ADD-NEW' | translate }}</button>
|
||||
<button [disabled]="saving" mat-menu-item (click)="saveAndContinue()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
|
||||
</mat-menu>
|
||||
|
||||
<button [disabled]="saving" *ngIf="!isLocked && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button" (click)="finalize()">{{ 'DESCRIPTION-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
|
||||
|
|
|
@ -62,6 +62,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
|||
|
||||
viewOnly = false;
|
||||
lockStatus: Boolean;
|
||||
descriptionIsOnceSaved = false;
|
||||
@ViewChild('table0fContents') table0fContents: TableOfContentsComponent;
|
||||
step: number = 0;
|
||||
|
||||
|
@ -633,20 +634,85 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
|||
|
||||
this.descriptionService.persist(formData)
|
||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||
complete => {
|
||||
onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete);
|
||||
this.descriptionIsOnceSaved = true;
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
formSubmit(onSuccess?: (response) => void): void {
|
||||
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (this.formGroup.get('label').valid && this.formGroup.get('dmpId').valid && this.formGroup.get('dmpDescriptionTemplateId').valid
|
||||
&& this.formGroup.get('dmpDescriptionTemplateId').valid && this.formGroup.get('status').valid) {
|
||||
this.persistEntity();
|
||||
this.persistEntity(onSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
saveAndClose(){
|
||||
this.formSubmit((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.router.navigate(['/descriptions']);
|
||||
});
|
||||
}
|
||||
|
||||
saveAndAddNew(){
|
||||
this.formSubmit((data) => {
|
||||
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
//TODO
|
||||
});
|
||||
}
|
||||
|
||||
saveAndContinue(){
|
||||
this.formSubmit((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.refreshOnNavigateToData(data ? data.id : null);
|
||||
});
|
||||
}
|
||||
|
||||
discardChanges() {
|
||||
let messageText = "";
|
||||
let confirmButtonText = "";
|
||||
let cancelButtonText = "";
|
||||
let isDeleteConfirmation = false;
|
||||
|
||||
if (this.isNew && !this.descriptionIsOnceSaved) {
|
||||
|
||||
messageText = this.language.instant('DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE');
|
||||
confirmButtonText = this.language.instant('DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM');
|
||||
cancelButtonText = this.language.instant('DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY');
|
||||
isDeleteConfirmation = true;
|
||||
} else {
|
||||
|
||||
messageText = this.language.instant('DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE');
|
||||
confirmButtonText = this.language.instant('DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM');
|
||||
cancelButtonText = this.language.instant('DESCRIPTION-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.ngOnInit();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public delete() {
|
||||
const value = this.formGroup.value;
|
||||
if (value.id) {
|
||||
|
@ -2236,50 +2302,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
|||
// return this.formGroup.dirty && this.hasChanges; // do we need this.formGroup.dirty
|
||||
// }
|
||||
|
||||
// discardChanges() {
|
||||
// // this.isDiscarded = true;
|
||||
// // this.hasChanges = false;
|
||||
// // this.hintErrors = false;
|
||||
// let messageText = "";
|
||||
// let confirmButtonText = "";
|
||||
// let cancelButtonText = "";
|
||||
// let isDeleteConfirmation = false;
|
||||
|
||||
// if (this.isNew && !this.descriptionIsOnceSaved) {
|
||||
|
||||
// messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE');
|
||||
// confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM');
|
||||
// cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY');
|
||||
// isDeleteConfirmation = true;
|
||||
|
||||
// // Object.keys(this.formGroup['controls']).forEach((key: string) => {
|
||||
// // if (key !== 'dmp' && (key!== 'profile')) {
|
||||
// // if(key === 'descriptionProfileDefinition'){
|
||||
// // this.formGroup.get(key).patchValue(this.descriptionProfileDefinitionModel.buildForm().getRawValue);
|
||||
// // }else{
|
||||
// // this.formGroup.get(key).reset();
|
||||
// // }
|
||||
|
||||
// // }
|
||||
// // });
|
||||
// } else {
|
||||
|
||||
// messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE');
|
||||
// confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM');
|
||||
// cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY');
|
||||
// isDeleteConfirmation = false;
|
||||
|
||||
// // this.isDiscarded = true;
|
||||
// // this.hasChanges = false;
|
||||
// // this.hintErrors = false;
|
||||
// // // this._unregisterFormListeners();
|
||||
// // this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue)));
|
||||
// // // this.registerFormListeners();
|
||||
// // this.isDiscarded = false;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
// restoreFocus: false,
|
||||
|
|
|
@ -733,7 +733,15 @@
|
|||
"SAVE-AND-ADD-NEW": "Save & Add New",
|
||||
"SAVE-AND-CLOSE": "Save & Close",
|
||||
"FINALIZE": "Finalize",
|
||||
"DISCARD": "Discard",
|
||||
"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."
|
||||
},
|
||||
"REVERSE": "Undo Finalization",
|
||||
"UNDO-FINALIZATION-QUESTION": "Undo finalization?",
|
||||
"CONFIRM": "Yes",
|
||||
|
|
Loading…
Reference in New Issue