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

View File

@ -1,5 +1,6 @@
package eu.eudat.logic.managers; 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.ContentDao;
import eu.eudat.data.dao.entities.ProjectDao; import eu.eudat.data.dao.entities.ProjectDao;
import eu.eudat.data.dao.entities.UserInfoDao; 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 { public DMP createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
DMP newDmp = dataManagementPlan.toDataModel(); DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
newDmp.setCreator(user); newDmp.setCreator(user);
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
return dmpret; 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()){ private void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
datasetRepository.createOrUpdate(dataset.toDataModel(dmp,profile)); 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; package eu.eudat.models.data.quickwizard;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserInfo; import eu.eudat.models.data.userinfo.UserInfo;
import java.util.Date; import java.util.Date;
@ -67,7 +69,7 @@ public class DmpQuickWizardModel {
this.project = project; 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(); eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
dataManagementPlanEntity.setId(this.id); dataManagementPlanEntity.setId(this.id);
@ -89,7 +91,7 @@ public class DmpQuickWizardModel {
dataManagementPlanEntity.setCreated(new Date()); dataManagementPlanEntity.setCreated(new Date());
List<UserInfo> user = new LinkedList<UserInfo>(); List<UserInfo> user = new LinkedList<UserInfo>();
eu.eudat.models.data.userinfo.UserInfo usetInfo = new eu.eudat.models.data.userinfo.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); user.add(usetInfo);
dataManagementPlanEntity.setAssociatedUsers(user); dataManagementPlanEntity.setAssociatedUsers(user);
return dataManagementPlanEntity; return dataManagementPlanEntity;

View File

@ -1,24 +1,18 @@
package eu.eudat.models.data.quickwizard; package eu.eudat.models.data.quickwizard;
import eu.eudat.models.data.project.Project;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class ProjectQuickWizardModel { public class ProjectQuickWizardModel {
private UUID id;
private String label; private String label;
private eu.eudat.data.entities.Project.Status status;
private String description; private String description;
private Project existProject;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() { public String getLabel() {
return label; return label;
@ -28,15 +22,6 @@ public class ProjectQuickWizardModel {
this.label = label; 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() { public String getDescription() {
return description; 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(){ public eu.eudat.models.data.project.Project toDataProject(){
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project(); eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
toProject.setId(this.id); toProject.setAbbreviation("");
toProject.setAbbreviation(""); toProject.setLabel(this.label);
toProject.setLabel(this.label); toProject.setReference("dmp:" + this.label);
toProject.setReference("dmp:" + this.label); toProject.setUri("");
toProject.setUri(""); toProject.setDefinition("");
toProject.setDefinition(""); toProject.setDescription(this.description);
toProject.setCreated(new Date()); return toProject;
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;
} }
} }

View File

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

View File

@ -33,7 +33,7 @@ export class QuickWizardCreateAdd extends BaseComponent implements OnInit {
navigateToAdd(){ 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')"> <mat-step class="step-container" [stepControl]="formGroup.get('dmpMeta')">
<ng-template matStepLabel>{{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}}</ng-template> <ng-template matStepLabel>{{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}}</ng-template>
<form [formGroup]="formGroup.get('dmpMeta')"> <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> </form>
<div class="col-12"> <div class="col-12">
<div class="row"> <div class="row">
<div class="col"></div> <div class="col"></div>
<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> </div>
</div> </div>
@ -18,15 +20,17 @@
<ng-template matStepLabel> <ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}} {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template> </ng-template>
<div *ngIf="formGroup.get('datasets')"> <div *ngIf="formGroup.get('dmpMeta').valid && isAvtive('step2')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup" [datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')" <app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp')"> [datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp').value['label']">
</app-dataset-editor-wizard-component> </app-dataset-editor-wizard-component>
<!-- [profile]="formGroup.get('dmpMeta').get('profile')" [datasetLabel]="formGroup.get('dmpMeta').get('label')" -->
</div> </div>
<div class="navigation-buttons-container"> <div class="navigation-buttons-container">
<button matStepperPrevious mat-raised-button color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button> <button matStepperPrevious mat-raised-button
<button style="float:right;" matStepperNext mat-raised-button (click)='save()' color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</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> </div>
</mat-step> </mat-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>

View File

@ -1,12 +1,10 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { Observable } from 'rxjs'; import { FormBuilder, FormGroup } from '@angular/forms';
import { MatStepper } from '@angular/material'; 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 { 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 { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
@Component({ @Component({
selector: 'dataset-create-wizard.component', selector: 'dataset-create-wizard.component',
@ -40,7 +38,16 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
submit() { submit() {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.subscribe(data => { .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 { FormBuilder, FormGroup, Validators } from "@angular/forms";
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 { BackendErrorValidator } from "../../common/forms/validation/custom-validator"; import { BackendErrorValidator } from "../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../common/forms/validation/error-model/validation-error-model"; 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 { 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 { 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 { export class DatasetCreateWizardModel {
public dmpMeta: DmpCreateWizardFormModel; public dmpMeta: DmpCreateWizardFormModel;
public datasets: DatasetEditorWizardModel; public datasets: DatasetEditorWizardModel;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel { fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel {
@ -31,7 +27,7 @@ export class DatasetCreateWizardModel {
const formBuilder = new FormBuilder(); const formBuilder = new FormBuilder();
const formGroup = formBuilder.group({ const formGroup = formBuilder.group({
dmpMeta: new DmpCreateWizardFormModel().buildForm(), dmpMeta: new DmpCreateWizardFormModel().buildForm(),
datasets: new DatasetEditorWizardModel().buildForm() datasets: new DatasetEditorWizardModel().buildForm()
}); });
return formGroup; return formGroup;

View File

@ -1,20 +1,16 @@
import { NgModule } from '@angular/core'; 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 { DatasetCreateWizard } from './dataset-create-wizard.component';
import { DatasetCreateWizardRoutingModule } from './dataset-create-wizard.routing'; 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 { 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({ @NgModule({

View File

@ -392,7 +392,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
openConfirm(dmpLabel, id): void { openConfirm(dmpLabel, id): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, { const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px', //maxWidth: '300px',
data: { data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), 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) this.datasetWizardService.delete(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .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) 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 { AvailableProfilesComponent } from './available-profiles/available-profiles.component';
import { DmpEditorModel } from './dmp-editor.model'; import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component'; import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpProfileStatus } from '../../../core/common/enum/dmp-profile-status';
@Component({ @Component({
selector: 'app-dmp-editor-component', selector: 'app-dmp-editor-component',
@ -193,7 +192,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(Option => { .subscribe(Option => {
if (Option instanceof Object) { if (Option instanceof Object) {
this.selectedDmpProfileDefinition=null; this.selectedDmpProfileDefinition = null;
this.dmpProfileService.getSingle(Option.id) this.dmpProfileService.getSingle(Option.id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(result => { .subscribe(result => {
@ -344,8 +343,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
} }
}); });
} }
onDeleteCallbackError(error){ onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
} }
// selectOption(option: any) { // 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 { BackendErrorValidator } from "../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model"; import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "../../../common/forms/validation/validation-context"; import { ValidationContext } from "../../../common/forms/validation/validation-context";
@ -17,9 +17,9 @@ export class DatasetEditorWizardModel extends BaseFormModel {
return this; return this;
} }
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { buildForm(context: ValidationContext = null): FormGroup {
if (context == null) { context = this.createValidationContext(); } 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>(); const formArray = new Array<FormGroup>();
this.datasetsList.forEach(item => { this.datasetsList.forEach(item => {
const form: FormGroup = item.buildForm(); const form: FormGroup = item.buildForm();
@ -31,7 +31,7 @@ export class DatasetEditorWizardModel extends BaseFormModel {
createValidationContext(): ValidationContext { createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new 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; return baseContext;
} }

View File

@ -35,7 +35,6 @@
</button> </button>
</div> </div>
</div> </div>
<!-- {{this.formGroup.get('datasets').get('datasetsList').value | json }} -->
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</div> </div>
@ -51,7 +50,7 @@
</mat-form-field> </mat-form-field>
<app-dataset-description-form class="col-12" <app-dataset-description-form class="col-12"
[form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]" [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> </app-dataset-description-form>
</div> </div>
</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 { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-description-model"; import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-description-model";
import { IfStmt } from "@angular/compiler"; 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[]>; breadCrumbs: Observable<BreadcrumbItem[]>;
@Input() formGroup: FormGroup; @Input() formGroup: FormGroup;
@Input() profile: FormGroup;// DatasetProfileModel; @Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel:FormGroup; @Input() datasetLabel: string;
editedDataset: boolean = false; editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel; dataset: DatasetDescriptionFormEditorModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel; public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
public lastIndexOfDataset = 0; public lastIndexOfDataset = 0;
public toggleButton=0; public toggleButton = 0;
public _inputValue: string; public _inputValue: string;
constructor( constructor(
private datasetWizardService: DatasetWizardService private datasetWizardService: DatasetWizardService,
public language: TranslateService,
) { ) {
super(); super();
} }
ngOnInit(): void { ngOnInit(): void {
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
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){ onValChange(event: any) {
if(event=="list"){ if (event == "list") {
this.toggleButton=0; this.toggleButton = 0;
this.editedDataset=false; this.editedDataset = false;
this._inputValue="list"; this._inputValue = "list";
}else if (event=="add"){ } else if (event == "add") {
this.addDataset(); this.addDataset();
this.toggleButton=2; this.toggleButton = 2;
this._inputValue="dataset"; this._inputValue = "dataset";
}else if (event=="dataset"){ } else if (event == "dataset") {
this.toggleButton=2; this.toggleButton = 2;
this._inputValue="dataset"; this._inputValue = "dataset";
} }
} }
editDataset(index:number){ editDataset(index: number) {
this.lastIndexOfDataset = index; this.lastIndexOfDataset = index;
this.toggleButton=2; this.toggleButton = 2;
this.editedDataset=true; this.editedDataset = true;
this._inputValue="dataset" this._inputValue = "dataset"
} }
deleteDataset(index:number){//TODO: delete Dataset From List deleteDataset(index: number) {//TODO: delete Dataset From List
this.lastIndexOfDataset = index; this.lastIndexOfDataset = index;
this.toggleButton=0; this.toggleButton = 0;
this.editedDataset=false; this.editedDataset = false;
this._inputValue="list"; this._inputValue = "list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index); (this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
} }
addDataset() { addDataset() {
this.datasetWizardService.getDefinition(this.profile.value["id"]) const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
.pipe(takeUntil(this._destroyed)) let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
.subscribe(item => { let formGroup = dataset.buildForm();
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;
});
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; isNew = true;
dmp: DmpEditorWizardModel; dmp: DmpEditorWizardModel;
@Input() formGroup: FormGroup; @Input() formGroup: FormGroup;
@Input() dmpLabel: FormGroup; @Input() dmpLabel: string;
//formGroup: FormGroup = null; //formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService private uiNotificationService: UiNotificationService
@ -43,7 +43,7 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
public router: Router, public router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private _service: DmpService, private _service: DmpService,
public language: TranslateService, public language: TranslateService
) { ) {
super(); super();
} }
@ -62,7 +62,8 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
this.dmp = new DmpEditorWizardModel(); this.dmp = new DmpEditorWizardModel();
this.formGroup = this.dmp.buildForm(); 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([ this.breadCrumbs = Observable.of([
{ {

View File

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

View File

@ -1,41 +1,67 @@
<div class="project-editor"> <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>
<mat-card-header> <mat-card-header>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<div class="row"> <div class="row" *ngIf="!isNew">
<mat-form-field class="col-md-12"> <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> <app-single-auto-complete required='true' [formControl]="formGroup.get('existProject')"
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error> placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-PROJECT' | translate}}"
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> [configuration]="projectAutoCompleteConfiguration">
</mat-form-field> </app-single-auto-complete>
<!-- <mat-error *ngIf="formGroup.hasError('backendError')">
<mat-form-field class="col-md-6"> {{formGroup.get('project').getError('backendError').message}}</mat-error>
<input matInput (focus)="startDate.open()" (click)="startDate.open()" placeholder="{{'PROJECT-EDITOR.FIELDS.START' | translate}}" class="table-input" [matDatepicker]="startDate" formControlName="startDate"> <mat-error *ngIf="formGroup.hasError('required')">
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<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>
</mat-form-field> </mat-form-field>
</div> </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-content>
</mat-card> </mat-card>
</form> </form>

View File

@ -1,16 +1,20 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { BaseComponent } from "../../../core/common/base/base.component"; import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; import { MatSnackBar } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs'; 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 { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { ProjectEditorWizardModel } from './project-editor-wizard-model'; 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({ @Component({
selector: 'app-quick-wizard-project-editor-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 { export class ProjectEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]); breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
isNew = true; isNew = false;
project: ProjectEditorWizardModel; project: ProjectEditorWizardModel;
@Input() formGroup: FormGroup; @Input() formGroup: FormGroup;
//formGroup: FormGroup = null; //formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService private uiNotificationService: UiNotificationService
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
constructor( constructor(
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
private route: ActivatedRoute, private route: ActivatedRoute,
public router: Router, public router: Router,
public language: TranslateService, public language: TranslateService,
private projectService: ProjectService,
public languageResolverService: LanguageResolverService,
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
if (this.formGroup == null) {
this.project = new ProjectEditorWizardModel();
this.formGroup = this.project.buildForm();
}
this.breadCrumbs = Observable.of([ this.breadCrumbs = Observable.of([
{ {
parentComponentName: 'QuickCreate', parentComponentName: 'QuickCreate',
@ -48,6 +51,29 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
url: '/quick-wizard/project' 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 // this.route.params
// .pipe(takeUntil(this._destroyed)) // .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => { // .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() { public isFormValid() {
return this.formGroup.valid; 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 { 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.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']); 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"> <div class="row">
<mat-horizontal-stepper linear class="col-12" #stepper> <mat-horizontal-stepper linear class="col-12" #stepper>
<mat-step [stepControl]="formGroup.get('project')"> <mat-step [stepControl]="formGroup.get('project')">
<ng-container *ngIf="isAvtive('step1')"> <ng-template matStepLabel>
<ng-template matStepLabel> {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}} </ng-template>
</ng-template> <div *ngIf="formGroup.get('project')">
<div *ngIf="formGroup.get('project')"> <app-quick-wizard-project-editor-component class="col-12"
<app-quick-wizard-project-editor-component class="col-12" [formGroup]="formGroup.get('project')">
[formGroup]="formGroup.get('project')"> </app-quick-wizard-project-editor-component>
</app-quick-wizard-project-editor-component> </div>
</div> <div class="navigation-buttons-container">
<div class="navigation-buttons-container"> <button style="float:right;" matStepperNext mat-raised-button
<button style="float:right;" matStepperNext mat-raised-button color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button>
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button> </div>
</div>
</ng-container>
</mat-step> </mat-step>
<mat-step [stepControl]="formGroup.get('dmp')"> <mat-step [stepControl]="formGroup.get('dmp')">
<ng-container *ngIf="isAvtive('step2')"> <ng-template matStepLabel>
<ng-template matStepLabel> {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}}
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}} </ng-template>
</ng-template> <ng-container *ngIf="formGroup.get('project').valid">
<div *ngIf="formGroup.get('dmp')"> <div>
<app-quick-wizard-dmp-editor-component class="col-12" [formGroup]="formGroup.get('dmp')" <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> </app-quick-wizard-dmp-editor-component>
</div> </div>
<div class="navigation-buttons-container"> <div class="navigation-buttons-container">
@ -38,15 +36,16 @@
</ng-container> </ng-container>
</mat-step> </mat-step>
<mat-step [stepControl]="formGroup.get('datasets')"> <mat-step [stepControl]="formGroup.get('datasets')">
<ng-container *ngIf="isAvtive('step3')"> <ng-template matStepLabel>
<ng-template matStepLabel> {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}} </ng-template>
</ng-template> <!-- <ng-container *ngIf="isAvtive('step3')"> -->
<ng-container *ngIf="formGroup.get('dmp').valid && isAvtive('step3')">
<div *ngIf="formGroup.get('datasets')"> <div *ngIf="formGroup.get('datasets')">
<!-- <div *ngIf="this.isActiveStep(3)" class="row"> --> <!-- <div *ngIf="this.isActiveStep(3)" class="row"> -->
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup" <app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmp').get('datasetProfile')" [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-editor-wizard-component>
<!-- <app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" <!-- <app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition"
[form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules"

View File

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

View File

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