comment field
This commit is contained in:
parent
067e0528dc
commit
dcf0c5ca87
|
@ -1,4 +1,4 @@
|
|||
<div *ngIf="visibilityRulesService.isElementVisible(pathName,compositeField.id)" [id]="compositeField.id" [formGroup]="form">
|
||||
<div [id]="compositeField.id" [formGroup]="form">
|
||||
|
||||
<h5 *ngIf="compositeField.title">{{compositeField.title}}</h5>
|
||||
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
|
||||
|
|
|
@ -21,12 +21,22 @@ export class DynamicFormCompositeFieldComponent implements OnInit {
|
|||
|
||||
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
||||
|
||||
ngOnInit() {debugger;
|
||||
ngOnInit() {
|
||||
debugger;
|
||||
console.log(this.form);
|
||||
if (this.compositeField.hasCommentField == true) {
|
||||
let newfield: Field = new Field();
|
||||
newfield.id = 'comment_' + this.compositeField.id;
|
||||
newfield.data = {label: "Comments"};
|
||||
newfield.viewStyle = {renderStyle: 'freetext', cssClass: ''};
|
||||
|
||||
this.compositeField.fields.push(newfield);
|
||||
(<FormArray>this.form.get("fields")).push(newfield.buildForm());
|
||||
}
|
||||
}
|
||||
|
||||
addMultipleField(fieldIndex: number) {
|
||||
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex,"");
|
||||
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, "");
|
||||
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
||||
(<FormArray>(this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
|
||||
}
|
||||
|
|
|
@ -53,17 +53,17 @@
|
|||
</div> -->
|
||||
|
||||
<div *ngFor="let compositeField of section.compositeFields; let i = index;">
|
||||
<div *ngIf="visibilityRulesService.isElementVisible(null,compositeField.id)">
|
||||
<div *ngIf="visibilityRulesService.isElementVisible(pathName+'.compositeFields.'+i,compositeField.id)">
|
||||
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
|
||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||
Add one more fieldset +
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index;">
|
||||
<df-composite-field [compositeField]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index;">
|
||||
<df-composite-field [compositeField]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { Section } from '../../entities/model/section';
|
||||
import { FormGroup, Form, FormArray } from '@angular/forms';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { CompositeField } from '@app/models/CompositeField';
|
||||
import { Section } from '@app/models/Section';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'df-section',
|
||||
templateUrl: './dynamic-form-section.html',
|
||||
|
@ -21,4 +24,11 @@ export class DynamicFormSectionComponent implements OnInit {
|
|||
ngOnInit() {
|
||||
console.log(this.section);
|
||||
}
|
||||
|
||||
addMultipleField(fieldsetIndex: number) {
|
||||
let compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
|
||||
this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
|
||||
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
|||
public title: string
|
||||
public description: string
|
||||
public extendedDescription: string
|
||||
public hasCommentField: boolean;
|
||||
|
||||
fromJSONObject(item: any): CompositeField {
|
||||
|
||||
|
@ -22,6 +23,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
|||
this.title = item.title;
|
||||
this.description = item.description;
|
||||
this.extendedDescription = item.extendedDescription;
|
||||
this.hasCommentField = item.hasCommentField;
|
||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||
//this.multiplicity = new Multiplicity();
|
||||
//this.multiplicity.max = 2;
|
||||
|
@ -35,7 +37,8 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
|||
ordinal: this.ordinal,
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
extendedDescription: this.extendedDescription
|
||||
extendedDescription: this.extendedDescription,
|
||||
hasCommentField: this.hasCommentField
|
||||
});
|
||||
|
||||
let fieldsFormArray = new Array<FormGroup>();
|
||||
|
|
|
@ -5,6 +5,8 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
|
|||
import { Serializable } from './interfaces/Serializable';
|
||||
import { Multiplicity } from './Multiplicity';
|
||||
import { DefaultValue } from './DefaultValue';
|
||||
import { ValidationTypes } from '@app/models/common/ValidationTypes';
|
||||
|
||||
export class Field extends BaseModel implements Serializable<Field>, FormGenerator<FormGroup>{
|
||||
|
||||
public id: string;
|
||||
|
@ -13,12 +15,13 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
|||
public defaultValue: DefaultValue;
|
||||
public description: string;
|
||||
public extendedDescription: string;
|
||||
public viewStyle: string;
|
||||
public viewStyle: any;
|
||||
public defaultVisibility: boolean;
|
||||
public page: number;
|
||||
public multiplicity: Multiplicity;
|
||||
public multiplicityItems: Array<Field> = new Array<Field>();
|
||||
public data: any;
|
||||
public validations: Array<ValidationTypes>;
|
||||
|
||||
fromJSONObject(item: any): Field {
|
||||
this.id = item.id;
|
||||
|
@ -29,6 +32,7 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
|||
this.viewStyle = item.viewStyle;
|
||||
this.defaultVisibility = item.defaultVisibility;
|
||||
this.page = item.page;
|
||||
this.validations = item.validations;
|
||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
||||
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export enum ValidationTypes {
|
||||
None = 0,
|
||||
Required = 1
|
||||
}
|
Loading…
Reference in New Issue