From 9e25001f10229f28fb4072f56802a12b8f48d54d Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 2 Jan 2018 18:29:27 +0200 Subject: [PATCH] change on datamodel --- .../compositefield-form.component.html | 26 +++++++++--- .../compositefield-form.component.ts | 4 +- .../field-form/field-form.component.html | 14 +------ .../form/form.component.html | 9 +++- .../groupfield-form.component.ts | 4 +- .../section-form/section-form.component.html | 27 +++++++++++- .../section-form/section-form.component.ts | 41 +++++++++++-------- .../datasetprofile-editor.component.html | 16 ++++---- .../datasetprofile-editor.component.ts | 4 +- .../DataSetProfile/DatasetProfileModel.ts | 12 +++--- .../src/app/models/DataSetProfile/Field.ts | 23 +++-------- .../app/models/DataSetProfile/FieldGroup.ts | 6 +-- .../{CompositeField.ts => FieldSet.ts} | 15 +++++-- .../src/app/models/DataSetProfile/Section.ts | 26 ++++++++---- .../app/services/dataset-profile.service.ts | 2 +- 15 files changed, 140 insertions(+), 89 deletions(-) rename dmp-admin/src/app/models/DataSetProfile/{CompositeField.ts => FieldSet.ts} (70%) diff --git a/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html b/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html index c297447f1..b084a1303 100644 --- a/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html +++ b/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html @@ -2,12 +2,27 @@ + Multiplicity
+
+
+ + +
+
+ + +
+
+ + +
+
-
+
Multiplicity
@@ -20,11 +35,11 @@
-
+
-
+
@@ -33,7 +48,8 @@
- +
diff --git a/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts b/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts index 3ae8ef3f5..0ee11f88a 100644 --- a/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts +++ b/dmp-admin/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { CompositeField } from 'app/models/DataSetProfile/CompositeField'; +import { FieldSet } from 'app/models/DataSetProfile/FieldSet'; import { Field } from 'app/models/DataSetProfile/Field'; import { FormArray, FormControl } from '@angular/forms/src/model'; @@ -12,7 +12,7 @@ import { FormArray, FormControl } from '@angular/forms/src/model'; export class CompositeFieldFormComponent { @Input() form: FormGroup; - @Input() dataModel: CompositeField; + @Input() dataModel: FieldSet; @Input() indexPath: string; isComposite: boolean = false; diff --git a/dmp-admin/src/app/dataset-profile-form/field-form/field-form.component.html b/dmp-admin/src/app/dataset-profile-form/field-form/field-form.component.html index dc0150af0..75d7128d5 100644 --- a/dmp-admin/src/app/dataset-profile-form/field-form/field-form.component.html +++ b/dmp-admin/src/app/dataset-profile-form/field-form/field-form.component.html @@ -33,7 +33,7 @@
-
+
@@ -68,16 +68,6 @@
- -
- - - -
- +

Form value: {{ form.value | json }}

diff --git a/dmp-admin/src/app/dataset-profile-form/groupfield-form/groupfield-form.component.ts b/dmp-admin/src/app/dataset-profile-form/groupfield-form/groupfield-form.component.ts index 31519b0ff..266de2f0e 100644 --- a/dmp-admin/src/app/dataset-profile-form/groupfield-form/groupfield-form.component.ts +++ b/dmp-admin/src/app/dataset-profile-form/groupfield-form/groupfield-form.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup'; -import { CompositeField } from 'app/models/DataSetProfile/CompositeField'; +import { FieldSet } from 'app/models/DataSetProfile/FieldSet'; import { FormArray } from '@angular/forms/src/model'; import { Field } from 'app/models/DataSetProfile/Field'; @@ -23,7 +23,7 @@ export class GroupFieldFormComponent { } addNewFieldSet(){ - let compositeField: CompositeField = new CompositeField(); + let compositeField: FieldSet = new FieldSet(); let field: Field = new Field(); //create field at the same time compositeField.fields.push(field); diff --git a/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.html b/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.html index 1b2348a8d..1d3730e4f 100644 --- a/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.html +++ b/dmp-admin/src/app/dataset-profile-form/section-form/section-form.component.html @@ -57,9 +57,34 @@ -
+ + +
+
+
+ + {{i + 1}}. Field {{i + 1}} + +
+ +
+
+
+
+ +
+
+
+ Label - Ruleset - Viewstyle - Definition + Created + Description + Status No elements - {{datasetProfile.id}} + {{datasetProfile?.label}} - {{datasetProfile?.ruleset?.label}} - {{datasetProfile?.viewstyle?.label}} - {{datasetProfile?.definition}} + {{datasetProfile?.created}} + {{datasetProfile?.description}} + {{datasetProfile?.status}} diff --git a/dmp-admin/src/app/managers/datasetprofile-editor/datasetprofile-editor.component.ts b/dmp-admin/src/app/managers/datasetprofile-editor/datasetprofile-editor.component.ts index 1afa960e0..d632656f0 100644 --- a/dmp-admin/src/app/managers/datasetprofile-editor/datasetprofile-editor.component.ts +++ b/dmp-admin/src/app/managers/datasetprofile-editor/datasetprofile-editor.component.ts @@ -69,7 +69,7 @@ export class DatasetprofileEditorComponent implements OnInit { this.tableVisible = false; this.editorVisible = true; if(datasetProfileID == null){ - this.editingDatasetProfile = {id: null, label: "", ruleset: "", viewstyle: "", definition: "" }; + this.editingDatasetProfile = {id: null, label: "", created: "", description: "", status: "" }; } else{ this.editingDatasetProfile = this.tableData.filter((datasetProfile) => datasetProfile.id === datasetProfileID)[0]; @@ -79,7 +79,7 @@ export class DatasetprofileEditorComponent implements OnInit { getAllDatasetProfiles(showNotification : boolean){ this.datasetProfileService.fetchAllDatasetProfiles().subscribe( (data) => { - this.tableData = data; + this.tableData = data.payload; if(showNotification) simple_notifier("info",null,"Refreshed the table"); }); diff --git a/dmp-admin/src/app/models/DataSetProfile/DatasetProfileModel.ts b/dmp-admin/src/app/models/DataSetProfile/DatasetProfileModel.ts index ea68ee4c6..db2a7ad0f 100644 --- a/dmp-admin/src/app/models/DataSetProfile/DatasetProfileModel.ts +++ b/dmp-admin/src/app/models/DataSetProfile/DatasetProfileModel.ts @@ -1,5 +1,5 @@ import { BaseModel } from '../BaseModel'; -import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; +import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; import { FormGenerator } from '../interfaces/FormGenerator'; import { JsonSerializer } from 'app/utilities/JsonSerializer'; import { Section } from './Section'; @@ -30,13 +30,13 @@ export class DatasetProfileModel extends BaseModel implements Serializable(); - this.pages.forEach(item => { - let form: FormGroup = item.buildForm(); - pagesFormArray.push(form) - }) + // this.pages.forEach(item => { + // let form: FormGroup = item.buildForm(); + // pagesFormArray.push(form) + // }) formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); - formGroup.addControl('label', new FormControl(this.label)); + formGroup.addControl('label', new FormControl(this.label, [Validators.required])); return formGroup; } diff --git a/dmp-admin/src/app/models/DataSetProfile/Field.ts b/dmp-admin/src/app/models/DataSetProfile/Field.ts index f74d1aba8..9b10791cc 100644 --- a/dmp-admin/src/app/models/DataSetProfile/Field.ts +++ b/dmp-admin/src/app/models/DataSetProfile/Field.ts @@ -17,13 +17,10 @@ export class Field extends BaseModel implements Serializable,FormGenerato public id:string; public title:string; - public defaultValue:DefaultValue = new DefaultValue; - public description:string; - public extendedDescription:string; + public defaultValue:DefaultValue = new DefaultValue; public viewStyle:ViewStyle = new ViewStyle(); - public defaultVisibility:boolean; public page:number; - public multiplicity: Multiplicity = new Multiplicity(); + //public multiplicity: Multiplicity = new Multiplicity(); public ordinal: number; public visible: Visibility = new Visibility(); public data:DataField; @@ -31,12 +28,9 @@ export class Field extends BaseModel implements Serializable,FormGenerato fromJSONObject(item:any):Field{ this.id = item.id; this.title = item.title; - this.defaultValue = new JsonSerializer().fromJSONObject(item.defaultValue, DefaultValue); - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.defaultVisibility = item.defaultVisibility !==null ? item.defaultVisibility : true; + this.defaultValue = new JsonSerializer().fromJSONObject(item.defaultValue, DefaultValue); this.page = item.page; - this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); + // this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); this.ordinal = item.ordinal; this.viewStyle = new JsonSerializer().fromJSONObject(item.viewStyle, ViewStyle); this.visible = new JsonSerializer().fromJSONObject(item.visible, Visibility); @@ -54,23 +48,18 @@ export class Field extends BaseModel implements Serializable,FormGenerato buildForm():FormGroup{ let formGroup = this.formBuilder.group({ id: [this.id], - title: [this.title], - description: [this.description], - extendedDescription:[this.extendedDescription], - defaultVisibility:[this.defaultVisibility], + title: [this.title], page:[this.page] , ordinal:[this.ordinal] }); - formGroup.addControl("multiplicity", this.multiplicity.buildForm()); + //formGroup.addControl("multiplicity", this.multiplicity.buildForm()); formGroup.addControl("defaultValue", this.defaultValue.buildForm()); formGroup.addControl("viewStyle", this.viewStyle.buildForm()); formGroup.addControl("visible", this.visible.buildForm()); //formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({})); if(this.data)formGroup.addControl("data",this.data.buildForm()); - - if( formGroup.controls["defaultVisibility"].value == null) formGroup.controls["defaultVisibility"].setValue(true); return formGroup; } diff --git a/dmp-admin/src/app/models/DataSetProfile/FieldGroup.ts b/dmp-admin/src/app/models/DataSetProfile/FieldGroup.ts index 18df097c1..bd1369e55 100644 --- a/dmp-admin/src/app/models/DataSetProfile/FieldGroup.ts +++ b/dmp-admin/src/app/models/DataSetProfile/FieldGroup.ts @@ -1,4 +1,4 @@ -import { CompositeField } from './CompositeField'; +import { FieldSet } from './FieldSet'; import { BaseModel } from '../BaseModel'; import { FormGroup } from '@angular/forms'; import { FormGenerator } from '../interfaces/FormGenerator'; @@ -18,7 +18,7 @@ export class FieldGroup extends BaseModel implements Serializable, F public defaultVisibility: boolean; public page: number; public ordinal: number; - public compositeFields: Array = new Array(); + public compositeFields: Array
= new Array
(); fromJSONObject(item: any): FieldGroup { this.id = item.id; @@ -29,7 +29,7 @@ export class FieldGroup extends BaseModel implements Serializable, F this.defaultVisibility = item.defaultVisibility; this.page = item.page; this.ordinal = item.ordinal; - this.compositeFields = new JsonSerializer().fromJSONArray(item.compositeFields, CompositeField); + this.compositeFields = new JsonSerializer
().fromJSONArray(item.compositeFields, FieldSet); return this; } diff --git a/dmp-admin/src/app/models/DataSetProfile/CompositeField.ts b/dmp-admin/src/app/models/DataSetProfile/FieldSet.ts similarity index 70% rename from dmp-admin/src/app/models/DataSetProfile/CompositeField.ts rename to dmp-admin/src/app/models/DataSetProfile/FieldSet.ts index e2d7dfb5b..d17c15fe4 100644 --- a/dmp-admin/src/app/models/DataSetProfile/CompositeField.ts +++ b/dmp-admin/src/app/models/DataSetProfile/FieldSet.ts @@ -5,25 +5,34 @@ import { BaseModel } from '../BaseModel'; import {Field} from './Field' import {Multiplicity} from './Multiplicity' -export class CompositeField extends BaseModel implements Serializable { +export class FieldSet extends BaseModel implements Serializable
{ public fields:Array = new Array(); public id:string; public ordinal:number; public multiplicity: Multiplicity = new Multiplicity(); + public title:string; + public description:string; + public extendedDescription:string; - fromJSONObject(item:any):CompositeField{ + fromJSONObject(item:any):FieldSet{ this.fields = new JsonSerializer().fromJSONArray(item.fields,Field); this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); this.id = item.id; this.ordinal = item.ordinal; + this.title = item.title; + this.description = item.description; + this.extendedDescription = item.extendedDescription; return this; } buildForm():FormGroup{ let formGroup = this.formBuilder.group({ id:[this.id], - ordinal:[this.ordinal] + ordinal:[this.ordinal], + title:[this.title], + description: [this.description], + extendedDescription:[this.extendedDescription] }); let fieldsFormArray = new Array(); diff --git a/dmp-admin/src/app/models/DataSetProfile/Section.ts b/dmp-admin/src/app/models/DataSetProfile/Section.ts index c24365448..e00d85cc9 100644 --- a/dmp-admin/src/app/models/DataSetProfile/Section.ts +++ b/dmp-admin/src/app/models/DataSetProfile/Section.ts @@ -4,26 +4,29 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms' import { JsonSerializer } from 'app/utilities/JsonSerializer'; import { Serializable } from '../interfaces/Serializable'; import { FieldGroup } from './FieldGroup'; +import { FieldSet } from 'app/models/DataSetProfile/FieldSet'; export class Section extends BaseModel implements Serializable
, FormGenerator{ public sections: Array
= new Array
(); - public fieldGroups: Array = new Array(); + //public fieldGroups: Array = new Array(); public defaultVisibility: boolean; public page: number; public id: string public title: string public description: string; public ordinal: number; + public fieldSets: Array
= new Array
(); fromJSONObject(item: any): Section { this.sections = new JsonSerializer
().fromJSONArray(item.sections, Section); - this.fieldGroups = new JsonSerializer().fromJSONArray(item.fieldGroups, FieldGroup); + //this.fieldGroups = new JsonSerializer().fromJSONArray(item.fieldGroups, FieldGroup); this.page = item.page; this.defaultVisibility = item.defaultVisibility; this.id = item.id; this.title = item.title; this.description = item.description; this.ordinal = item.ordinal; + this.fieldSets = new JsonSerializer
().fromJSONArray(item.fieldSets, FieldSet); return this; } @@ -36,15 +39,24 @@ export class Section extends BaseModel implements Serializable
, FormGen sectionsFormArray.push(form) }) } - let fieldGroupsFormArray = new Array(); - if (this.fieldGroups) { - this.fieldGroups.forEach(item => { + // let fieldGroupsFormArray = new Array(); + // if (this.fieldGroups) { + // this.fieldGroups.forEach(item => { + // let form: FormGroup = item.buildForm(); + // fieldGroupsFormArray.push(form) + // }) + // } + let compositeFieldsFormArray = new Array(); + if (this.fieldSets) { + this.fieldSets.forEach(item => { let form: FormGroup = item.buildForm(); - fieldGroupsFormArray.push(form) + compositeFieldsFormArray.push(form) }) } + formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray)); + // formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray)); + formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray)); formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility)); formGroup.addControl('page', new FormControl(this.page, [Validators.required])); formGroup.addControl('id', new FormControl(this.id)); diff --git a/dmp-admin/src/app/services/dataset-profile.service.ts b/dmp-admin/src/app/services/dataset-profile.service.ts index 38a33c85b..3956fa94d 100644 --- a/dmp-admin/src/app/services/dataset-profile.service.ts +++ b/dmp-admin/src/app/services/dataset-profile.service.ts @@ -17,7 +17,7 @@ export class DatasetProfileService implements OnInit { } fetchAllDatasetProfiles(){ - return this.restBase.get("datasetprofile/getAll"); + return this.restBase.get("datasetprofiles/getAll"); } getDatasetProfileById(datasetProfileID){