Fixes "Save and Finalize" on Quick wizard.
This commit is contained in:
parent
fb70345d39
commit
460aa7d1e7
|
@ -3,6 +3,8 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.logic.managers.*;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
|
||||
import eu.eudat.models.data.quickwizard.QuickWizardModel;
|
||||
|
@ -16,6 +18,7 @@ import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
|
|||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
|
@ -58,14 +61,12 @@ public class QuickWizardController extends BaseController {
|
|||
//Create Datasets
|
||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
|
||||
this.datasetManager.createOrUpdate(dataset.toDataModel(quickWizard.getDmp().toDataDmp(
|
||||
projectEntity,
|
||||
principal),
|
||||
quickWizard.getDmp().getDatasetProfile().getId()),
|
||||
principal);
|
||||
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp( projectEntity, principal);
|
||||
UUID uuid = quickWizard.getDmp().getDatasetProfile().getId();
|
||||
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, uuid);
|
||||
this.datasetManager.createOrUpdate(datasetWizardModel, principal);
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
|
|||
newDataset.setCreated(new Date());
|
||||
newDataset.setProfile(profile);
|
||||
newDataset.setDmp(dmp);
|
||||
newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||
newDataset.setStatus((short) this.getStatus());
|
||||
//newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||
|
||||
|
||||
newDataset.setDatasetProfileDefinition((PagedDatasetProfile) this);
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
<div class="navigation-buttons-container">
|
||||
<button matStepperPrevious mat-raised-button
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
||||
<button style="float:right;" matStepperNext mat-raised-button (click)='save()'
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!formGroup.valid"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE-AND-FINALIZE' | translate}}</button>
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='save()'
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.saveAndFinalizeButton{
|
||||
float:right;
|
||||
}
|
||||
.saveButton{
|
||||
float:right;
|
||||
margin-right: 15px;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup, FormArray } from '@angular/forms';
|
||||
import { MatStepper } from '@angular/material';
|
||||
import { Router } from '@angular/router';
|
||||
import { BaseComponent } from '../../core/common/base/base.component';
|
||||
|
@ -49,6 +49,17 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
|
|||
}
|
||||
|
||||
save() {
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
control.get('status').setValue('0');
|
||||
}
|
||||
this.submit();
|
||||
}
|
||||
|
||||
saveFinalize() {
|
||||
if (!this.isFormValid()) { return; }
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
control.get('status').setValue('1');
|
||||
}
|
||||
this.submit();
|
||||
}
|
||||
|
||||
|
@ -60,6 +71,10 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
|
|||
)
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
onCallbackSuccess(): 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.router.navigate(['/home']);
|
||||
|
|
|
@ -8,6 +8,7 @@ import { FormGroup, FormControl } from "@angular/forms";
|
|||
export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEditorModel {
|
||||
|
||||
public datasetLabel: string;
|
||||
//public status: number;
|
||||
|
||||
fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel {
|
||||
super.fromModel(item);
|
||||
|
@ -17,6 +18,7 @@ export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEd
|
|||
buildForm(): FormGroup {
|
||||
const formGroup: FormGroup = super.buildForm();
|
||||
formGroup.addControl('datasetLabel', new FormControl({value: this.datasetLabel}));
|
||||
formGroup.addControl('status', new FormControl({value: this.status}));
|
||||
return formGroup;
|
||||
}
|
||||
}
|
|
@ -67,6 +67,9 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
formSubmit(): void {
|
||||
this.touchAllFormFields(this.formGroup);
|
||||
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
control.get('status').setValue('0');
|
||||
}
|
||||
this.onSubmit();
|
||||
} else {
|
||||
return;
|
||||
|
@ -75,7 +78,9 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
|
||||
saveFinalize() {
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.formGroup.get('status').setValue('1');
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
control.get('status').setValue('1');
|
||||
}
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue