on dataset save remain at the same position

This commit is contained in:
apapachristou 2020-11-02 18:08:25 +02:00
parent 02d79165c4
commit 0e2d288478
3 changed files with 39 additions and 8 deletions

View File

@ -42,8 +42,8 @@ export class DatasetWizardService {
return this.http.delete<DatasetWizardModel>(this.actionUrl + 'delete/' + id, { headers: this.headers });
}
createDataset(datasetModel: DatasetWizardModel): Observable<String> {
return this.http.post<String>(this.actionUrl, datasetModel, { headers: this.headers });
createDataset(datasetModel: DatasetWizardModel): Observable<DatasetWizardModel> {
return this.http.post<DatasetWizardModel>(this.actionUrl, datasetModel, { headers: this.headers });
}
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {

View File

@ -54,7 +54,7 @@
<div (click)="changeStep(0)" *ngIf="datasetInfoValid()" class="main-info" [ngClass]="{'active': this.step === 0}">0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (<mat-icon class="done-icon">done</mat-icon>)</div>
<div class="row toc-pane-container" #boundary (click)="changeStep(1)">
<div #spacer></div>
<table-of-contents class="toc-pane-container" [boundary]="boundary" [spacer]="spacer" [isActive]="step !== 0" stickyThing (stepFound)="onStepFound($event)"></table-of-contents>
<table-of-contents class="toc-pane-container" [boundary]="boundary" [spacer]="spacer" [isActive]="step !== 0" [datasetSavedLinks]="datasetSavedLinks" stickyThing (stepFound)="onStepFound($event)" (linksInit)="onLinksInit($event)"></table-of-contents>
</div>
</div>
</div>
@ -79,9 +79,9 @@
<app-form-progress-indication class="col-12" *ngIf="formGroup" [formGroup]="formGroup" [isDatasetEditor]="true"></app-form-progress-indication>
</div>
</div>
<div class="col-auto form">
<div class="col-auto form" id="dataset-editor-form">
<app-dataset-editor-component [hidden]="this.step !== 0" [formGroup]="formGroup" [dmpId]="formGroup.get('dmp').value.id" [availableProfiles]="formGroup.get('dmp').value.profiles" (formChanged)="formChanged()"></app-dataset-editor-component>
<app-dataset-description [hidden]="this.step === 0" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules" [datasetProfileId]="formGroup.get('profile').value" [linkToScroll]="linkToScroll"></app-dataset-description>
<app-dataset-description [hidden]="this.step === 0" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value" [datasetProfileId]="formGroup.get('profile').value" [linkToScroll]="linkToScroll"></app-dataset-description>
</div>
</div>
</form>

View File

@ -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;
}
}