From 180e02c829a8fb35056124d5afdbec3835a94b62 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 23 Feb 2023 15:51:46 +0200 Subject: [PATCH] Ticket 8389: Fix undo finalazation appears even finalized wasn't successful. Also fix issue where the buttons are remaining disabled when user press No in the dialog of finalization. On undo finalization do a save in order to be sync with the backend. --- .../dataset-wizard.component.html | 7 ++- .../dataset-wizard.component.ts | 49 ++++++++++++++----- 2 files changed, 41 insertions(+), 15 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 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; } }); }