From 0e2d28847895a5570b20de723524979966bd893d Mon Sep 17 00:00:00 2001 From: apapachristou Date: Mon, 2 Nov 2020 18:08:25 +0200 Subject: [PATCH] on dataset save remain at the same position --- .../dataset-wizard/dataset-wizard.service.ts | 4 +- .../dataset-wizard.component.html | 6 +-- .../dataset-wizard.component.ts | 37 +++++++++++++++++-- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts index 1703704b2..437a413ea 100644 --- a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts @@ -42,8 +42,8 @@ export class DatasetWizardService { return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); } - createDataset(datasetModel: DatasetWizardModel): Observable { - return this.http.post(this.actionUrl, datasetModel, { headers: this.headers }); + createDataset(datasetModel: DatasetWizardModel): Observable { + return this.http.post(this.actionUrl, datasetModel, { headers: this.headers }); } public downloadPDF(id: string): Observable> { 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 71db4b830..7a129c60f 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 @@ -54,7 +54,7 @@
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
- +
@@ -79,9 +79,9 @@ -
+
- +
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 5855875f3..38ab8e72d 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 @@ -42,6 +42,7 @@ import { AuthService } from '@app/core/services/auth/auth.service'; import { environment } from 'environments/environment'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { SaveType } from '@app/core/common/enum/save-type'; +import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; @Component({ selector: 'app-dataset-wizard-component', @@ -81,6 +82,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr maxStep: number; saveAnd = SaveType; + datasetSavedLinks: any = null; + + scrollTop: number; constructor( private datasetWizardService: DatasetWizardService, @@ -543,6 +547,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr submit(saveType?: SaveType) { + this.scrollTop = document.getElementById('dataset-editor-form').scrollTop; this.datasetWizardService.createDataset(this.formGroup.getRawValue()) .pipe(takeUntil(this._destroyed)) .subscribe( @@ -624,15 +629,37 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr }); } - onCallbackSuccess(id?: String, saveType?: SaveType): void { + onCallbackSuccess(data?: DatasetWizardModel, saveType?: SaveType): void { this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - if (id) { + if (data.id) { if (saveType === this.saveAnd.addNew) { this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'new', this.formGroup.get('dmp').value.id]); }) } else if (saveType === this.saveAnd.close) { this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]); }); } else { - this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }); + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); + this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; + + 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(() => { this.formGroup = null; }); + setTimeout(() => { + this.formGroup = this.datasetWizardModel.buildForm(); + }); + + setTimeout(() => { + document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; + }, 500); + + // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); } } else { this.router.navigate(['/datasets']); @@ -888,4 +915,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr datasetInfoValid(): boolean { return this.formGroup.get('label') && this.formGroup.get('label').valid && this.formGroup.get('profile') && this.formGroup.get('profile').valid; } + + onLinksInit(event) { + this.datasetSavedLinks = event; + } }