From 6ca77c2df231c191190d9ec43a890932db1af72b Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 15 Mar 2023 15:55:57 +0200 Subject: [PATCH] Ticket 8391: DMP Editor: Add dialog before Discard. Dataset Editor: On Discard reset the form instead of go back in dmp editor. --- .../dataset-wizard.component.ts | 47 +++++++++++------ .../ui/dmp/editor/dmp-editor.component.html | 2 +- .../app/ui/dmp/editor/dmp-editor.component.ts | 40 +++++++++++++- .../dataset-description.component.ts | 52 ++++++++++--------- dmp-frontend/src/assets/i18n/de.json | 6 +-- dmp-frontend/src/assets/i18n/en.json | 8 +-- dmp-frontend/src/assets/i18n/gr.json | 6 +-- dmp-frontend/src/assets/i18n/sk.json | 6 +-- dmp-frontend/src/assets/i18n/sr.json | 6 +-- dmp-frontend/src/assets/i18n/tr.json | 6 +-- 10 files changed, 116 insertions(+), 63 deletions(-) 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 618db108c..522c37945 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 @@ -93,6 +93,8 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme availableProfiles: DatasetProfileModel[] = []; itemId: string; + dmpId: string; + newDmpId: string; publicId: string; profileUpdateId: string; downloadDocumentId: string; @@ -166,14 +168,24 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme const params = this.route.snapshot.params; const queryParams = this.route.snapshot.queryParams; this.itemId = params['id']; - const dmpId = params['dmpId']; - const newDmpId = queryParams['newDmpId']; + this.dmpId = params['dmpId']; + this.newDmpId = queryParams['newDmpId']; this.publicId = params['publicId']; this.profileUpdateId = params['updateId']; this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId - if (this.itemId != null && newDmpId == null) { + this.init(); + // this.route.params + // .pipe(takeUntil(this._destroyed)) + // .subscribe((params: Params) => { + // const itemId = params['id']; + // if (itemId != null) { setTimeout(() => this.stepper.selectedIndex = 2); } + // }); + } + + init() { + if (this.itemId != null && this.newDmpId == null) { this.isNew = false; this.datasetWizardService.getSingle(this.itemId) .pipe(takeUntil(this._destroyed)) @@ -239,9 +251,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.router.navigate(['/datasets/']); return observableOf(null); }); - } else if (dmpId != null) { + } else if (this.dmpId != null) { this.isNew = true; - this.dmpService.getSingleNoDatasets(dmpId).pipe(map(data => data as DmpModel)) + this.dmpService.getSingleNoDatasets(this.dmpId).pipe(map(data => data as DmpModel)) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.datasetWizardModel = new DatasetWizardEditorModel(); @@ -294,7 +306,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme }]); }); }); - } else if (newDmpId != null) { + } else if (this.newDmpId != null) { this.isNew = false; this.isCopy = true; this.datasetWizardService.getSingle(this.itemId) @@ -306,7 +318,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.datasetWizardModel.status = 0; this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup.get('id').setValue(null); - this.dmpService.getSingleNoDatasets(newDmpId).pipe(map(data => data as DmpModel)) + this.dmpService.getSingleNoDatasets(this.newDmpId).pipe(map(data => data as DmpModel)) .pipe(takeUntil(this._destroyed)) .subscribe(data => { setTimeout(() => { @@ -442,13 +454,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme url: '/datasets/new/' }]); } - - // this.route.params - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // const itemId = params['id']; - // if (itemId != null) { setTimeout(() => this.stepper.selectedIndex = 2); } - // }); } // private _listenersSubscription:Subscription = new Subscription(); @@ -953,9 +958,10 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; document.getElementById('stepper-options').scrollTop = this.tocScrollTop; }, 500); - this.saving = false; - this.isNew = false; + if(this.isNew) { + this.reloadDateset(this.datasetWizardModel.id); + } // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); } } else { @@ -1326,7 +1332,10 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.backToDmp(this.formGroup.get('dmp').value.id) + // this.backToDmp(this.formGroup.get('dmp').value.id) + setTimeout(x => { + this.init(); + }); } }); @@ -1338,6 +1347,10 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme this.router.navigate(['/datasets', 'new', dmpId]); } + reloadDateset(datasetId: string) { + this.router.navigate(['/datasets', 'edit', datasetId]); + } + backToDmp(id: string) { this.router.navigate(['/plans', 'edit', id]); } 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 ae70a647e..37a0be5d1 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 @@ -43,7 +43,7 @@ [vertical]="true" class="ml-2 mr-2">
-