3 fieldgroups, description, modelbuilder fixes
This commit is contained in:
parent
5c66c65bdf
commit
d6a4ba6fec
|
@ -30,7 +30,8 @@
|
|||
<div [ngClass]="{true:'show', false:'hide'}[field.visible]">
|
||||
|
||||
<label [attr.for]="field.key">{{field.label}}</label>
|
||||
|
||||
<div>{{field.description}}</div>
|
||||
|
||||
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
||||
required="field.required" [(ngModel)]="field.value">
|
||||
|
||||
|
@ -41,7 +42,7 @@
|
|||
<input *ngSwitchCase="'checkbox'" class="form-check" [formControlName]="field.key" [(ngModel)]="field.value" [id]="field.key" [type]="field.type"
|
||||
(change)="toggleVisibility($event, field, ckb)" #ckb> <!--(change)="field.value = ckb.checked"-->
|
||||
|
||||
|
||||
|
||||
|
||||
<div *ngSwitchCase="'radiobox'">
|
||||
<ng-container *ngFor="let answrBase of field.answers">
|
||||
|
@ -50,11 +51,9 @@
|
|||
<input type="radio" [formControlName]="field.key" [id]= "answrBase.id" [value]= "answrBase" [(ngModel)]="field.value" (change) = "toggleVisibility($event, field)"/>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -9,6 +9,7 @@ export class FieldBase<T>{
|
|||
visible: boolean;
|
||||
controlType:string;
|
||||
group:string;
|
||||
description:string;
|
||||
|
||||
constructor(options: {
|
||||
value?: T,
|
||||
|
@ -20,6 +21,7 @@ export class FieldBase<T>{
|
|||
visible?: boolean,
|
||||
controlType?: string
|
||||
group?: string
|
||||
description?: string,
|
||||
} = {}) {
|
||||
this.value = options.value;
|
||||
this.key = options.key || '';
|
||||
|
@ -30,5 +32,6 @@ export class FieldBase<T>{
|
|||
this.visible = options.visible;
|
||||
this.controlType = options.controlType || '';
|
||||
this.group = options.group || '';
|
||||
this.description = options.description || '';
|
||||
}
|
||||
}
|
|
@ -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<any>[] =[];
|
||||
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<any>[] =[];
|
||||
|
||||
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;
|
||||
|
|
|
@ -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';
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue