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 });
}
createDataset(datasetModel: DatasetWizardModel): Observable<DatasetWizardModel> {
return this.http.post<DatasetWizardModel>(this.actionUrl, datasetModel, { headers: this.headers });
createDataset(datasetModel: DatasetWizardModel): Observable<String> {
return this.http.post<String>(this.actionUrl, datasetModel, { headers: this.headers });
}
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {

View File

@ -27,8 +27,9 @@
</button>
</div>
<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" type="submit">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | 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" (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>
</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 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" stickyThing (stepFound)="onStepFound($event)"></table-of-contents>
</div>
</div>
</div>
@ -60,14 +61,17 @@
<span class="material-icons">chevron_left</span>
<div>{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}</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>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div>
<div *ngIf="this.step === 1" mat-raised-button type="button" class="col-auto add-dataset-option ml-auto">
<a class="add-dataset-btn stepper-btn" (click)="addDataset()" target="_blank">
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
</a>
<div *ngIf="this.step === this.maxStep && isNew" mat-raised-button type="button" class="col-auto stepper-btn dataset-next next-disabled ml-auto">
<span class="material-icons">chevron_right</span>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</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>

View File

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

View File

@ -42,6 +42,12 @@ import { AuthService } from '@app/core/services/auth/auth.service';
import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
enum SaveType {
close = 0,
addNew = 1
}
@Component({
selector: 'app-dataset-wizard-component',
templateUrl: 'dataset-wizard.component.html',
@ -74,7 +80,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
step: number = 0;
stepOffset: number = 1;
maxStep: number = 1;
maxStep: number;
saveAnd = SaveType;
constructor(
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
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
@ -367,7 +376,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.formGroup.get('profile').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
this.datasetProfileValueChanged(x);
this.datasetProfileValueChanged(x.id);
});
}
@ -387,7 +396,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
datasetProfileValueChanged(profiledId: string) {
if (profiledId && profiledId.length > 0) {
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']; }
}
getDefinition() {
getDefinition(profileId: string) {
// 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))
.subscribe(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())
.pipe(takeUntil(this._destroyed))
.subscribe(
data => {
this.onCallbackSuccess(this.datasetWizardModel.id);
this.onCallbackSuccess(data, saveType);
},
error => this.onCallbackError(error));
}
save() {
save(saveType?: SaveType) {
this.formService.touchAllFormFields(this.formGroup);
if (!this.isSemiFormValid(this.formGroup)) {
this.showValidationErrorsDialog();
return;
}
this.submit();
this.submit(saveType);
}
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);
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) {
@ -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) {

View File

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

View File

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

View File

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

View File

@ -422,7 +422,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
// return this.grantService.getWithExternal(grantRequestItem);
// }
formSubmit(showAddDatasetDialog?: boolean): void {
formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
this.formService.touchAllFormFields(this.formGroup);
if (this.isNewDataset) {
if (!this.isDatasetFormValid) {
@ -436,7 +436,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.showValidationErrorsDialog();
return;
}
this.onSubmit(showAddDatasetDialog);
this.onSubmit(addNew, showAddDatasetDialog);
}
}
@ -461,37 +461,39 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
});
}
onSubmit(showAddDatasetDialog?: boolean): void {
this.dmpService.createDmpWithDatasets(this.formGroup.getRawValue())
onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
this.dmpService.createDmp(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
if (showAddDatasetDialog) {
this.addDatasetOpenDialog(complete);
}
else if (this.step < this.stepsBeforeDatasets) { this.onCallbackSuccess(complete) }
else { this.onCallbackSuccess(complete, this.datasetId) }
if (addNew) {
this.onCallbackSuccessAddNew(complete);
}
else { this.onCallbackSuccess(complete) }
},
error => {
this.formGroup.get('status').setValue(DmpStatus.Draft);
this.onCallbackError(error);
}
)
// this.dmpService.createDmp(this.formGroup.getRawValue())
);
// this.dmpService.createDmpWithDatasets(this.formGroup.getRawValue())
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => {
// if (showAddDatasetDialog) {
// this.addDatasetOpenDialog(complete);
// }
// else { this.onCallbackSuccess(complete) }
// else if (this.step < this.stepsBeforeDatasets) { this.onCallbackSuccess(complete) }
// else { this.onCallbackSuccess(complete, this.datasetId) }
// },
// error => {
// this.formGroup.get('status').setValue(DmpStatus.Draft);
// this.onCallbackError(error);
// }
// );
// )
}
onDatasetSubmit(): void {
@ -520,6 +522,11 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
//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) {
Object.keys(validationErrorModel).forEach(item => {
(<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item];
@ -712,13 +719,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
addDataset() {
if (!this.formGroup.get('datasets')) {
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
}
this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm());
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;
this.formSubmit(true, false);
// Add dataset to list
// if (!this.formGroup.get('datasets')) {
// this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
// }
// this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm());
// 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 {

View File

@ -99,7 +99,7 @@ export class TableOfContents extends BaseComponent implements OnInit {
}
this.links = links;
// 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",
"SAVE": "Speichern",
"SAVE-AND-ADD": "Save & Add New",
"SAVE-AND-CLOSE": "Save & Close",
"SAVE-AND-FINALISE": "Speichern und Fertigstellen",
"FINALIZE": "Fertigstellen",
"REVERSE": "Fertigstellung rückgängig machen",

View File

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

View File

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

View File

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

View File

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