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 2181b16dd..a33d78874 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 @@ -63,12 +63,15 @@ 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 33951bea3..618db108c 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 @@ -659,7 +659,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme // } - submit(saveType?: SaveType) { + submit(saveType?: SaveType, onSuccess: Function = null, onError: Function = null) { this.scrollTop = document.getElementById('dataset-editor-form').scrollTop; this.tocScrollTop = document.getElementById('stepper-options').scrollTop; this.datasetWizardService.createDataset(this.formGroup.getRawValue()) @@ -669,8 +669,16 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.hasChanges = false; this.datasetIsOnceSaved = true; this.onCallbackSuccess(data, saveType); + if(onSuccess) { + onSuccess(); + } }, - error => this.onCallbackError(error)); + error => { + if(onError) { + onError(); + } + this.onCallbackError(error) + }); } @@ -840,16 +848,27 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme .pipe( filter(x => x), takeUntil(this._destroyed) - ).subscribe(_ => { - this.viewOnly = false; - this.datasetWizardModel.status = DatasetStatus.Draft; - setTimeout(x => { - this.formGroup = null; - }); - setTimeout(x => { - this.formGroup = this.datasetWizardModel.buildForm(); - this.registerFormListeners(); - }); + ).subscribe(result => { + if (result) { + // if (!this.isFormValid()) { return; } + this.formGroup.get('status').setValue(DatasetStatus.Draft); + this.submit(SaveType.finalize, () => { + this.viewOnly = false; + this.datasetWizardModel.status = DatasetStatus.Draft; + setTimeout(x => { + this.formGroup = null; + }); + setTimeout(x => { + this.formGroup = this.datasetWizardModel.buildForm(); + this.registerFormListeners(); + }); + }, () => { + this.formGroup.get('status').setValue(DatasetStatus.Finalized); + this.viewOnly = true; + }); + } else { + this.saving = false; + } }); @@ -885,7 +904,11 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme if (result) { // if (!this.isFormValid()) { return; } this.formGroup.get('status').setValue(DatasetStatus.Finalized); - this.submit(SaveType.finalize); + this.submit(SaveType.finalize, null, () => { + this.formGroup.get('status').setValue(DatasetStatus.Draft); + }); + } else { + this.saving = false; } }); }