new http call , fieldgroups
This commit is contained in:
parent
5ef6708efb
commit
8ed421ccfc
|
@ -8065,6 +8065,12 @@
|
||||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
||||||
"dev": true
|
"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": {
|
"string-width": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
"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": {
|
"stringstream": {
|
||||||
"version": "0.0.5",
|
"version": "0.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
"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>
|
||||||
|
|
||||||
<ng-template #otherRuleBlock> <!--to do other rules -->
|
<ng-template #otherRuleBlock>
|
||||||
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
|
|
|
@ -29,4 +29,24 @@ export class DynamicFormFieldComponent {
|
||||||
if(field.visible == true)
|
if(field.visible == true)
|
||||||
return 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 {
|
export class dataModelBuilder {
|
||||||
|
|
||||||
private dataModel : DataModel;
|
private dataModel : DataModel;
|
||||||
|
private fields : FieldBase<any>[];
|
||||||
|
|
||||||
public getDataModel(data){
|
public getDataModel(data){
|
||||||
|
|
||||||
if(this.dataModel != null)
|
if(this.dataModel != null)
|
||||||
return this.dataModel;
|
return this.dataModel;
|
||||||
|
|
||||||
|
let fldGroup = data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup;//one fieldgroup
|
||||||
this.dataModel = new DataModel();
|
this.dataModel = new DataModel();
|
||||||
this.dataModel.fields = this.getFieldVisibility(data.dataset.profile.viewstyle.definition.root.fields.field);
|
//this.dataModel.fields = this.getFieldVisibility(data.dataset.profile.viewstyle.definition.root.fields.field);
|
||||||
this.dataModel.groups =
|
this.fields = this.buildFields(data.dataset.profile.viewstyle.definition.root.fields.field);
|
||||||
//this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, this.dataModel.fields);
|
this.dataModel.groups = this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, fldGroup, this.fields);
|
||||||
this.getDummyGroups();
|
//this.getDummyGroups();
|
||||||
|
|
||||||
return this.dataModel;
|
return this.dataModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private getFieldVisibility(fields:any[]) {
|
private buildFields(fields:any[]) {
|
||||||
console.log(fields);
|
console.log(fields);
|
||||||
let fieldsVisible :FieldBase<any>[] =[];
|
let fieldsVisible :FieldBase<any>[] =[];
|
||||||
fields.forEach(element => {
|
fields.forEach(element => {
|
||||||
if (element.viewStyle._renderstyle == "freetext"){
|
if (element.viewStyle._renderstyle == "freetext"){
|
||||||
let newfield:FieldBase <any>;
|
let newfield:FieldBase <any>;
|
||||||
let rule = new Rule();
|
let rule = new Rule();
|
||||||
//rule.target = element.visible.rule._target;
|
|
||||||
//rule.ruleType = element.visible.rule._type;
|
|
||||||
newfield = new TextboxField({
|
newfield = new TextboxField({
|
||||||
label: element._attribute,
|
label: element.title.__cdata,
|
||||||
key:element.title._id,
|
key:element._id,
|
||||||
value: 'DMP1',
|
value: 'DMP1',
|
||||||
required: true,
|
required: true,
|
||||||
ordinal:element._ordinal,
|
order:element._ordinal,
|
||||||
rules: new Array(),
|
rules: new Array(),
|
||||||
visible: true,
|
visible: element._defaultVisibility,
|
||||||
group : element._group
|
group : element._group
|
||||||
});
|
});
|
||||||
if (element.visible.rule)
|
if (element.visible.rule)
|
||||||
|
@ -58,34 +58,34 @@ export class dataModelBuilder {
|
||||||
|
|
||||||
fieldsVisible.push(newfield);
|
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 newfield:DropdownField;
|
||||||
let rule = new Rule();
|
let rule = new Rule();
|
||||||
//rule.target = element.visible.rule._target;
|
|
||||||
//rule.ruleType = element.visible.rule._type;
|
|
||||||
newfield = new DropdownField({
|
newfield = new DropdownField({
|
||||||
label: element._attribute,
|
label: element.title.__cdata,
|
||||||
key:element.title._id,
|
key:element._id,
|
||||||
value: 'DMP1',
|
value: 'DMP1',
|
||||||
required: true,
|
required: true,
|
||||||
ordinal:element._ordinal,
|
order:element._ordinal,
|
||||||
rule: element.visible.rule,
|
rule: element.visible.rule,
|
||||||
visible: true
|
visible: element._defaultVisibility,
|
||||||
|
group : element._group
|
||||||
});
|
});
|
||||||
fieldsVisible.push(newfield);
|
fieldsVisible.push(newfield);
|
||||||
}
|
}
|
||||||
else if (element.viewStyle._renderstyle == "checkbox"){
|
else if (element.viewStyle._renderstyle == "checkbox"||element.viewStyle._renderstyle == "checkBox"){
|
||||||
let newfield:CheckBoxField;
|
let newfield:CheckBoxField;
|
||||||
//rule.target = element.visible.rule._target;
|
let rule = new Array<Rule>();
|
||||||
//rule.ruleType = element.visible.rule._type;
|
|
||||||
newfield = new CheckBoxField({
|
newfield = new CheckBoxField({
|
||||||
label: element._attribute,
|
label: element.title.__cdata,
|
||||||
key:element._id,
|
key:element._id,
|
||||||
value: true,
|
value: true,
|
||||||
required: true,
|
required: true,
|
||||||
ordinal:element._ordinal,
|
order:element._ordinal,
|
||||||
rule: element.visible.rule,
|
rule: element.visible.rule != undefined ? element.visible.rule: rule,
|
||||||
visible: true
|
visible: element._defaultVisibility,
|
||||||
|
group : element._group,
|
||||||
|
type: "checkbox"
|
||||||
});
|
});
|
||||||
fieldsVisible.push(newfield);
|
fieldsVisible.push(newfield);
|
||||||
}
|
}
|
||||||
|
@ -94,20 +94,32 @@ export class dataModelBuilder {
|
||||||
return fieldsVisible;
|
return fieldsVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getGroups(fieldGroups:any[], fields:any[]){
|
private getGroups(fieldGroups:any[], fldGroup, fields:any[]){
|
||||||
let groups :GroupBase<any>[] =[];
|
let groups :GroupBase<any>[] =[];
|
||||||
|
|
||||||
fieldGroups.forEach(fieldGroup =>{
|
|
||||||
let newfldGroup = new GroupBase();
|
let newfldGroup = new GroupBase();
|
||||||
newfldGroup.groupFields = new Array();
|
newfldGroup.groupFields = new Array();
|
||||||
|
|
||||||
|
if(fieldGroups.length>1)
|
||||||
|
fieldGroups.forEach(fieldGroup =>{
|
||||||
fields.forEach(field => {
|
fields.forEach(field => {
|
||||||
if(fieldGroup._id == field.group){
|
if(fieldGroup._id == field.group){
|
||||||
newfldGroup.groupFields.push(field);
|
newfldGroup.groupFields.push(field);
|
||||||
}
|
}else
|
||||||
|
this.dataModel.fields.push(field);
|
||||||
});
|
});
|
||||||
newfldGroup.title = fieldGroup.title.__cdata;
|
newfldGroup.title = fieldGroup.title.__cdata;
|
||||||
groups.push(newfldGroup)
|
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;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ export class ServerService {
|
||||||
|
|
||||||
xml2jsonOBJ: any;
|
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/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';
|
//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