Adds Quick dataset create functionality.
This commit is contained in:
parent
74694c82b6
commit
edbed239db
|
@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -58,4 +59,16 @@ public class QuickWizardController extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetcreate"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{
|
||||||
|
for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){
|
||||||
|
this.datasetManager.createOrUpdate(this.getApiContext(), dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId()), principal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetCreateWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Dataset added!"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
|
|
||||||
|
public class DatasetCreateWizardModel {
|
||||||
|
|
||||||
|
private DmpCreateWizardModel dmpMeta;
|
||||||
|
private DatasetQuickWizardModel datasets;
|
||||||
|
|
||||||
|
public DmpCreateWizardModel getDmpMeta() { return dmpMeta; }
|
||||||
|
public void setDmpMeta(DmpCreateWizardModel dmpMeta) { this.dmpMeta = dmpMeta; }
|
||||||
|
|
||||||
|
public DatasetQuickWizardModel getDatasets() {
|
||||||
|
return datasets;
|
||||||
|
}
|
||||||
|
public void setDatasets(DatasetQuickWizardModel datasets) {
|
||||||
|
this.datasets = datasets;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DatasetProfileCreateWizardModel {
|
||||||
|
private UUID id;
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
public UUID getId() { return id; }
|
||||||
|
public void setId(UUID id) { this.id = id; }
|
||||||
|
|
||||||
|
public String getLabel() { return label; }
|
||||||
|
public void setLabel(String label) { this.label = label; }
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
|
||||||
|
public class DmpCreateWizardModel {
|
||||||
|
private DatasetProfileCreateWizardModel datasetProfile;
|
||||||
|
private DataManagementPlan dmp;
|
||||||
|
|
||||||
|
public DatasetProfileCreateWizardModel getDatasetProfile() {return datasetProfile; }
|
||||||
|
public void setDatasetProfile(DatasetProfileCreateWizardModel datasetProfileCreateWizardModel) {
|
||||||
|
this.datasetProfile = datasetProfileCreateWizardModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataManagementPlan getDmp() { return dmp; }
|
||||||
|
public void setDmp(DataManagementPlan dmp) { this.dmp = dmp; }
|
||||||
|
}
|
|
@ -11,6 +11,13 @@ const appRoutes: Routes = [
|
||||||
},
|
},
|
||||||
pathMatch: 'full'
|
pathMatch: 'full'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'datasetcreatewizard',
|
||||||
|
loadChildren: './ui/dataset-create-wizard/dataset-create-wizard.module#DatasetCreateWizardModule',
|
||||||
|
data: {
|
||||||
|
breadcrumb: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'explore',
|
path: 'explore',
|
||||||
loadChildren: './ui/explore-dataset/explore-dataset.module#ExploreDatasetModule',
|
loadChildren: './ui/explore-dataset/explore-dataset.module#ExploreDatasetModule',
|
||||||
|
|
|
@ -19,7 +19,8 @@ import { BreadcrumbModule } from './ui/misc/breadcrumb/breadcrumb.module';
|
||||||
import { HelpContentModule } from './ui/misc/help-content/help-content.module';
|
import { HelpContentModule } from './ui/misc/help-content/help-content.module';
|
||||||
import { NavigationModule } from './ui/misc/navigation/navigation.module';
|
import { NavigationModule } from './ui/misc/navigation/navigation.module';
|
||||||
import { LoginModule } from './ui/auth/login/login.module';
|
import { LoginModule } from './ui/auth/login/login.module';
|
||||||
import { QuickWizardRoutingModule } from './ui/quick-wizard/quick-wizard.rooting';
|
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||||
|
import { DatasetCreateWizardModule } from './ui/dataset-create-wizard/dataset-create-wizard.module';
|
||||||
|
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
export function HttpLoaderFactory(http: HttpClient) {
|
export function HttpLoaderFactory(http: HttpClient) {
|
||||||
|
@ -49,10 +50,13 @@ export function HttpLoaderFactory(http: HttpClient) {
|
||||||
NotificationModule,
|
NotificationModule,
|
||||||
NavigationModule,
|
NavigationModule,
|
||||||
BreadcrumbModule,
|
BreadcrumbModule,
|
||||||
HelpContentModule
|
HelpContentModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
FormsModule,
|
||||||
|
DatasetCreateWizardModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent
|
AppComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@ 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.
|
||||||
|
@ -83,7 +84,8 @@ export class CoreServiceModule {
|
||||||
UserService,
|
UserService,
|
||||||
DmpInvitationService,
|
DmpInvitationService,
|
||||||
DatasetExternalAutocompleteService,
|
DatasetExternalAutocompleteService,
|
||||||
QuickWizardService
|
QuickWizardService,
|
||||||
|
QuickDatasetCreateWizardService
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { DmpModel } from "../dmp"
|
||||||
|
import { DatasetProfileModel } from "../../dataset/dataset-profile";
|
||||||
|
import { FormGroup } from "@angular/forms/src/model";
|
||||||
|
import { ValidationContext } from "../../../../common/forms/validation/validation-context";
|
||||||
|
import { Validators, FormBuilder } from "@angular/forms";
|
||||||
|
import { BackendErrorValidator } from "../../../../common/forms/validation/custom-validator";
|
||||||
|
import { ValidationErrorModel } from "../../../../common/forms/validation/error-model/validation-error-model";
|
||||||
|
|
||||||
|
export class DmpCreateWizardFormModel {
|
||||||
|
dmp: DmpModel;
|
||||||
|
datasetProfile: DatasetProfileModel;
|
||||||
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
|
||||||
|
fromModel(item: DmpCreateWizardFormModel): DmpCreateWizardFormModel {
|
||||||
|
this.dmp = item.dmp;
|
||||||
|
this.datasetProfile = item.datasetProfile;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext = null): FormGroup{
|
||||||
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
const formBuilder = new FormBuilder();
|
||||||
|
const formGroup = formBuilder.group({
|
||||||
|
dmp: [this.dmp, context.getValidation('dmp').validators],
|
||||||
|
datasetProfile: [this.datasetProfile, context.getValidation('datasetProfile').validators],
|
||||||
|
});
|
||||||
|
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
createValidationContext(): ValidationContext {
|
||||||
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
|
baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] });
|
||||||
|
baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] });
|
||||||
|
|
||||||
|
return baseContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ import { Observable } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model';
|
import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model';
|
||||||
import { BaseHttpService } from '../http/base-http.service';
|
import { BaseHttpService } from '../http/base-http.service';
|
||||||
|
import { DatasetCreateWizardModel } from '../../../ui/dataset-create-wizard/dataset-create-wizard.model';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QuickWizardService {
|
export class QuickWizardService {
|
||||||
|
@ -16,11 +15,11 @@ export class QuickWizardService {
|
||||||
this.actionUrl = environment.Server + 'quick-wizard/';
|
this.actionUrl = environment.Server + 'quick-wizard/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable<QuickWizardEditorWizardModel> {
|
createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable<QuickWizardEditorWizardModel> {
|
||||||
return this.http.post<QuickWizardEditorWizardModel>(this.actionUrl, quickWizard, { headers: this.headers });
|
return this.http.post<QuickWizardEditorWizardModel>(this.actionUrl, quickWizard, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createQuickDatasetWizard(datasetCreateWizardModel: DatasetCreateWizardModel): Observable<DatasetCreateWizardModel> {
|
||||||
}
|
return this.http.post<DatasetCreateWizardModel>(this.actionUrl + '/datasetcreate', datasetCreateWizardModel, { headers: this.headers });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<div class="dataset-create-wizard">
|
||||||
|
<mat-horizontal-stepper linear #stepper>
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-step>
|
||||||
|
<mat-step [stepControl]="formGroup">
|
||||||
|
<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')">
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</mat-step>
|
||||||
|
</mat-horizontal-stepper>
|
||||||
|
</div>
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
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 { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'dataset-create-wizard.component',
|
||||||
|
templateUrl: 'dataset-create-wizard.component.html',
|
||||||
|
styleUrls: ['./dataset-create-wizard.component.scss'],
|
||||||
|
})
|
||||||
|
export class DatasetCreateWizard extends BaseComponent implements OnInit {
|
||||||
|
isLinear = false;
|
||||||
|
formGroup: FormGroup;
|
||||||
|
router: Router;
|
||||||
|
|
||||||
|
datasetCreateWizardModel: DatasetCreateWizardModel;
|
||||||
|
@ViewChild('stepper') stepper: MatStepper;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
|
public quickWizardService: QuickWizardService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.datasetCreateWizardModel = new DatasetCreateWizardModel();
|
||||||
|
this.formGroup = this.datasetCreateWizardModel.buildForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
save() {
|
||||||
|
this.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
|
||||||
|
.subscribe(data => {
|
||||||
|
this.router.navigateByUrl('');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
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 { BackendErrorValidator } from "../../common/forms/validation/custom-validator";
|
||||||
|
import { ValidationErrorModel } from "../../common/forms/validation/error-model/validation-error-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 { DmpEditorWizardModel } from "../quick-wizard/dmp-editor/dmp-editor-wizard-model";
|
||||||
|
|
||||||
|
export class DatasetCreateWizardModel {
|
||||||
|
public dmpMeta: DmpCreateWizardFormModel;
|
||||||
|
public datasets: DatasetEditorWizardModel;
|
||||||
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
|
||||||
|
fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel {
|
||||||
|
this.dmpMeta.fromModel(item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromModelDataset(item: DatasetWizardEditorModel[]): DatasetCreateWizardModel {
|
||||||
|
this.datasets.fromModel(item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext = null): FormGroup {
|
||||||
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
const formBuilder = new FormBuilder();
|
||||||
|
const formGroup = formBuilder.group({
|
||||||
|
dmpMeta: new DmpCreateWizardFormModel().buildForm(),
|
||||||
|
datasets: new DatasetEditorWizardModel().buildForm()
|
||||||
|
});
|
||||||
|
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
createValidationContext(): ValidationContext {
|
||||||
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
|
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||||
|
baseContext.validation.push({ key: 'status', validators: [BackendErrorValidator(this.validationErrorModel, 'status')] });
|
||||||
|
|
||||||
|
return baseContext;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
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({
|
||||||
|
imports: [
|
||||||
|
DatasetCreateWizardRoutingModule,
|
||||||
|
CommonUiModule,
|
||||||
|
CommonFormsModule,
|
||||||
|
AutoCompleteModule,
|
||||||
|
FormattingModule,
|
||||||
|
UrlListingModule,
|
||||||
|
ConfirmationDialogModule,
|
||||||
|
QuickWizardRoutingModule,
|
||||||
|
DatasetDescriptionFormModule,
|
||||||
|
OuickWizardModule,
|
||||||
|
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
DatasetCreateWizard,
|
||||||
|
DatasetDmpSelector,
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class DatasetCreateWizardModule { }
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { DatasetCreateWizard } from './dataset-create-wizard.component';
|
||||||
|
import { DatasetDmpSelector } from './dmp-selector/dataset-dmp-selector.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: DatasetCreateWizard,
|
||||||
|
data: {
|
||||||
|
breadcrumb: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: DatasetDmpSelector,
|
||||||
|
data: {
|
||||||
|
breadcrumb: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class DatasetCreateWizardRoutingModule { }
|
|
@ -0,0 +1,14 @@
|
||||||
|
<div class="dataset-dmp-selector" [formGroup]="formGroup" *ngIf="formGroup">
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}"
|
||||||
|
[configuration]="dmpAutoCompleteConfiguration">
|
||||||
|
</app-single-auto-complete>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="col-md-6">
|
||||||
|
<mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" formControlName="datasetProfile">
|
||||||
|
<mat-option *ngFor="let datasetProfile of availableProfiles" [value]="datasetProfile">
|
||||||
|
{{datasetProfile.label}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
|
@ -0,0 +1,89 @@
|
||||||
|
import { Component, OnInit, ViewChild, Input } from '@angular/core';
|
||||||
|
import { BaseComponent } from '../../../core/common/base/base.component';
|
||||||
|
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
|
||||||
|
import { MatStepper, MatSnackBar } from '@angular/material';
|
||||||
|
import { FormGroup } from '@angular/forms';
|
||||||
|
import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { RequestItem } from '../../../core/query/request-item';
|
||||||
|
import { DmpCriteria } from '../../../core/query/dmp/dmp-criteria';
|
||||||
|
import { Params, ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { DatasetProfileCriteria } from '../../../core/query/dataset-profile/dataset-profile-criteria';
|
||||||
|
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
||||||
|
import { DmpListingModel } from '../../../core/model/dmp/dmp-listing';
|
||||||
|
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
|
||||||
|
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
|
||||||
|
import { DatasetWizardService } from '../../../core/services/dataset-wizard/dataset-wizard.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { DmpService } from '../../../core/services/dmp/dmp.service';
|
||||||
|
import { FormControl } from '@angular/forms/src/model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'dataset-dmp-selector-component',
|
||||||
|
templateUrl: 'dataset-dmp-selector.component.html',
|
||||||
|
styleUrls: ['./dataset-dmp-selector.component.scss'],
|
||||||
|
})
|
||||||
|
|
||||||
|
export class DatasetDmpSelector extends BaseComponent implements OnInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
|
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
@Input() formGroup: FormGroup;
|
||||||
|
formControl: FormControl;
|
||||||
|
availableProfiles: DatasetProfileModel[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
public dmpService: DmpService,
|
||||||
|
private datasetWizardService: DatasetWizardService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.dmpAutoCompleteConfiguration = {
|
||||||
|
filterFn: this.searchDmp.bind(this),
|
||||||
|
initialItems: (extraData) => this.searchDmp(''),
|
||||||
|
displayFn: (item) => item['label'],
|
||||||
|
titleFn: (item) => item['label'],
|
||||||
|
};
|
||||||
|
|
||||||
|
this.formGroup.get('dmp').valueChanges
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(x => {
|
||||||
|
if (x) { this.loadDatasetProfiles(); }
|
||||||
|
else {
|
||||||
|
this.availableProfiles = [];
|
||||||
|
this.formGroup.get('datasetProfile').reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
searchDmp(query: string): Observable<DmpListingModel[]> {
|
||||||
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||||
|
dmpDataTableRequest.criteria = new DmpCriteria();
|
||||||
|
dmpDataTableRequest.criteria.like = query;
|
||||||
|
//const dmpListingModel =
|
||||||
|
|
||||||
|
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete")
|
||||||
|
.map(x => x.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadDatasetProfiles() {
|
||||||
|
const datasetProfileRequestItem: RequestItem<DatasetProfileCriteria> = new RequestItem();
|
||||||
|
datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
|
||||||
|
datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id;
|
||||||
|
if (datasetProfileRequestItem.criteria.id) {
|
||||||
|
this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(items => {
|
||||||
|
this.availableProfiles = items;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { DmpModel } from "../../../core/model/dmp/dmp";
|
||||||
|
import { DatasetProfileModel } from "../../../core/model/dataset/dataset-profile";
|
||||||
|
|
||||||
|
export class DatasetDmpSelectorModel{
|
||||||
|
label?: string;
|
||||||
|
status?: number;
|
||||||
|
}
|
|
@ -6,13 +6,14 @@ import { ValidationContext } from "../../../common/forms/validation/validation-c
|
||||||
import { FormBuilder, FormGroup, Validators } 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 { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator";
|
import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator";
|
||||||
|
import { DatasetProfileModel } from "../../../core/model/dataset/dataset-profile";
|
||||||
|
|
||||||
export class DmpEditorWizardModel {
|
export class DmpEditorWizardModel {
|
||||||
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 profile: DmpProfile;
|
public datasetProfile: DatasetProfileModel;
|
||||||
public definition: DmpProfileDefinition;
|
public definition: DmpProfileDefinition;
|
||||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ export class DmpEditorWizardModel {
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.status = item.status;
|
this.status = item.status;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.profile = item.profiles[0];
|
this.datasetProfile = item.profiles[0];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ export class DmpEditorWizardModel {
|
||||||
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],
|
||||||
profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators],
|
datasetProfile: [{ value: this.datasetProfile, disabled: disabled }, context.getValidation('datasetProfile').validators],
|
||||||
});
|
});
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,7 @@ export class DmpEditorWizardModel {
|
||||||
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: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
|
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
|
||||||
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: 'profile', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profile')] });
|
baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] });
|
||||||
return baseContext;
|
return baseContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
translate}}</mat-error>
|
translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col-12">
|
<mat-form-field class="col-12">
|
||||||
<app-single-auto-complete [required]='true' [formControl]="formGroup.get('profile')"
|
<app-single-auto-complete [required]='true' [formControl]="formGroup.get('datasetProfile')"
|
||||||
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE' | translate}}"
|
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE' | translate}}"
|
||||||
[configuration]="profilesAutoCompleteConfiguration">
|
[configuration]="profilesAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('profile').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('datasetProfile').hasError('backendError')">
|
||||||
{{formGroup.get('profile').getError('backendError').message}}</mat-error>
|
{{formGroup.get('datasetProfile').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('profile').hasError('required')">
|
<mat-error *ngIf="formGroup.get('datasetProfile').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<!-- <mat-form-field class="col-md-6">
|
<!-- <mat-form-field class="col-md-6">
|
||||||
|
@ -64,4 +64,4 @@
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<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"
|
||||||
[profile]="formGroup.get('dmp').get('profile')"
|
[datasetProfile]="formGroup.get('dmp').get('datasetProfile')"
|
||||||
[datasetLabel]="formGroup.get('dmp').get('label')">
|
[datasetLabel]="formGroup.get('dmp').get('label')">
|
||||||
</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"
|
||||||
|
@ -67,4 +67,4 @@
|
||||||
</mat-horizontal-stepper>
|
</mat-horizontal-stepper>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,13 +20,16 @@ import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/d
|
||||||
AutoCompleteModule,
|
AutoCompleteModule,
|
||||||
ConfirmationDialogModule,
|
ConfirmationDialogModule,
|
||||||
QuickWizardRoutingModule,
|
QuickWizardRoutingModule,
|
||||||
DatasetDescriptionFormModule
|
DatasetDescriptionFormModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ProjectEditorWizardComponent,
|
ProjectEditorWizardComponent,
|
||||||
DmpEditorWizardComponent,
|
DmpEditorWizardComponent,
|
||||||
QuickWizardEditorComponent,
|
QuickWizardEditorComponent,
|
||||||
DatasetEditorWizardComponent
|
DatasetEditorWizardComponent
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
DatasetEditorWizardComponent,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OuickWizardModule { }
|
export class OuickWizardModule { }
|
||||||
|
|
|
@ -215,6 +215,14 @@
|
||||||
"DOWNLOAD-PDF": "Download PDF"
|
"DOWNLOAD-PDF": "Download PDF"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DMP-UPLOAD": {
|
||||||
|
"TITLE": "Upload Data Managment Plan via XML",
|
||||||
|
"UPLOAD-BUTTON": "Upload",
|
||||||
|
"ACTIONS": {
|
||||||
|
"IMPORT": "Import",
|
||||||
|
"CANCEL": "Cancel"
|
||||||
|
}
|
||||||
|
},
|
||||||
"DATASET-WIZARD": {
|
"DATASET-WIZARD": {
|
||||||
"TITLE": {
|
"TITLE": {
|
||||||
"NEW": "New Dataset Description"
|
"NEW": "New Dataset Description"
|
||||||
|
@ -452,6 +460,16 @@
|
||||||
"DELETE": "Delete"
|
"DELETE": "Delete"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DATASET-CREATE-WIZARD": {
|
||||||
|
"ACTIONS": {
|
||||||
|
"NEXT": "Next",
|
||||||
|
"BACK": "Back",
|
||||||
|
"SAVE": "Save"
|
||||||
|
},
|
||||||
|
"FIRST-STEP": {
|
||||||
|
"TITLE": "DMP Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
"INVITATION-EDITOR": {
|
"INVITATION-EDITOR": {
|
||||||
"TITLE": "Send Invitations for ",
|
"TITLE": "Send Invitations for ",
|
||||||
"AUTOCOMPLETE-USER": "User",
|
"AUTOCOMPLETE-USER": "User",
|
||||||
|
@ -690,4 +708,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue