After dmp save remain at the same position
This commit is contained in:
parent
abfb6342b2
commit
b13dab598f
|
@ -82,7 +82,7 @@
|
||||||
<app-form-progress-indication class="col-12" *ngIf="formGroup" [formGroup]="formGroup" [isDmpEditor]="true"></app-form-progress-indication>
|
<app-form-progress-indication class="col-12" *ngIf="formGroup" [formGroup]="formGroup" [isDmpEditor]="true"></app-form-progress-indication>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto form">
|
<div class="col-auto form" id="editor-form">
|
||||||
<main-info [hidden]="this.step !== 0" [formGroup]="formGroup" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></main-info>
|
<main-info [hidden]="this.step !== 0" [formGroup]="formGroup" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></main-info>
|
||||||
<funding-info [hidden]="this.step !== 1" [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized || lockStatus" [isNew]="isNew" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></funding-info>
|
<funding-info [hidden]="this.step !== 1" [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized || lockStatus" [isNew]="isNew" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></funding-info>
|
||||||
<license-info [hidden]="this.step !== 2" [formGroup]="formGroup" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></license-info>
|
<license-info [hidden]="this.step !== 2" [formGroup]="formGroup" [isUserOwner]="isUserOwner" (onFormChanged)="formChanged()"></license-info>
|
||||||
|
|
|
@ -96,6 +96,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
stepsBeforeDatasets: number = 4;
|
stepsBeforeDatasets: number = 4;
|
||||||
maxStep: number = 4;
|
maxStep: number = 4;
|
||||||
|
|
||||||
|
scrollTop: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
private datasetWizardService: DatasetWizardService,
|
private datasetWizardService: DatasetWizardService,
|
||||||
|
@ -169,7 +171,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
this.dmp.extraProperties = new ExtraPropertiesFormModel();
|
this.dmp.extraProperties = new ExtraPropertiesFormModel();
|
||||||
this.dmp.fromModel(data);
|
this.dmp.fromModel(data);
|
||||||
this.formGroup = this.dmp.buildForm();
|
this.formGroup = this.dmp.buildForm();
|
||||||
// console.log(this.formGroup);
|
|
||||||
|
|
||||||
this.datasets = this.formGroup.get('datasets') as FormArray;
|
this.datasets = this.formGroup.get('datasets') as FormArray;
|
||||||
|
|
||||||
|
@ -436,6 +437,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
|
onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
|
||||||
|
this.scrollTop = document.getElementById('editor-form').scrollTop;
|
||||||
|
|
||||||
this.dmpService.createDmp(this.formGroup.getRawValue())
|
this.dmpService.createDmp(this.formGroup.getRawValue())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -484,25 +487,35 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(dmp?: DmpModel, datasetId?: string): void {
|
onCallbackSuccess(dmp?: DmpModel, datasetId?: string): void {
|
||||||
|
|
||||||
|
// On save keep editor position
|
||||||
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||||
// console.log(dmp)
|
if (dmp) {
|
||||||
// if (dmp) {
|
let dmpEditorModel: DmpEditorModel;
|
||||||
// let dmpEditorModel: DmpEditorModel;
|
dmpEditorModel = new DmpEditorModel();
|
||||||
// dmpEditorModel = new DmpEditorModel();
|
dmpEditorModel.grant = new GrantTabModel();
|
||||||
// dmpEditorModel.grant = new GrantTabModel();
|
dmpEditorModel.project = new ProjectFormModel();
|
||||||
// dmpEditorModel.project = new ProjectFormModel();
|
dmpEditorModel.funder = new FunderFormModel();
|
||||||
// dmpEditorModel.funder = new FunderFormModel();
|
dmpEditorModel.extraProperties = new ExtraPropertiesFormModel();
|
||||||
// dmpEditorModel.extraProperties = new ExtraPropertiesFormModel();
|
dmpEditorModel.fromModel(dmp);
|
||||||
// dmpEditorModel.fromModel(dmp);
|
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
|
||||||
// this.formGroup = dmpEditorModel.buildForm();
|
this.associatedUsers = dmp.associatedUsers;
|
||||||
// } else {
|
this.people = dmp.users;
|
||||||
// this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); });
|
|
||||||
// }
|
setTimeout(() => { this.formGroup = null; });
|
||||||
if (dmp.id != null) {
|
setTimeout(() => { this.formGroup = dmpEditorModel.buildForm(); });
|
||||||
datasetId ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id], { queryParams: { dataset: datasetId } }); }) : this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id]); })
|
setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; });
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); });
|
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncomment to not keep editor position on save
|
||||||
|
// if (dmp.id != null) {
|
||||||
|
// datasetId ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id], { queryParams: { dataset: datasetId } }); }) : this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id]); })
|
||||||
|
// } else {
|
||||||
|
// this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); });
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(error: any) {
|
onCallbackError(error: any) {
|
||||||
|
|
Loading…
Reference in New Issue