QuickWizard Fix Merge Component And Fix Thi InitSteper

This commit is contained in:
Diamantis Tziotzios 2019-03-05 13:21:04 +02:00
parent edbed239db
commit ab8022d133
23 changed files with 375 additions and 269 deletions

View File

@ -16,21 +16,24 @@ import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
import javax.transaction.Transactional;
import javax.validation.Valid;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/quick-wizard/"})
public class QuickWizardController extends BaseController {
private QuickWizardManager quickWizardManager;
private ProjectManager projectManager;
private DatasetManager datasetManager;
@Autowired
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager,DatasetManager datasetManager) {
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager, DatasetManager datasetManager, ProjectManager projectManager) {
super(apiContext);
this.quickWizardManager = quickWizardManager;
this.datasetManager = datasetManager;
this.projectManager = projectManager;
}
@ -38,24 +41,38 @@ public class QuickWizardController extends BaseController {
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<QuickWizardModel>> addQuickWizardModel(@Valid @RequestBody QuickWizardModel quickWizard, Principal principal) throws Exception {
eu.eudat.data.entities.Project projectEntity;
//Create Project
eu.eudat.data.entities.Project projectEntity = this.quickWizardManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
quickWizard.getProject().toDataProject(), principal);
if (quickWizard.getProject().getExistProject() == null) {
projectEntity = this.quickWizardManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(),
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
quickWizard.getProject().toDataProject(), principal);
} else {
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
}
//Create Dmp
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(this.getApiContext(), quickWizard.getDmp().toDataDmp(projectEntity), principal);
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
this.getApiContext(),
quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
principal);
//Create Datasets
quickWizard.getDmp().setId(dmpEntity.getId());
for(DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()){
this.datasetManager.createOrUpdate(this.getApiContext(), dataset.toDataModel(quickWizard.getDmp().toDataDmp(projectEntity),quickWizard.getDmp().getDatasetProfile().getId()), principal);
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
this.datasetManager.createOrUpdate(this.getApiContext(), dataset.toDataModel(quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
quickWizard.getDmp().getDatasetProfile().getId()),
principal);
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.managers;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.dao.entities.ContentDao;
import eu.eudat.data.dao.entities.ProjectDao;
import eu.eudat.data.dao.entities.UserInfoDao;
@ -29,19 +30,26 @@ public class QuickWizardManager {
public DMP createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
newDmp.setCreator(user);
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
return dmpret;
}
/*public void createOrUpdate(ApiContext apiContext, DatasetDao datasetRepository,DMP dmp, eu.eudat.data.entities.DatasetProfile profile , DatasetQuickWizardModel datasetwrapper, Principal principal) throws Exception {
for (DatasetDescriptionQuickWizardModel dataset :datasetwrapper.getDatasetsList()){
datasetRepository.createOrUpdate(dataset.toDataModel(dmp,profile));
private void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
if (newDmp.getProject() != null) {
Project project = newDmp.getProject();
ProjectCriteria criteria = new ProjectCriteria();
criteria.setReference(project.getReference());
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault();
if (projectEntity != null) project.setId(projectEntity.getId());
else {
project.setType(Project.ProjectType.EXTERNAL.getValue());
projectDao.createOrUpdate(project);
}
}
}*/
}
}

View File

