diff --git a/dmp-admin/src/app/dataset-profile-form/form/form.component.html b/dmp-admin/src/app/dataset-profile-form/form/form.component.html index 388ca31ce..2741ea42b 100644 --- a/dmp-admin/src/app/dataset-profile-form/form/form.component.html +++ b/dmp-admin/src/app/dataset-profile-form/form/form.component.html @@ -1,6 +1,6 @@ 
-
+
diff --git a/dmp-admin/src/app/dataset-profile-form/form/form.component.ts b/dmp-admin/src/app/dataset-profile-form/form/form.component.ts index b16ca40e2..993f34174 100644 --- a/dmp-admin/src/app/dataset-profile-form/form/form.component.ts +++ b/dmp-admin/src/app/dataset-profile-form/form/form.component.ts @@ -25,28 +25,22 @@ export class FormComponent { constructor(public restBase: RestBase, private datasetProfileService: DatasetProfileService, private route: ActivatedRoute) { this.profileID = route.snapshot.params['id']; - } ngOnInit() { - this.dataModel = new JsonSerializer().fromJSONObject(new DatasetProfileModel(), DatasetProfileModel); - this.form = this.dataModel.buildForm(); + this.dataModel = new JsonSerializer().fromJSONObject(new DatasetProfileModel(), DatasetProfileModel); + this.form = this.dataModel.buildForm(); if (this.profileID) { this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => { - this.dataModel = new JsonSerializer().fromJSONObject(data, DatasetProfileModel); this.form = this.dataModel.buildForm(); }); } - else{ - - this.addSection(); - this.addPage(0); + else { + this.addSection(); + this.addPage(0); } - - // this.dataModel = new JsonSerializer().fromJSONObject(TestModel, DatasetProfileModel); - // this.form = this.dataModel.buildForm(); } onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { @@ -63,31 +57,31 @@ export class FormComponent { } addPage(number) { - let page: Page = new Page(this.dataModel.pages.length); - this.dataModel.pages.push(page); - (this.form.get("pages")).push(page.buildForm()); + let page: Page = new Page(this.dataModel.pages.length); + this.dataModel.pages.push(page); + (this.form.get("pages")).push(page.buildForm()); } DeleteSection(index) { - this.dataModel.sections.splice(index,1); + this.dataModel.sections.splice(index, 1); (this.form.get("sections")).removeAt(index) } DeletePage(index) { - this.dataModel.pages.splice(index, 1); - (this.form.get("pages")).removeAt(index) + this.dataModel.pages.splice(index, 1); + (this.form.get("pages")).removeAt(index) } createForm(data) { return this.restBase.post("/admin/addDmp", data); } - updateForm(id,data) { - return this.restBase.post("/admin/addDmp/"+id, data); + updateForm(id, data) { + return this.restBase.post("/admin/addDmp/" + id, data); } onSubmit() { let data = this.form.value; - - if(this.profileID) this.updateForm(this.profileID, data).subscribe(); + + if (this.profileID) this.updateForm(this.profileID, data).subscribe(); else this.createForm(data).subscribe(); } diff --git a/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.ts b/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.ts index ffa4723ac..0ab425d3c 100644 --- a/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.ts +++ b/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { FormGroup } from '@angular/forms'; import { Section } from 'app/models/DataSetProfile/Section'; import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup'; import { FormArray } from '@angular/forms/src/model'; @@ -24,36 +24,21 @@ export class SectionFormComponent { constructor() { } ngOnInit() { - var self = this; - - this.form.root.get("pages").valueChanges.subscribe(function(value) { - self.keepPageSelectionValid(value); - }); + var self = this; + this.form.root.get("pages").valueChanges.subscribe(function (value) { + self.keepPageSelectionValid(value); + }); } - // addGroupField() { - // let fieldGroup: FieldGroup = new FieldGroup(); - // if (this.dataModel.fieldGroups) - // this.dataModel.fieldGroups.push(fieldGroup); - // (this.form.get("fieldGroups")).push(fieldGroup.buildForm()); - // } - addField() { let fieldSet: FieldSet = new FieldSet(); let field: Field = new Field(); - //let fieldGroup: FieldGroup = new FieldGroup(); fieldSet.fields.push(field); - //fieldGroup.compositeFields.push(fieldSet); if (this.dataModel.fieldSets) this.dataModel.fieldSets.push(fieldSet); (this.form.get("fieldSets")).push(fieldSet.buildForm()); } - // DeleteFieldGroup(index) { - // this.dataModel.fieldGroups.splice(index, 1); - // (this.form.get("fieldGroups")).removeAt(index) - // } - addSectioninSection() { let section: Section = new Section(); this.dataModel.sections.push(section); @@ -65,15 +50,15 @@ export class SectionFormComponent { (this.form.get("sections")).removeAt(index); } - DeleteFieldSet(index){ + DeleteFieldSet(index) { this.dataModel.fieldSets.splice(index, 1); (this.form.get("fieldSets")).removeAt(index); } keepPageSelectionValid(pagesJson: Array) { - let selectedPage = this.form.get("page").value as number; - let pages: Array = new JsonSerializer().fromJSONArray(pagesJson, Page); - if (!isNaN(selectedPage) && pages.find(elem => elem.id === selectedPage) === undefined) - this.form.get("page").reset(); + let selectedPage = this.form.get("page").value as String; + let pages: Array = new JsonSerializer().fromJSONArray(pagesJson, Page); + if (pages.find(elem => elem.id === selectedPage) === undefined) + this.form.get("page").reset(); } } \ No newline at end of file diff --git a/dmp-admin/src/app/login/main-sign-in/main-sign-in.component.html b/dmp-admin/src/app/login/main-sign-in/main-sign-in.component.html index c6a336722..13b9a844f 100644 --- a/dmp-admin/src/app/login/main-sign-in/main-sign-in.component.html +++ b/dmp-admin/src/app/login/main-sign-in/main-sign-in.component.html @@ -3,7 +3,7 @@

- -
\ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/dataset-wizard/dataset-wizard.component.ts index fc35c438d..08c54e8c9 100644 --- a/dmp-frontend/src/app/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/dataset-wizard/dataset-wizard.component.ts @@ -107,7 +107,7 @@ export class DatasetWizardComponent implements AfterViewInit { datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); datasetProfileRequestItem.criteria.id = this.datasetWizardModel.dmp.id; this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem).subscribe(items => { - this.availableProfiles = items; + this.availableProfiles = JsonSerializer.fromJSONArray(items, DatasetProfileModel); }); } ngAfterViewInit() { diff --git a/dmp-frontend/src/app/models/datasetprofile/DatasetProfileModel.ts b/dmp-frontend/src/app/models/datasetprofile/DatasetProfileModel.ts index 538aed2b8..24bfee236 100644 --- a/dmp-frontend/src/app/models/datasetprofile/DatasetProfileModel.ts +++ b/dmp-frontend/src/app/models/datasetprofile/DatasetProfileModel.ts @@ -7,19 +7,18 @@ import { Serializable } from "../Serializable"; export class DatasetProfileModel implements Serializable { public id: String; public label: String; - public errorModel: BaseErrorModel = new BaseErrorModel(); - + fromJSONObject(item: any): DatasetProfileModel { this.id = item.id; this.label = item.label; return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { + } + + buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { if (context == null) { context = this.createValidationContext(); } const formGroup = new FormBuilder().group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators] + id: [{ value: this.id, disabled: disabled }], }); return formGroup; @@ -27,7 +26,7 @@ export class DatasetProfileModel implements Serializable { createValidationContext(): ValidationContext { const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'id')] }); + //baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'id')] }); return baseContext; } } \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasets/DatasetWizardModel.ts b/dmp-frontend/src/app/models/datasets/DatasetWizardModel.ts index 8e4243512..74de67257 100644 --- a/dmp-frontend/src/app/models/datasets/DatasetWizardModel.ts +++ b/dmp-frontend/src/app/models/datasets/DatasetWizardModel.ts @@ -16,7 +16,7 @@ import { ExternalDatasetModel } from '@app/models/external-dataset/ExternalDatas export class DatasetWizardModel implements Serializable { public id: String; public label: String; - public profile: DatasetProfileModel = new DatasetProfileModel; + public profile: DatasetProfileModel = new DatasetProfileModel(); public uri: String; public status: String; public description: String; @@ -39,7 +39,7 @@ export class DatasetWizardModel implements Serializable { this.registries = JsonSerializer.fromJSONArray(item.registries, RegisterModel); this.dataRepositories = JsonSerializer.fromJSONArray(item.dataRepositories, DataRepositoryModel); this.dmp = JsonSerializer.fromJSONObject(item.dmp, DataManagementPlanModel); - this.profile = JsonSerializer.fromJSONObject(item.profile, DatasetWizardModel); + this.profile = JsonSerializer.fromJSONObject(item.profile, DatasetProfileModel); this.datasetProfileDefinition = JsonSerializer.fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel); return this; } @@ -57,9 +57,9 @@ export class DatasetWizardModel implements Serializable { dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators], externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators], dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators], - profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators], - }); + + formGroup.addControl("profile",this.profile.buildForm()) return formGroup; }