diff --git a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html index eb1141ace..8f015d75e 100644 --- a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html @@ -30,7 +30,8 @@
- +
{{field.description}}
+ @@ -41,7 +42,7 @@ - +
@@ -50,11 +51,9 @@
-
- + - - + diff --git a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.ts b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.ts index 856eee33e..dd2dce4ba 100644 --- a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.ts +++ b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.ts @@ -58,8 +58,7 @@ export class DynamicFormFieldComponent { } } - toggleVisibility(e, field, ckb){ - console.log(field);debugger; + toggleVisibility(e, field, ckb){ //ckb the checkbox only send this parameter, it's essential to change the field value if(ckb) field.value = ckb.checked; field.rules.forEach(rule => { diff --git a/dmp-frontend/src/app/form/fields/field-base.ts b/dmp-frontend/src/app/form/fields/field-base.ts index 2d6012b50..bdead23b9 100644 --- a/dmp-frontend/src/app/form/fields/field-base.ts +++ b/dmp-frontend/src/app/form/fields/field-base.ts @@ -9,6 +9,7 @@ export class FieldBase{ visible: boolean; controlType:string; group:string; + description:string; constructor(options: { value?: T, @@ -20,6 +21,7 @@ export class FieldBase{ visible?: boolean, controlType?: string group?: string + description?: string, } = {}) { this.value = options.value; this.key = options.key || ''; @@ -30,5 +32,6 @@ export class FieldBase{ this.visible = options.visible; this.controlType = options.controlType || ''; this.group = options.group || ''; + this.description = options.description || ''; } } \ No newline at end of file diff --git a/dmp-frontend/src/app/services/dataModelBuilder.service.ts b/dmp-frontend/src/app/services/dataModelBuilder.service.ts index 657f392f4..86e4c6b95 100644 --- a/dmp-frontend/src/app/services/dataModelBuilder.service.ts +++ b/dmp-frontend/src/app/services/dataModelBuilder.service.ts @@ -19,11 +19,10 @@ export class dataModelBuilder { if(this.dataModel != null) return this.dataModel; - let fldGroup = data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup;//one fieldgroup this.dataModel = new DataModel(); //this.dataModel.fields = this.getFieldVisibility(data.dataset.profile.viewstyle.definition.root.fields.field); this.fields = this.buildFields(data.dataset.profile.viewstyle.definition.root.fields.field); - this.dataModel.groups = this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, fldGroup, this.fields); + this.dataModel.groups = this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, this.fields); //this.getDummyGroups(); this.dataModel.buildIndex(); @@ -41,7 +40,7 @@ export class dataModelBuilder { newfield = new TextboxField({ label: element.title.__cdata, key:element._id, - value: 'DMP1', + value: element.value, required: true, order:element._ordinal, rules: element.visible.rule != undefined ? element.visible.rule: rule, @@ -57,7 +56,7 @@ export class dataModelBuilder { newfield = new DropdownField({ label: element.title.__cdata, key:element._id, - value: 'DMP1', + value: element.value, required: true, order:element._ordinal, rules: element.visible.rule != undefined ? element.visible.rule: rule, @@ -95,6 +94,7 @@ export class dataModelBuilder { visible: element._defaultVisibility, group : element._group, type: "radio", + description: element.description.__cdata, answers: [ { id: 1, @@ -114,31 +114,38 @@ export class dataModelBuilder { return fieldsVisible; } - private getGroups(fieldGroups:any[], fldGroup, fields:any[]){ - let groups :GroupBase[] =[]; - let newfldGroup = new GroupBase(); - newfldGroup.groupFields = new Array(); - if(fieldGroups.length>1) - fieldGroups.forEach(fieldGroup =>{ - fields.forEach(field => { - if(fieldGroup._id == field.group){ - newfldGroup.groupFields.push(field); - }else - this.dataModel.fields.push(field); - }); - newfldGroup.title = fieldGroup.title.__cdata; - newfldGroup.key = fldGroup._id; - groups.push(newfldGroup) - }); + private getGroups(fieldGroups:any, fields:any[]){ + let groups :GroupBase[] =[]; + + if(fieldGroups.length>1){ + fieldGroups.forEach(fieldGroup =>{ // each fiedgroup fills with its fields from json + let newfldGroup = new GroupBase(); + newfldGroup.groupFields = new Array(); + fields.forEach(field => { + if(fieldGroup._id == field.group){ + newfldGroup.groupFields.push(field); + }else{ + //this.dataModel.fields.push(field); + } + + }); + newfldGroup.title = fieldGroup.title.__cdata; + newfldGroup.key = fieldGroup._id; + groups.push(newfldGroup) + }); + } + else{ - fields.forEach(field => { - if(fldGroup._id == field.group){ + let newfldGroup = new GroupBase(); + newfldGroup.groupFields = new Array(); + fields.forEach(field => { //for one fieldgroup, beacouse xml to json transformation doesn't create array of one fieldfroup + if(fieldGroups._id == field.group){ newfldGroup.groupFields.push(field); }else this.dataModel.fields.push(field); }); - newfldGroup.title = fldGroup.title.__cdata; - newfldGroup.key = fldGroup._id; + newfldGroup.title = fieldGroups.title.__cdata; + newfldGroup.key = fieldGroups._id; groups.push(newfldGroup) } return groups; diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 8283562d0..056be452c 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -19,7 +19,7 @@ export class ServerService { xml2jsonOBJ: any; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a868dbbb-ee37-4ce6-81c8-27048e0599a9'; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';//include rules! - fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d619d418-88be-4f2c-9dcc-db7ad4fc60b3';//include sections! + fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d597c26e-3d8b-416a-bc07-1734d68c79c9';//'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d619d418-88be-4f2c-9dcc-db7ad4fc60b3';//include sections! //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364'; /*