@ -1,7 +1,9 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.Project;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserInfo;
import java.util.Date;
@ -67,7 +69,7 @@ public class DmpQuickWizardModel {
this.project = project;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Project project) {
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(UserInfoDao userInfoRepository ,Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
dataManagementPlanEntity.setId(this.id);
@ -89,7 +91,7 @@ public class DmpQuickWizardModel {
dataManagementPlanEntity.setCreated(new Date());
List<UserInfo> user = new LinkedList<UserInfo>();
eu.eudat.models.data.userinfo.UserInfo usetInfo = new eu.eudat.models.data.userinfo.UserInfo();
usetInfo.fromDataModel(project.getCreationUser());
usetInfo.fromDataModel(userInfoRepository.find(principal.getId()));
user.add(usetInfo);
dataManagementPlanEntity.setAssociatedUsers(user);
return dataManagementPlanEntity;

View File

@ -1,24 +1,18 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.models.data.project.Project;
import java.util.Date;
import java.util.UUID;
public class ProjectQuickWizardModel {
private UUID id;
private String label;
private eu.eudat.data.entities.Project.Status status;
private String description;
private Project existProject;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
@ -28,15 +22,6 @@ public class ProjectQuickWizardModel {
this.label = label;
}
public short getStatus() {
return status.getValue();
}
public void setStatus(Short status) {
this.status = eu.eudat.data.entities.Project.Status.fromInteger(status);
}
public String getDescription() {
return description;
}
@ -46,19 +31,23 @@ public class ProjectQuickWizardModel {
}
public Project getExistProject() {
return existProject;
}
public void setExistProject(Project existProject) {
this.existProject = existProject;
}
public eu.eudat.models.data.project.Project toDataProject(){
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
toProject.setId(this.id);
toProject.setAbbreviation("");
toProject.setLabel(this.label);
toProject.setReference("dmp:" + this.label);
toProject.setUri("");
toProject.setDefinition("");
toProject.setCreated(new Date());
toProject.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Project.Status.ACTIVE.getValue());
toProject.setModified(new Date());
toProject.setDescription(this.description);
return toProject;
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
toProject.setAbbreviation("");
toProject.setLabel(this.label);
toProject.setReference("dmp:" + this.label);
toProject.setUri("");
toProject.setDefinition("");
toProject.setDescription(this.description);
return toProject;
}
}

View File

@ -32,7 +32,6 @@ import { UserService } from './services/user/user.service';
import { CollectionUtils } from './services/utilities/collection-utils.service';
import { TypeUtils } from './services/utilities/type-utils.service';
import { QuickWizardService } from './services/quick-wizard/quick-wizard.service';
import { QuickDatasetCreateWizardService } from './services/dataset-create-wizard/quick-dataset-create-wizard.service';
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
@ -85,7 +84,6 @@ export class CoreServiceModule {
DmpInvitationService,
DatasetExternalAutocompleteService,
QuickWizardService,
QuickDatasetCreateWizardService
],
};
}

View File

