From ae7988aa136e9048a370e5c8c3fa8f43a3152575 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 1 Apr 2022 18:13:50 +0300 Subject: [PATCH] Make DMP Editor more safe when saving and make save pop messages more consistent --- .../dataset-wizard/dataset-wizard.component.scss | 4 ---- .../dataset-wizard/dataset-wizard.component.ts | 1 + .../app/ui/dmp/editor/dmp-editor.component.html | 16 ++++++++-------- .../app/ui/dmp/editor/dmp-editor.component.scss | 9 +++++---- .../app/ui/dmp/editor/dmp-editor.component.ts | 11 +++++++++-- .../app/ui/dmp/wizard/dmp-wizard.component.html | 2 +- .../app/ui/dmp/wizard/dmp-wizard.component.ts | 3 +++ 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss index 6d418e82a..e6509e5df 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss @@ -179,7 +179,6 @@ display: flex; justify-content: center; align-items: center; - cursor: pointer; } .save-btn { @@ -194,7 +193,6 @@ align-items: center; font-weight: 700; color: #129d99; - cursor: pointer; } .dataset-discard-btn { @@ -208,7 +206,6 @@ display: flex; justify-content: center; align-items: center; - cursor: pointer; } .dataset-save-btn { @@ -221,7 +218,6 @@ display: flex; justify-content: center; align-items: center; - cursor: pointer; } .dataset-to-dmp { diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 81fce30d1..f7377c335 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -943,6 +943,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme } this.uiNotificationService.snackBarNotification(feedbackMessage, SnackBarNotificationLevel.Warning); this.setErrorModel(error.error); + this.saving = false; } public setErrorModel(validationErrorModel: ValidationErrorModel) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index 145242942..98aef9b79 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -11,14 +11,14 @@
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
- -
-
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
-
+
-
@@ -73,10 +73,10 @@
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
+
+ {{'DMP-EDITOR.ACTIONS.SAVE' | translate}} & {{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} +
diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss index 1c6e9f9c0..63259747e 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss @@ -155,7 +155,6 @@ a:hover { display: flex; justify-content: center; align-items: center; - cursor: pointer; } .save-btn { @@ -169,7 +168,6 @@ a:hover { align-items: center; font-weight: 700; color: #129d99; - cursor: pointer; } .dataset-discard-btn { @@ -346,11 +344,14 @@ mat-icon.size-16 { } .add-dataset-btn { - color: #212121; background: #f7dd72 0% 0% no-repeat padding-box; box-shadow: 0px 3px 6px #1e202029; font-weight: 500; - cursor: pointer; + white-space: normal; + word-wrap: break-word; + line-height: normal; + text-align: left; + font-size: 13.8px; } .add-dataset-action { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 122dcb1a2..e14bf2cfd 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -61,6 +61,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements editMode = true; // editMode = false; + saving = false; breadCrumbs: Observable; isNew = true; @@ -416,6 +417,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements // } formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void { + this.saving = true; this.formService.touchAllFormFields(this.formGroup); // if (this.isNewDataset) { // if (!this.isDatasetFormValid) { @@ -440,6 +442,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements const errmess = this._buildDMPDescriptionErrorMessages(); this.showValidationErrorsDialog(undefined, errmess); this.hintErrors = true; + this.saving = false; return; } this.onSubmit(addNew, showAddDatasetDialog); @@ -554,7 +557,8 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements setTimeout(() => { this.formGroup = null; }); setTimeout(() => { this.formGroup = dmpEditorModel.buildForm(); }); setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; }); - + this.saving = false; + this.isNew = false; } else { this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); }); } @@ -570,12 +574,14 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements onCallbackError(error: any) { this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); this.setErrorModel(error.error); + this.saving = false; //this.validateAllFormFields(this.formGroup); } onCallbackSuccessAddNew(dmp?: DmpModel) { // this.editDataset(dmp.id, true, this.isNew && !this.formGroup.get('datasets').value.length); this.editDataset(dmp.id, true, false); + this.saving = false; } public setErrorModel(validationErrorModel: ValidationErrorModel) { @@ -883,12 +889,13 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements addDataset() { - + this.saving = true; if(!this._isDMPDescriptionValid()){ const errmess = this._buildDMPDescriptionErrorMessages(); this.showValidationErrorsDialog(undefined, errmess); this.hintErrors = true; + this.saving = false; return; } diff --git a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.html b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.html index 8f1ad460c..2c18e8af3 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.html +++ b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.html @@ -14,7 +14,7 @@ diff --git a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.ts b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.ts index 83e8444a8..b25b10731 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.ts @@ -31,6 +31,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC dmp: DmpWizardEditorModel; formGroup: FormGroup; isClone: boolean; + saving = false; constructor( private dmpService: DmpService, @@ -76,6 +77,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC submit() { + this.saving = true; if (this.isClone) { this.dmpService.clone(this.formGroup.getRawValue(), this.itemId) .pipe(takeUntil(this._destroyed)) @@ -100,6 +102,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC onCallbackError(error: any) { this.setErrorModel(error.error); + this.saving = false; //this.validateAllFormFields(this.formGroup); }