diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html
index 48318c906..7ad7c9dc0 100644
--- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html
+++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html
@@ -46,7 +46,7 @@
@@ -63,9 +63,9 @@
-
-
-
+
+
+
diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts
index faf308c90..1222bb869 100644
--- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts
+++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts
@@ -62,6 +62,7 @@ export class DescriptionEditorComponent extends BaseEditor 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 {
-// // 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,
diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json
index c122ef9fd..d2bff73c0 100644
--- a/dmp-frontend/src/assets/i18n/en.json
+++ b/dmp-frontend/src/assets/i18n/en.json
@@ -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",