new http call , fieldgroups
This commit is contained in:
parent
5ef6708efb
commit
8ed421ccfc
|
@ -8065,6 +8065,12 @@
|
|||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
||||
"dev": true
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
||||
|
@ -8092,12 +8098,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
||||
"dev": true
|
||||
},
|
||||
"stringstream": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
[hidden] { display: none ;}
|
||||
.hide{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.show {
|
||||
display:block;
|
||||
}
|
|
@ -82,7 +82,7 @@
|
|||
|
||||
</ng-template>
|
||||
|
||||
<ng-template #otherRuleBlock> <!--to do other rules -->
|
||||
<ng-template #otherRuleBlock>
|
||||
|
||||
</ng-template>
|
||||
|
||||
|
|
|
@ -29,4 +29,24 @@ export class DynamicFormFieldComponent {
|
|||
if(field.visible == true)
|
||||
return true;
|
||||
}
|
||||
FieldValueRuleMethod(field, rule, dataModel){ //fieldValue rule -- checks the value of target
|
||||
if (rule._ruleStyle == "range"){
|
||||
dataModel.fields.forEach(fld => {
|
||||
if (fld.key == rule._target && rule._from< fld.value <rule._to){
|
||||
console.log("visible"+ fld.value)
|
||||
field.visible = true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleVisibility(e, field){
|
||||
console.log(this.dataModel.groups.find(x => x.order === field.group));
|
||||
console.log(this.dataModel);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -11,39 +11,39 @@ import { GroupBase } from '../form/dynamic-form-group/group-base';
|
|||
export class dataModelBuilder {
|
||||
|
||||
private dataModel : DataModel;
|
||||
|
||||
private fields : FieldBase<any>[];
|
||||
|
||||
public getDataModel(data){
|
||||
|
||||
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.dataModel.groups =
|
||||
//this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, this.dataModel.fields);
|
||||
this.getDummyGroups();
|
||||
//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.getDummyGroups();
|
||||
|
||||
return this.dataModel;
|
||||
}
|
||||
|
||||
|
||||
private getFieldVisibility(fields:any[]) {
|
||||
private buildFields(fields:any[]) {
|
||||
console.log(fields);
|
||||
let fieldsVisible :FieldBase<any>[] =[];
|
||||
fields.forEach(element => {
|
||||
if (element.viewStyle._renderstyle == "freetext"){
|
||||
let newfield:FieldBase <any>;
|
||||
let rule = new Rule();
|
||||
//rule.target = element.visible.rule._target;
|
||||
//rule.ruleType = element.visible.rule._type;
|
||||
newfield = new TextboxField({
|
||||
label: element._attribute,
|
||||
key:element.title._id,
|
||||
label: element.title.__cdata,
|
||||
key:element._id,
|
||||
value: 'DMP1',
|
||||
required: true,
|
||||
ordinal:element._ordinal,
|
||||
order:element._ordinal,
|
||||
rules: new Array(),
|
||||
visible: true,
|
||||
visible: element._defaultVisibility,
|
||||
group : element._group
|
||||
});
|
||||
if (element.visible.rule)
|
||||
|
@ -58,34 +58,34 @@ export class dataModelBuilder {
|
|||
|
||||
fieldsVisible.push(newfield);
|
||||
}
|
||||
else if (element.viewStyle._renderstyle == "combobox"){
|
||||
else if (element.viewStyle._renderstyle == "dropdown" ||element.viewStyle._renderstyle == "combobox"){//to choose one of these in xml
|
||||
let newfield:DropdownField;
|
||||
let rule = new Rule();
|
||||
//rule.target = element.visible.rule._target;
|
||||
//rule.ruleType = element.visible.rule._type;
|
||||
newfield = new DropdownField({
|
||||
label: element._attribute,
|
||||
key:element.title._id,
|
||||
label: element.title.__cdata,
|
||||
key:element._id,
|
||||
value: 'DMP1',
|
||||
required: true,
|
||||
ordinal:element._ordinal,
|
||||
order:element._ordinal,
|
||||
rule: element.visible.rule,
|
||||
visible: true
|
||||
visible: element._defaultVisibility,
|
||||
group : element._group
|
||||
});
|
||||
fieldsVisible.push(newfield);
|
||||
}
|
||||
else if (element.viewStyle._renderstyle == "checkbox"){
|
||||
else if (element.viewStyle._renderstyle == "checkbox"||element.viewStyle._renderstyle == "checkBox"){
|
||||
let newfield:CheckBoxField;
|
||||
//rule.target = element.visible.rule._target;
|
||||
//rule.ruleType = element.visible.rule._type;
|
||||
let rule = new Array<Rule>();
|
||||
newfield = new CheckBoxField({
|
||||
label: element._attribute,
|
||||
label: element.title.__cdata,
|
||||
key:element._id,
|
||||
value: true,
|
||||
required: true,
|
||||
ordinal:element._ordinal,
|
||||
rule: element.visible.rule,
|
||||
visible: true
|
||||
order:element._ordinal,
|
||||
rule: element.visible.rule != undefined ? element.visible.rule: rule,
|
||||
visible: element._defaultVisibility,
|
||||
group : element._group,
|
||||
type: "checkbox"
|
||||
});
|
||||
fieldsVisible.push(newfield);
|
||||
}
|
||||
|
@ -94,20 +94,32 @@ export class dataModelBuilder {
|
|||
return fieldsVisible;
|
||||
}
|
||||
|
||||
private getGroups(fieldGroups:any[], fields:any[]){
|
||||
private getGroups(fieldGroups:any[], fldGroup, fields:any[]){
|
||||
let groups :GroupBase<any>[] =[];
|
||||
let newfldGroup = new GroupBase();
|
||||
newfldGroup.groupFields = new Array();
|
||||
|
||||
fieldGroups.forEach(fieldGroup =>{
|
||||
let newfldGroup = new GroupBase();
|
||||
newfldGroup.groupFields = new Array();
|
||||
fields.forEach(field => {
|
||||
if(fieldGroup._id == field.group){
|
||||
newfldGroup.groupFields.push(field);
|
||||
}
|
||||
});
|
||||
newfldGroup.title = fieldGroup.title.__cdata;
|
||||
groups.push(newfldGroup)
|
||||
});
|
||||
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;
|
||||
groups.push(newfldGroup)
|
||||
});
|
||||
else{
|
||||
fields.forEach(field => {
|
||||
if(fldGroup._id == field.group){
|
||||
newfldGroup.groupFields.push(field);
|
||||
}else
|
||||
this.dataModel.fields.push(field);
|
||||
});
|
||||
newfldGroup.title = fldGroup.title.__cdata;
|
||||
groups.push(newfldGroup)
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ 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/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';//include rules!
|
||||
fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/ccae5e6b-61e5-42b2-ac46-b720770c8148';//include sections!
|
||||
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364';
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
Loading…
Reference in New Issue