From a9199ab8f0980936a06c865bc0cb96fe578db66c Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 1 Apr 2022 17:20:37 +0300 Subject: [PATCH] Make Dataset Editor more safe when saving and make save pop messages more consistent --- .../dataset-wizard.component.html | 24 +++---- .../dataset-wizard.component.scss | 8 +-- .../dataset-wizard.component.ts | 64 ++++++++++--------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index ec1cb77f6..3a12076f3 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -28,27 +28,27 @@
-
- - - - + + + - + - - + +
@@ -89,9 +89,9 @@ chevron_right
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
-
{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}
-
+
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 ca5cd4282..6d418e82a 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 @@ -427,11 +427,12 @@ } .add-dataset-btn { - color: #212121; background: #f7dd72 0% 0% no-repeat padding-box; box-shadow: 0px 3px 6px #1e202029; font-weight: 500; - cursor: pointer; + word-wrap: break-word; + white-space: normal; + line-height: normal; } .next { @@ -450,8 +451,7 @@ cursor: pointer; } - .previous-disabled, - .add-dataset-btn-disabled { + .previous-disabled { border: 1px solid #b5b5b5; color: #b5b5b5 !important; cursor: auto !important; 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 125e7a9c8..81fce30d1 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 @@ -1,4 +1,4 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {AbstractControl, FormArray, FormControl, FormGroup} from '@angular/forms'; import {MatDialog} from '@angular/material/dialog'; import {MatSnackBar} from '@angular/material/snack-bar'; @@ -72,6 +72,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme hasChanges = false; isDiscarded = false; formGroupRawValue: any; + saving = false; DatasetStatus = DatasetStatus; dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; @@ -759,7 +760,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme } save(saveType?: SaveType) { - + this.saving = true; Object.keys(this.formGroup.controls).forEach(controlName => { if (controlName == 'datasetProfileDefinition') { return; @@ -895,39 +896,40 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]); }); - } else { + } else if (saveType === SaveType.finalize) { this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); + } else { + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); + this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; + // setTimeout(() => { this.formGroup = null; }); + setTimeout(() => { + this.formGroup.get('id').patchValue(data.id); + this.formGroup.get('modified').patchValue(data.modified); + this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + this.hasChanges = false; + + // this.formGroup = this.datasetWizardModel.buildForm(); + // if (this.formGroup.get('datasetProfileDefinition')) { + // this.formGroup.removeControl('datasetProfileDefinition'); + // this.getDefinition(data.profile.id); + // this.maxStep = 1; + // } else { + // this.getDefinition(data.profile.id); + // this.maxStep = 1; + // } + }); + + setTimeout(() => { + document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; + document.getElementById('stepper-options').scrollTop = this.tocScrollTop; + }, 500); + + this.saving = false; + this.isNew = false; + // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); } - // } else { - // this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - // this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // // setTimeout(() => { this.formGroup = null; }); - // setTimeout(() => { - // this.formGroup.get('id').patchValue(data.id); - // this.formGroup.get('modified').patchValue(data.modified); - // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - // this.hasChanges = false; - - // // this.formGroup = this.datasetWizardModel.buildForm(); - // // if (this.formGroup.get('datasetProfileDefinition')) { - // // this.formGroup.removeControl('datasetProfileDefinition'); - // // this.getDefinition(data.profile.id); - // // this.maxStep = 1; - // // } else { - // // this.getDefinition(data.profile.id); - // // this.maxStep = 1; - // // } - // }); - - // setTimeout(() => { - // document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; - // document.getElementById('stepper-options').scrollTop = this.tocScrollTop; - // }, 500); - - // // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); - // } } else { this.router.navigate(['/datasets']); }