composite field
This commit is contained in:
parent
5459a79b6a
commit
1680ebaa0d
|
@ -6822,9 +6822,9 @@
|
|||
}
|
||||
},
|
||||
"primeng": {
|
||||
"version": "5.0.0-rc.0",
|
||||
"resolved": "https://registry.npmjs.org/primeng/-/primeng-5.0.0-rc.0.tgz",
|
||||
"integrity": "sha1-fb5YXppO84emPfSyyR3VbeXpJVI="
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/primeng/-/primeng-4.3.0.tgz",
|
||||
"integrity": "sha1-aH7NHhoVjPDodC78fam5M4zUcMM="
|
||||
},
|
||||
"process": {
|
||||
"version": "0.11.10",
|
||||
|
|
|
@ -13,13 +13,11 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^4.3.6",
|
||||
|
||||
"@angular/common": "^4.3.6",
|
||||
"@angular/compiler": "^4.3.6",
|
||||
"@angular/core": "^4.3.6",
|
||||
"@angular/forms": "^4.3.6",
|
||||
"@angular/http": "^4.3.6",
|
||||
|
||||
"@angular/platform-browser": "^4.3.6",
|
||||
"@angular/platform-browser-dynamic": "^4.3.6",
|
||||
"@angular/router": "^4.3.6",
|
||||
|
|
|
@ -38,6 +38,16 @@ export class DataModel {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
this.groups.forEach((group) => {
|
||||
if (group.compositeFields != undefined){
|
||||
group.compositeFields.groupFields.forEach((field) => {
|
||||
//console.log("groupid: "+group.key + "fieldid:" +field.key);
|
||||
this.fIndex.set(field.key, field);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public getFieldByKey(key){
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.hide{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.show {
|
||||
display:block;
|
||||
}
|
|
@ -1,23 +1,25 @@
|
|||
<div [formGroup]="form" [ngStyle] = "customStyle" [class]="classFromJson" >
|
||||
<h4 [id]= "group.key">{{group.title}}</h4>
|
||||
<div *ngFor="let field of group.groupFields" >
|
||||
<div *ngIf ="group.compositeFields == undefined">
|
||||
|
||||
<df-field [field]="field" [form]="form" [dataModel] = "dataModel"></df-field>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngFor="let field of group.groupFields" > <!--edw akoma den exei oloklirwthei!! -->
|
||||
<div *ngIf ="group.compositeFields != undefined">
|
||||
<div *ngIf ="group.compositeFields != undefined">
|
||||
<div *ngFor="let field of group.compositeFields.groupFields" >
|
||||
<df-field [field]="field" [form]="form" [dataModel] = "dataModel"></df-field>
|
||||
</div>
|
||||
<a (click)="addFieldSet()" style="cursor: default">
|
||||
<div *ngIf="shouldIShow();">
|
||||
<a (click)="addFieldSet(form)" style="cursor: default">
|
||||
Add another fieldSet +
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- class = "form-group" [class]="customStyle" [ngStyle] = "customStyle"-->
|
|
@ -1,8 +1,11 @@
|
|||
import { DataModel } from '../../entities/DataModel';
|
||||
import { GroupBase } from './group-base';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormGroup, Validators } from '@angular/forms';
|
||||
import { FormGroup, Validators, FormControl } from '@angular/forms';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { FieldBase } from '../fields/field-base';
|
||||
import { TextboxField } from '../fields/textbox/field-textbox';
|
||||
import { Rule } from '../../entities/common/rule';
|
||||
|
||||
|
||||
|
||||
|
@ -42,4 +45,36 @@ export class DynamicFormGroupComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
addFieldSet(){
|
||||
debugger;
|
||||
let subgroup: any = {};
|
||||
this.group.compositeFields.groupFields.forEach((field, i )=>{ debugger;
|
||||
this.form.addControl(field.key +"_"+i, new FormControl("") )
|
||||
|
||||
if (field.controlType == "textbox") {
|
||||
let newfield: FieldBase<any>;
|
||||
let rule = new Rule();
|
||||
newfield = new TextboxField({
|
||||
label: field.label+"_"+i,
|
||||
key: field.key +"_"+i,
|
||||
value: "",
|
||||
order: field.order,
|
||||
rules: field.rules,
|
||||
visible: field.visible,
|
||||
group: field.group,
|
||||
description: field.description
|
||||
});
|
||||
this.group.compositeFields.groupFields.push(newfield)
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
shouldIShow(){
|
||||
this.group.compositeFields.groupFields.forEach((field, i )=>{
|
||||
if(field.visible)
|
||||
return true;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -167,10 +167,10 @@ export class dataModelBuilder {
|
|||
compositeFields.groupFields = new Array();
|
||||
fields.forEach(field => {
|
||||
if (fieldGroup._id == field.group) {
|
||||
if (dataValues != "")//--------------------------SET VALUES--------------------------------------------
|
||||
if (dataValues != "")//--------------------------SET VALUES---------------------------------------------------------------------------------------
|
||||
if (dataValues[fieldGroup._id][field.key] != undefined) // to put values in fields
|
||||
field.value = dataValues[fieldGroup._id][field.key].value == undefined ? dataValues[fieldGroup._id][field.key] : dataValues[fieldGroup._id][field.key].value;
|
||||
if(field.order.toString().split(",").length > 1){
|
||||
if(field.order.toString().split(",").length > 1){//--------------Composite Fields Multiplicity --------------------------------------------------
|
||||
compositeFields.groupFields.push(field);
|
||||
newfldGroup.compositeFields = compositeFields;
|
||||
}else
|
||||
|
@ -286,6 +286,7 @@ export class dataModelBuilder {
|
|||
let newAttribute = new Attribute();
|
||||
let multiplicityParam = false;
|
||||
fieldsets.forEach(fieldset => {
|
||||
let multiplicityParam = false;
|
||||
if (fieldset.fields.field.length){
|
||||
if(fieldset.multiplicity._max >1 || fieldset.multiplicity._max == "n")
|
||||
multiplicityParam = true;
|
||||
|
|
|
@ -19,18 +19,18 @@ export class RestBase {
|
|||
|
||||
|
||||
|
||||
protocol: string = "http";
|
||||
/* protocol: string = "http";
|
||||
hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";//
|
||||
port: number = 8080;//8080;//
|
||||
webappname: string = "dmp-backend";//"dmp-backend-new";//
|
||||
webappname: string = "dmp-backend";//"dmp-backend-new";//*/
|
||||
|
||||
|
||||
|
||||
|
||||
// protocol: string = "http";
|
||||
// hostname: string = "dionysus.di.uoa.gr" ;
|
||||
// port: number = 7070;
|
||||
// webappname: string = "dmp-backend";
|
||||
protocol: string = "http";
|
||||
hostname: string = "dionysus.di.uoa.gr" ;
|
||||
port: number = 7070;
|
||||
webappname: string = "dmp-backend";
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue