Dataset editor changes on save

This commit is contained in:
apapachristou 2020-09-17 18:48:13 +03:00
parent 9b403bb480
commit 5944dfc005
14 changed files with 91 additions and 51 deletions

View File

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

View File

@ -27,8 +27,9 @@
</button> </button>
</div> </div>
<div class="col-auto d-flex align-items-center"> <div class="col-auto d-flex align-items-center">
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" type="submit">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button> <button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save()" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" type="submit">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}</button> <button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.close)" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.addNew)">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}</button>
<button *ngIf="lockStatus" mat-raised-button disabled class="dataset-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button> <button *ngIf="lockStatus" mat-raised-button disabled class="dataset-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button>
</div> </div>
</div> </div>
@ -51,7 +52,7 @@
<div (click)="changeStep(0)" class="main-info" [ngClass]="{'active': this.step === 0}">0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (5)</div> <div (click)="changeStep(0)" class="main-info" [ngClass]="{'active': this.step === 0}">0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (5)</div>
<div class="row toc-pane-container" #boundary (click)="changeStep(1)"> <div class="row toc-pane-container" #boundary (click)="changeStep(1)">
<div #spacer></div> <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" stickyThing (stepFound)="onStepFound($event)"></table-of-contents>
</div> </div>
</div> </div>
</div> </div>
@ -60,14 +61,17 @@
<span class="material-icons">chevron_left</span> <span class="material-icons">chevron_left</span>
<div>{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}</div> <div>{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}</div>
</div> </div>
<div *ngIf="this.step < 1" mat-raised-button type="button" class="col-auto stepper-btn dataset-next ml-auto" (click)="nextStep()"> <div *ngIf="this.step < this.maxStep" mat-raised-button type="button" class="col-auto stepper-btn dataset-next ml-auto" (click)="nextStep()">
<span class="material-icons">chevron_right</span> <span class="material-icons">chevron_right</span>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div> <div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div> </div>
<div *ngIf="this.step === 1" mat-raised-button type="button" class="col-auto add-dataset-option ml-auto"> <div *ngIf="this.step === this.maxStep && isNew" mat-raised-button type="button" class="col-auto stepper-btn dataset-next next-disabled ml-auto">
<a class="add-dataset-btn stepper-btn" (click)="addDataset()" target="_blank"> <span class="material-icons">chevron_right</span>
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} <div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</a> </div>
<div *ngIf="this.step === 1 && !isNew" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset(formGroup.get('dmp').value.id)" target="_blank">
<mat-icon>add</mat-icon>
<div>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -356,6 +356,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
padding-left: 0.625rem; padding-left: 0.625rem;
padding-right: 0.625rem;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

View File

@ -42,6 +42,12 @@ import { AuthService } from '@app/core/services/auth/auth.service';
import { environment } from 'environments/environment'; import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
enum SaveType {
close = 0,
addNew = 1
}
@Component({ @Component({
selector: 'app-dataset-wizard-component', selector: 'app-dataset-wizard-component',
templateUrl: 'dataset-wizard.component.html', templateUrl: 'dataset-wizard.component.html',
@ -74,7 +80,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
step: number = 0; step: number = 0;
stepOffset: number = 1; stepOffset: number = 1;
maxStep: number = 1; maxStep: number;
saveAnd = SaveType;
constructor( constructor(
private datasetWizardService: DatasetWizardService, private datasetWizardService: DatasetWizardService,
@ -350,6 +358,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}]); }]);
} }
!this.isNew ? this.maxStep = 1 : this.maxStep = 0;
// this.route.params // this.route.params
// .pipe(takeUntil(this._destroyed)) // .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => { // .subscribe((params: Params) => {
@ -367,7 +376,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.formGroup.get('profile').valueChanges this.formGroup.get('profile').valueChanges
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(x => { .subscribe(x => {
this.datasetProfileValueChanged(x); this.datasetProfileValueChanged(x.id);
}); });
} }
@ -387,7 +396,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
datasetProfileValueChanged(profiledId: string) { datasetProfileValueChanged(profiledId: string) {
if (profiledId && profiledId.length > 0) { if (profiledId && profiledId.length > 0) {
this.formGroup.removeControl('datasetProfileDefinition'); this.formGroup.removeControl('datasetProfileDefinition');
this.getDefinition(); this.getDefinition(profiledId);
this.maxStep = 1;
} }
} }
@ -439,9 +449,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
else { return item['label']; } else { return item['label']; }
} }
getDefinition() { getDefinition(profileId: string) {
// if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; }
this.datasetWizardService.getDefinition(this.formGroup.get('profile').value) this.datasetWizardService.getDefinition(profileId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(item => { .subscribe(item => {
this.datasetWizardModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); this.datasetWizardModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
@ -487,23 +497,25 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
// ); // );
// } // }
submit() {
submit(saveType?: SaveType) {
this.datasetWizardService.createDataset(this.formGroup.getRawValue()) this.datasetWizardService.createDataset(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
data => { data => {
this.onCallbackSuccess(this.datasetWizardModel.id); this.onCallbackSuccess(data, saveType);
}, },
error => this.onCallbackError(error)); error => this.onCallbackError(error));
} }
save() { save(saveType?: SaveType) {
this.formService.touchAllFormFields(this.formGroup); this.formService.touchAllFormFields(this.formGroup);
if (!this.isSemiFormValid(this.formGroup)) { if (!this.isSemiFormValid(this.formGroup)) {
this.showValidationErrorsDialog(); this.showValidationErrorsDialog();
return; return;
} }
this.submit(); this.submit(saveType);
} }
private showValidationErrorsDialog(projectOnly?: boolean) { private showValidationErrorsDialog(projectOnly?: boolean) {
@ -567,9 +579,19 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}); });
} }
onCallbackSuccess(id?: String): void { onCallbackSuccess(id?: String, 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); this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']); if (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]); });
}
} else {
this.router.navigate(['/datasets']);
}
} }
onCallbackError(error: any) { onCallbackError(error: any) {
@ -799,8 +821,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
addDataset() { addDataset(dmpId: string) {
this.router.navigate(['/datasets', 'new', dmpId]);
} }
backToDmp(id: string) { backToDmp(id: string) {

View File

@ -93,10 +93,9 @@
<span class="material-icons">chevron_right</span> <span class="material-icons">chevron_right</span>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div> <div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div> </div>
<div *ngIf="this.step >= 3 && hasProfile()" mat-raised-button type="button" class="col-auto add-dataset-option ml-auto"> <div *ngIf="this.step >= 3 && hasProfile() && !isFinalized" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset()" target="_blank">
<a class="add-dataset-btn stepper-btn" (click)="addDataset()" target="_blank"> <mat-icon>add</mat-icon>
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} <div>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</div>
</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -117,10 +117,9 @@
<span class="material-icons">chevron_right</span> <span class="material-icons">chevron_right</span>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div> <div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div> </div>
<div *ngIf="!isNewDataset && this.step >= 3 && hasProfile() && !isFinalized" mat-raised-button type="button" class="col-auto add-dataset-option ml-auto"> <div *ngIf="!isNewDataset && this.step >= 3 && hasProfile() && !isFinalized" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset()" target="_blank">
<a class="add-dataset-btn stepper-btn" (click)="addDataset()" target="_blank"> <mat-icon>add</mat-icon>
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} <div>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</div>
</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -286,7 +286,8 @@ a:hover {
justify-content: left; justify-content: left;
display: flex; display: flex;
align-items: center; align-items: center;
padding-left: 0.625rem; padding-left: 0.625rem;
padding-right: 0.625rem;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

View File

@ -422,7 +422,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
// return this.grantService.getWithExternal(grantRequestItem); // return this.grantService.getWithExternal(grantRequestItem);
// } // }
formSubmit(showAddDatasetDialog?: boolean): void { formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
this.formService.touchAllFormFields(this.formGroup); this.formService.touchAllFormFields(this.formGroup);
if (this.isNewDataset) { if (this.isNewDataset) {
if (!this.isDatasetFormValid) { if (!this.isDatasetFormValid) {
@ -436,7 +436,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.showValidationErrorsDialog(); this.showValidationErrorsDialog();
return; return;
} }
this.onSubmit(showAddDatasetDialog); this.onSubmit(addNew, showAddDatasetDialog);
} }
} }
@ -461,37 +461,39 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}); });
} }
onSubmit(showAddDatasetDialog?: boolean): void { onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
this.dmpService.createDmpWithDatasets(this.formGroup.getRawValue()) this.dmpService.createDmp(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { complete => {
if (showAddDatasetDialog) { if (showAddDatasetDialog) {
this.addDatasetOpenDialog(complete); this.addDatasetOpenDialog(complete);
} }
else if (this.step < this.stepsBeforeDatasets) { this.onCallbackSuccess(complete) } if (addNew) {
else { this.onCallbackSuccess(complete, this.datasetId) } this.onCallbackSuccessAddNew(complete);
}
else { this.onCallbackSuccess(complete) }
}, },
error => { error => {
this.formGroup.get('status').setValue(DmpStatus.Draft); this.formGroup.get('status').setValue(DmpStatus.Draft);
this.onCallbackError(error); this.onCallbackError(error);
} }
) );
// this.dmpService.createDmp(this.formGroup.getRawValue()) // this.dmpService.createDmpWithDatasets(this.formGroup.getRawValue())
// .pipe(takeUntil(this._destroyed)) // .pipe(takeUntil(this._destroyed))
// .subscribe( // .subscribe(
// complete => { // complete => {
// if (showAddDatasetDialog) { // if (showAddDatasetDialog) {
// this.addDatasetOpenDialog(complete); // this.addDatasetOpenDialog(complete);
// } // }
// else { this.onCallbackSuccess(complete) } // else if (this.step < this.stepsBeforeDatasets) { this.onCallbackSuccess(complete) }
// else { this.onCallbackSuccess(complete, this.datasetId) }
// }, // },
// error => { // error => {
// this.formGroup.get('status').setValue(DmpStatus.Draft); // this.formGroup.get('status').setValue(DmpStatus.Draft);
// this.onCallbackError(error); // this.onCallbackError(error);
// } // }
// ); // )
} }
onDatasetSubmit(): void { onDatasetSubmit(): void {
@ -520,6 +522,11 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
//this.validateAllFormFields(this.formGroup); //this.validateAllFormFields(this.formGroup);
} }
onCallbackSuccessAddNew(id?: String) {
// this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/datasets', 'new', id]);
}
public setErrorModel(validationErrorModel: ValidationErrorModel) { public setErrorModel(validationErrorModel: ValidationErrorModel) {
Object.keys(validationErrorModel).forEach(item => { Object.keys(validationErrorModel).forEach(item => {
(<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item]; (<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item];
@ -712,13 +719,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
} }
addDataset() { addDataset() {
if (!this.formGroup.get('datasets')) { this.formSubmit(true, false);
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>())); // Add dataset to list
} // if (!this.formGroup.get('datasets')) {
this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm()); // this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
this.datasets = this.formGroup.get('datasets') as FormArray; // }
this.step = this.stepsBeforeDatasets + this.formGroup.get('datasets')['controls'].length - 1; // this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm());
this.maxStep = this.maxStep + this.formGroup.get('datasets')['controls'].length - 1; // this.datasets = this.formGroup.get('datasets') as FormArray;
// this.step = this.stepsBeforeDatasets + this.formGroup.get('datasets')['controls'].length - 1;
// this.maxStep = this.maxStep + this.formGroup.get('datasets')['controls'].length - 1;
} }
hasProfile(): boolean { hasProfile(): boolean {

View File

@ -99,7 +99,7 @@ export class TableOfContents extends BaseComponent implements OnInit {
} }
this.links = links; this.links = links;
// Initialize selected for button next on dataset wizard component editor // Initialize selected for button next on dataset wizard component editor
this.links[0].selected = true; this.links.length > 0 ? this.links[0].selected = true : null;
}) })
} }

View File

@ -491,6 +491,7 @@
"GO-TO-DMP": "Gehe zu Datensatzbeschreibung DMP", "GO-TO-DMP": "Gehe zu Datensatzbeschreibung DMP",
"SAVE": "Speichern", "SAVE": "Speichern",
"SAVE-AND-ADD": "Save & Add New", "SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Speichern und Fertigstellen", "SAVE-AND-FINALISE": "Speichern und Fertigstellen",
"FINALIZE": "Fertigstellen", "FINALIZE": "Fertigstellen",
"REVERSE": "Fertigstellung rückgängig machen", "REVERSE": "Fertigstellung rückgängig machen",

View File

@ -530,6 +530,7 @@
"GO-TO-DMP": "Go to Dataset Description's DMP", "GO-TO-DMP": "Go to Dataset Description's DMP",
"SAVE": "Save", "SAVE": "Save",
"SAVE-AND-ADD": "Save & Add New", "SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Save and Finalize", "SAVE-AND-FINALISE": "Save and Finalize",
"FINALIZE": "Finalize", "FINALIZE": "Finalize",
"REVERSE": "Undo Finalization", "REVERSE": "Undo Finalization",

View File

@ -531,6 +531,7 @@
"GO-TO-DMP": "Ir al PGD de la descripción del dataset", "GO-TO-DMP": "Ir al PGD de la descripción del dataset",
"SAVE": "Grabar", "SAVE": "Grabar",
"SAVE-AND-ADD": "Save & Add New", "SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Grabar y finalizar", "SAVE-AND-FINALISE": "Grabar y finalizar",
"FINALIZE": "Finalizar", "FINALIZE": "Finalizar",
"REVERSE": "Deshacer la finalización", "REVERSE": "Deshacer la finalización",

View File

@ -528,6 +528,7 @@
"GO-TO-DMP": "Μετάβαση σε Περιγραφή Συνόλου Δεδομένων του Σχεδίου Διαχείρισης Δεδομένων", "GO-TO-DMP": "Μετάβαση σε Περιγραφή Συνόλου Δεδομένων του Σχεδίου Διαχείρισης Δεδομένων",
"SAVE": "Save", "SAVE": "Save",
"SAVE-AND-ADD": "Save & Add New", "SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Αποθήκευση και Οριστικοποίηση", "SAVE-AND-FINALISE": "Αποθήκευση και Οριστικοποίηση",
"FINALIZE": "Οριστικοποίηση", "FINALIZE": "Οριστικοποίηση",
"REVERSE": "Αναίρεση Οριστικοποίησης", "REVERSE": "Αναίρεση Οριστικοποίησης",

View File

@ -526,6 +526,7 @@
"GO-TO-DMP": "Veri seti Tanımı VYP'na Git", "GO-TO-DMP": "Veri seti Tanımı VYP'na Git",
"SAVE": "Kaydet", "SAVE": "Kaydet",
"SAVE-AND-ADD": "Save & Add New", "SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Kaydet ve Bitir", "SAVE-AND-FINALISE": "Kaydet ve Bitir",
"FINALIZE": "Tamamla", "FINALIZE": "Tamamla",
"REVERSE": "Tamamlamayı Geri Al", "REVERSE": "Tamamlamayı Geri Al",