@ -33,7 +33,7 @@ export class QuickWizardCreateAdd extends BaseComponent implements OnInit {
navigateToAdd(){
this.router.navigate(["/quick-wizard-add"]);
this.router.navigate(["/datasetcreatewizard"]);
}

View File

@ -3,13 +3,15 @@
<mat-step class="step-container" [stepControl]="formGroup.get('dmpMeta')">
<ng-template matStepLabel>{{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}}</ng-template>
<form [formGroup]="formGroup.get('dmpMeta')">
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')"></dataset-dmp-selector-component>
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')">
</dataset-dmp-selector-component>
</form>
<div class="col-12">
<div class="row">
<div class="col"></div>
<div>
<button matStepperNext mat-raised-button color="primary">{{'DATASET-CREATE-WIZARD.ACTIONS.NEXT'| translate}}</button>
<button matStepperNext mat-raised-button
color="primary">{{'DATASET-CREATE-WIZARD.ACTIONS.NEXT'| translate}}</button>
</div>
</div>
</div>
@ -18,16 +20,18 @@
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('datasets')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup" [datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp')">
<div *ngIf="formGroup.get('dmpMeta').valid && isAvtive('step2')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp').value['label']">
</app-dataset-editor-wizard-component>
<!-- [profile]="formGroup.get('dmpMeta').get('profile')" [datasetLabel]="formGroup.get('dmpMeta').get('label')" -->
</div>
<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()' color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
<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()'
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</div>
</div>

View File

@ -1,12 +1,10 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Observable } from 'rxjs';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatStepper } from '@angular/material';
import { BaseComponent } from '../../core/common/base/base.component';
import { TranslateService } from '@ngx-translate/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
import { Router } from '@angular/router/src/router';
import { BaseComponent } from '../../core/common/base/base.component';
import { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
@Component({
selector: 'dataset-create-wizard.component',
@ -40,7 +38,16 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
submit() {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.subscribe(data => {
this.router.navigateByUrl('');
this.router.navigateByUrl('/create-add');
})
}
isAvtive(step: string): boolean {
switch (step) {
case 'step1':
return this.stepper.selectedIndex==0;
case 'step2':
return this.stepper.selectedIndex==1;
}
}
}

View File

@ -1,19 +1,15 @@
import { DatasetDmpSelectorModel } from "./dmp-selector/dataset-dmp-selector.model";
import { DmpModel } from "../../core/model/dmp/dmp";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { DatasetProfileModel } from "../../core/model/dataset/dataset-profile";
import { ValidationContext } from "../../common/forms/validation/validation-context";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "../../common/forms/validation/validation-context";
import { DmpCreateWizardFormModel } from "../../core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model";
import { DatasetEditorWizardModel } from "../quick-wizard/dataset-editor/dataset-editor-wizard-model";
import { DatasetWizardEditorModel } from "../dataset/dataset-wizard/dataset-wizard-editor.model";
import { DatasetEditorWizardModel } from "../quick-wizard/dataset-editor/dataset-editor-wizard-model";
import { DmpEditorWizardModel } from "../quick-wizard/dmp-editor/dmp-editor-wizard-model";
export class DatasetCreateWizardModel {
public dmpMeta: DmpCreateWizardFormModel;
public datasets: DatasetEditorWizardModel;
public dmpMeta: DmpCreateWizardFormModel;
public datasets: DatasetEditorWizardModel;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel {
@ -31,7 +27,7 @@ export class DatasetCreateWizardModel {
const formBuilder = new FormBuilder();
const formGroup = formBuilder.group({
dmpMeta: new DmpCreateWizardFormModel().buildForm(),
datasets: new DatasetEditorWizardModel().buildForm()
datasets: new DatasetEditorWizardModel().buildForm()
});
return formGroup;

View File

@ -1,20 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonFormsModule } from '../../common/forms/common-forms.module';
import { CommonUiModule } from '../../common/ui/common-ui.module';
import { FormattingModule } from '../../core/formatting.module';
import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module';
import { ConfirmationDialogModule } from '../../library/confirmation-dialog/confirmation-dialog.module';
import { UrlListingModule } from '../../library/url-listing/url-listing.module';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { OuickWizardModule } from '../quick-wizard/quick-wizard.module';
import { QuickWizardRoutingModule } from '../quick-wizard/quick-wizard.rooting';
import { DatasetCreateWizard } from './dataset-create-wizard.component';
import { DatasetCreateWizardRoutingModule } from './dataset-create-wizard.routing';
import { CommonUiModule } from '../../common/ui/common-ui.module';
import { CommonFormsModule } from '../../common/forms/common-forms.module';
import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module';
import { DatasetDmpSelector } from './dmp-selector/dataset-dmp-selector.component';
import { FormattingModule } from '../../core/formatting.module';
import { DatasetEditorWizardComponent } from '../quick-wizard/dataset-editor/dataset-editor-wizard.component';
//import { DatasetDescriptionFormComponent } from '../misc/dataset-description-form/dataset-description-form.component';
//import { FormProgressIndicationComponent } from '../misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component';
import { UrlListingModule } from '../../library/url-listing/url-listing.module';
import { ConfirmationDialogModule } from '../../library/confirmation-dialog/confirmation-dialog.module';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { QuickWizardRoutingModule } from '../quick-wizard/quick-wizard.rooting';
import { OuickWizardModule } from '../quick-wizard/quick-wizard.module';
import { CoreServiceModule } from '../../core/core-service.module';
@NgModule({

View File

@ -392,7 +392,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
openConfirm(dmpLabel, id): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
//maxWidth: '300px',
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
@ -404,7 +404,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardService.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets/dmp/' + this.formGroup.get('dmp').value.id);},
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets')},
error => this.onCallbackError(error)
);
}

View File

@ -39,7 +39,6 @@ import { AddResearcherComponent } from './add-researcher/add-researcher.componen
import { AvailableProfilesComponent } from './available-profiles/available-profiles.component';
import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpProfileStatus } from '../../../core/common/enum/dmp-profile-status';
@Component({
selector: 'app-dmp-editor-component',
@ -193,7 +192,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
.pipe(takeUntil(this._destroyed))
.subscribe(Option => {
if (Option instanceof Object) {
this.selectedDmpProfileDefinition=null;
this.selectedDmpProfileDefinition = null;
this.dmpProfileService.getSingle(Option.id)
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
@ -344,8 +343,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
});
}
onDeleteCallbackError(error){
this.uiNotificationService.snackBarNotification(error.error.message? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
}
// selectOption(option: any) {

View File

@ -1,4 +1,4 @@
import { FormBuilder, FormGroup } from "@angular/forms";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "../../../common/forms/validation/validation-context";
@ -17,9 +17,9 @@ export class DatasetEditorWizardModel extends BaseFormModel {
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
buildForm(context: ValidationContext = null): FormGroup {
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({});
const formGroup = new FormBuilder().group({},context.getValidation('datasetsList').validators);
const formArray = new Array<FormGroup>();
this.datasetsList.forEach(item => {
const form: FormGroup = item.buildForm();
@ -31,7 +31,7 @@ export class DatasetEditorWizardModel extends BaseFormModel {
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'datasetsList', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetsList')] });
baseContext.validation.push({ key: 'datasetsList', validators:[BackendErrorValidator(this.validationErrorModel, 'datasetsList')] });
return baseContext;
}

View File

@ -35,7 +35,6 @@
</button>
</div>
</div>
<!-- {{this.formGroup.get('datasets').get('datasetsList').value | json }} -->
</mat-card-content>
</mat-card>
</div>
@ -51,7 +50,7 @@
</mat-form-field>
<app-dataset-description-form class="col-12"
[form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]"
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="profile.value">
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value">
</app-dataset-description-form>
</div>
</div>

View File

@ -11,6 +11,7 @@ import { IBreadCrumbComponent } from "../../misc/breadcrumb/definition/IBreadCru
import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-description-model";
import { IfStmt } from "@angular/compiler";
import { TranslateService } from "@ngx-translate/core";
@ -27,70 +28,81 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
breadCrumbs: Observable<BreadcrumbItem[]>;
@Input() formGroup: FormGroup;
@Input() profile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel:FormGroup;
@Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel: string;
editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
public lastIndexOfDataset = 0;
public toggleButton=0;
public toggleButton = 0;
public _inputValue: string;
constructor(
private datasetWizardService: DatasetWizardService
private datasetWizardService: DatasetWizardService,
public language: TranslateService,
) {
super();
}
ngOnInit(): void {
}
onValChange(event: any){
if(event=="list"){
this.toggleButton=0;
this.editedDataset=false;
this._inputValue="list";
}else if (event=="add"){
this.addDataset();
this.toggleButton=2;
this._inputValue="dataset";
}else if (event=="dataset"){
this.toggleButton=2;
this._inputValue="dataset";
}
}
editDataset(index:number){
this.lastIndexOfDataset = index;
this.toggleButton=2;
this.editedDataset=true;
this._inputValue="dataset"
}
deleteDataset(index:number){//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton=0;
this.editedDataset=false;
this._inputValue="list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
this.datasetWizardService.getDefinition(this.profile.value["id"])
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
this.lastIndexOfDataset = formArray.length;
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
formGroup.get('datasetLabel').setValue("Dataset :"+this.profile.value["label"]+" For Dmp : "+this.datasetLabel.value);
formArray.push(formGroup);
this.editedDataset=true;
this.onValChange("list");
const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length;
if (length == 0) {
this.lastIndexOfDataset = length;
this.addDataset();
this.onValChange("dataset");
}
});
}
onValChange(event: any) {
if (event == "list") {
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
} else if (event == "add") {
this.addDataset();
this.toggleButton = 2;
this._inputValue = "dataset";
} else if (event == "dataset") {
this.toggleButton = 2;
this._inputValue = "dataset";
}
}
editDataset(index: number) {
this.lastIndexOfDataset = index;
this.toggleButton = 2;
this.editedDataset = true;
this._inputValue = "dataset"
}
deleteDataset(index: number) {//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
formGroup.get('datasetLabel').setValue(
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') +
this.datasetProfile.value["label"] +
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') +
this.datasetLabel);
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;
}

View File

@ -29,7 +29,7 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
isNew = true;
dmp: DmpEditorWizardModel;
@Input() formGroup: FormGroup;
@Input() dmpLabel: FormGroup;
@Input() dmpLabel: string;
//formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService
@ -43,7 +43,7 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
public router: Router,
private route: ActivatedRoute,
private _service: DmpService,
public language: TranslateService,
public language: TranslateService
) {
super();
}
@ -62,8 +62,9 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
this.dmp = new DmpEditorWizardModel();
this.formGroup = this.dmp.buildForm();
}
this.formGroup.get('label').setValue("Dmp From Project : "+ this.dmpLabel.value);
this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME')+this.dmpLabel);
this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME')+this.dmpLabel);
this.breadCrumbs = Observable.of([
{
parentComponentName: 'project',

View File

@ -4,12 +4,14 @@ import { ValidationContext } from "../../../common/forms/validation/validation-c
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator";
export class ProjectEditorWizardModel {
public id: string;
public label: string;
public status: Status = Status.Active;
public description: String;
public existProject: ProjectListingModel;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
@ -29,6 +31,7 @@ export class ProjectEditorWizardModel {
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
existProject: [{ value: this.existProject, disabled: disabled }, context.getValidation('existProject').validators],
});
return formGroup;
}
@ -39,6 +42,10 @@ export class ProjectEditorWizardModel {
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseContext.validation.push({ key: 'status', validators: [] });
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'existProject', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existProject')] });
return baseContext;
}
}

View File

@ -1,42 +1,68 @@
<div class="project-editor">
<mat-card-title *ngIf="isNew">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.NEW-TITLE' | translate}}</mat-card-title>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<form *ngIf="formGroup" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="row" *ngIf="!isNew">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!--
<mat-form-field class="col-md-6">
<input matInput (focus)="startDate.open()" (click)="startDate.open()" placeholder="{{'PROJECT-EDITOR.FIELDS.START' | translate}}" class="table-input" [matDatepicker]="startDate" formControlName="startDate">
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
<mat-datepicker #startDate></mat-datepicker>
<mat-error *ngIf="formGroup.get('startDate').hasError('backendError')">{{formGroup.get('startDate').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('startDate').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<input matInput (focus)="endDate.open()" (click)="endDate.open()" placeholder="{{'PROJECT-EDITOR.FIELDS.END' | translate}}" class="table-input" [matDatepicker]="endDate" formControlName="endDate">
<mat-datepicker-toggle matSuffix [for]="endDate"></mat-datepicker-toggle>
<mat-datepicker #endDate></mat-datepicker>
<mat-error *ngIf="formGroup.get('endDate').hasError('backendError')">{{formGroup.get('endDate').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('endDate').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-error *ngIf="formGroup.hasError('startAfterEndError')"class="col-md-12">{{'GENERAL.VALIDATION.PROJECT-START-AFTER-END' | translate}}</mat-error> -->
<mat-form-field class="col-md-12">
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<app-single-auto-complete required='true' [formControl]="formGroup.get('existProject')"
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-PROJECT' | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.hasError('backendError')">
{{formGroup.get('project').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row" *ngIf="isNew">
<mat-form-field class="col-md-12">
<input matInput
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL' | translate}}"
type="text" name="label" [formControl]="formGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area"
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}"
[formControl]="formGroup.get('description')" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row">
<div class="col">
<hr>
</div>
<h3 class="col-auto">
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate}}
</h3>
<div class="col">
<hr>
</div>
</div>
<div class="row">
<div class="col"></div>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="!isNew"
(click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW' | translate}}</button>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="isNew"
(click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST' | translate}}</button>
<div class="col"></div>
</div>
</mat-card-content>
</mat-card>
</form>
</div>
</div>

View File

@ -1,16 +1,20 @@
import { Component, OnInit, Input } from '@angular/core';
import { BaseComponent } from "../../../core/common/base/base.component";
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { BaseComponent } from "../../../core/common/base/base.component";
import { ProjectCriteria } from '../../../core/query/project/project-criteria';
import { RequestItem } from '../../../core/query/request-item';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { ProjectService } from '../../../core/services/project/project.service';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { ProjectEditorWizardModel } from './project-editor-wizard-model';
import { MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-quick-wizard-project-editor-component',
@ -20,27 +24,26 @@ import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/
export class ProjectEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
isNew = true;
isNew = false;
project: ProjectEditorWizardModel;
@Input() formGroup: FormGroup;
//formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
constructor(
public snackBar: MatSnackBar,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
private projectService: ProjectService,
public languageResolverService: LanguageResolverService,
) {
super();
}
ngOnInit() {
if (this.formGroup == null) {
this.project = new ProjectEditorWizardModel();
this.formGroup = this.project.buildForm();
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'QuickCreate',
@ -48,6 +51,29 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
url: '/quick-wizard/project'
}]
);
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
initialItems: (extraData) => this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label']
};
if (!this.formGroup) {
this.project = new ProjectEditorWizardModel();
this.formGroup = this.project.buildForm();
}
this.formGroup.get('existProject').enable();
this.formGroup.get('label').disable();
this.formGroup.get('description').disable();
// this.route.params
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
@ -76,11 +102,6 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
// });
}
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
public isFormValid() {
return this.formGroup.valid;
@ -101,16 +122,6 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
}
}
onSubmit(): void {
// this.projectService.createProject(this.formGroup.value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
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(['/project']);
@ -143,4 +154,27 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
create() {
this.isNew = !this.isNew;
if (this.isNew) {
this.formGroup.get('existProject').disable();
this.formGroup.get('existProject').reset();
this.formGroup.get('label').enable();
this.formGroup.get('description').enable();
} else {
this.formGroup.get('existProject').enable();
this.formGroup.get('label').disable();
this.formGroup.get('label').reset();
this.formGroup.get('description').disable();
this.formGroup.get('description').reset();
}
}
}

View File

@ -4,29 +4,27 @@
<div class="row">
<mat-horizontal-stepper linear class="col-12" #stepper>
<mat-step [stepControl]="formGroup.get('project')">
<ng-container *ngIf="isAvtive('step1')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('project')">
<app-quick-wizard-project-editor-component class="col-12"
[formGroup]="formGroup.get('project')">
</app-quick-wizard-project-editor-component>
</div>
<div class="navigation-buttons-container">
<button style="float:right;" matStepperNext mat-raised-button
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button>
</div>
</ng-container>
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('project')">
<app-quick-wizard-project-editor-component class="col-12"
[formGroup]="formGroup.get('project')">
</app-quick-wizard-project-editor-component>
</div>
<div class="navigation-buttons-container">
<button style="float:right;" matStepperNext mat-raised-button
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button>
</div>
</mat-step>
<mat-step [stepControl]="formGroup.get('dmp')">
<ng-container *ngIf="isAvtive('step2')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('dmp')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}}
</ng-template>
<ng-container *ngIf="formGroup.get('project').valid">
<div>
<app-quick-wizard-dmp-editor-component class="col-12" [formGroup]="formGroup.get('dmp')"
[dmpLabel]="formGroup.get('project').get('label')">
[dmpLabel]=" getProjectLabel()">
</app-quick-wizard-dmp-editor-component>
</div>
<div class="navigation-buttons-container">
@ -38,15 +36,16 @@
</ng-container>
</mat-step>
<mat-step [stepControl]="formGroup.get('datasets')">
<ng-container *ngIf="isAvtive('step3')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<!-- <ng-container *ngIf="isAvtive('step3')"> -->
<ng-container *ngIf="formGroup.get('dmp').valid && isAvtive('step3')">
<div *ngIf="formGroup.get('datasets')">
<!-- <div *ngIf="this.isActiveStep(3)" class="row"> -->
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmp').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmp').get('label')">
[datasetLabel]="formGroup.get('dmp').get('label').value">
</app-dataset-editor-wizard-component>
<!-- <app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition"
[form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules"
@ -67,4 +66,4 @@
</mat-horizontal-stepper>
</div>
</form>
</div>
</div>

View File

@ -34,7 +34,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
formGroup: FormGroup = null;
firstStepFormGroup: FormGroup;
secondFormGroup: FormGroup;
uiNotificationService: any;
constructor(
@ -42,16 +41,17 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
public quickWizardService: QuickWizardService
public quickWizardService: QuickWizardService,
private uiNotificationService: UiNotificationService
) {
super();
}
ngOnInit(): void {
this.quickWizard = new QuickWizardEditorWizardModel();
// this.quickWizard.project = new ProjectEditorWizardModel();
this.quickWizard.project = new ProjectEditorWizardModel();
// this.quickWizard.dmp = new DmpEditorWizardModel();
// this.quickWizard.datasets = new DatasetEditorWizardModel();
//this.quickWizard.datasets = new DatasetEditorWizardModel();
this.formGroup = this.quickWizard.buildForm();
this.breadCrumbs = Observable.of([
{
@ -101,7 +101,11 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
if(this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList')as FormArray).length>0){
this.onSubmit();
}else{
return;
}
}
public isFormValid() {
@ -125,7 +129,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
onSubmit(): void {
if (!this.isFormValid()) { return; }
this.quickWizardService.createQuickWizard(this.formGroup.value)
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
@ -136,19 +140,19 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
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(['/quickwizard']);
this.router.navigate(['/home/create-add']);
}
onCallbackError(errorResponse: any) {
// this.setErrorModel(errorResponse.error.payload);
this.setErrorModel(errorResponse.error.payload);
this.validateAllFormFields(this.formGroup);
}
// public setErrorModel(validationErrorModel: ValidationErrorModel) {
// Object.keys(validationErrorModel).forEach(item => {
// (<any>this.quickWizard.validationErrorModel)[item] = (<any>validationErrorModel)[item];
// });
// }
public setErrorModel(validationErrorModel: ValidationErrorModel) {
Object.keys(validationErrorModel).forEach(item => {
(<any>this.quickWizard.validationErrorModel)[item] = (<any>validationErrorModel)[item];
});
}
public validateAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
@ -165,9 +169,12 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
}
isActiveStep(index: number) {
return this.stepper.selectedIndex === index;
getProjectLabel():string{
if(this.formGroup.get('project').get('existProject').value){
return this.formGroup.get('project').get('existProject').value['label'];
}else{
return this.formGroup.get('project').get('label').value;
}
}
}

View File

@ -34,10 +34,9 @@ export class QuickWizardEditorWizardModel {
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); }
buildForm(context: ValidationContext = null): FormGroup {
// if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
project: new ProjectEditorWizardModel().buildForm(),
dmp: new DmpEditorWizardModel().buildForm(),
datasets: new DatasetEditorWizardModel().buildForm()
@ -46,12 +45,12 @@ export class QuickWizardEditorWizardModel {
return formGroup;
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'project')] });
baseContext.validation.push({ key: 'dmp', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmp')] });
baseContext.validation.push({ key: 'datasets', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasets')] });
return baseContext;
}
// createValidationContext(): ValidationContext {
// const baseContext: ValidationContext = new ValidationContext();
// baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'project')] });
// baseContext.validation.push({ key: 'dmp', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmp')] });
// baseContext.validation.push({ key: 'datasets', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasets')] });
// return baseContext;
// }
}

View File

@ -677,12 +677,15 @@
"DELETE": "Delete",
"SAVE": "Save",
"NEXT": "Next",
"BACK": "Back"
"BACK": "Back",
"CREATE-NEW":"Create new",
"EXIST":"Existing Project"
},
"FIRST-STEP": {
"TITLE": "Create Project",
"NEW-TITLE": "New Project",
"TITLE": "Select Project",
"OR": "or",
"FIELDS": {
"SELECT-PROJECT":"Select Project",
"LABEL": "Label",
"DESCRIPTION": "Description"
}
@ -690,6 +693,7 @@
"SECOND-STEP": {
"TITLE": "Create Dmp",
"NEW-TITLE": "New Data Management Plan",
"DMP-NAME":"Dmp For Project : ",
"FIELDS": {
"NAME": "Name of the Dmp",
"DESCRIPTION": "Description",
@ -699,7 +703,9 @@
"THIRD-STEP": {
"TITLE": "Create Dataset",
"NEW-TITLE":"New Dataset",
"DATASET-LABEL":"Dataset Name"
"DATASET-LABEL":"Dataset Name",
"DATASET-NAME":"Dataset : ",
"DATASET-NAME-FOR":" For Dmp : "
}
}
},