Toc improvements, visibility rules
This commit is contained in:
parent
6c0d9946ee
commit
51db10bd8b
|
@ -33,7 +33,7 @@
|
||||||
<div>{{field.description}}</div>
|
<div>{{field.description}}</div>
|
||||||
|
|
||||||
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
||||||
[(ngModel)]="field.value" [required]="field.required" [pattern] = "field.regex">
|
[(ngModel)]="field.value" [required]="field.required" [pattern] = "field.regex" (blur) = "toggleVisibility($event, field)">
|
||||||
|
|
||||||
<select [id]="field.key" *ngSwitchCase="'dropdown'" class="form-control"[formControlName]="field.key" [(ngModel)]="field.value" [required]="field.required">
|
<select [id]="field.key" *ngSwitchCase="'dropdown'" class="form-control"[formControlName]="field.key" [(ngModel)]="field.value" [required]="field.required">
|
||||||
<option *ngFor="let opt of field.options" [value]="opt.key">{{opt.value}}</option>
|
<option *ngFor="let opt of field.options" [value]="opt.key">{{opt.value}}</option>
|
||||||
|
|
|
@ -79,17 +79,36 @@ export class DynamicFormFieldComponent {
|
||||||
this.dataModel.getFieldByKey(rule._target).visible = false;
|
this.dataModel.getFieldByKey(rule._target).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (rule._ruleStyle == "existence") {
|
||||||
|
if (field.visible == "true" || field.visible == true) {
|
||||||
|
this.dataModel.getFieldByKey(rule._target).visible = true;
|
||||||
|
this.AddvalidationRules(rule._target);
|
||||||
|
} else {
|
||||||
|
this.dataModel.getFieldByKey(rule._target).visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rule._ruleStyle == "regex") {
|
||||||
|
if (new RegExp(rule.__cdata).test(field.value)) {
|
||||||
|
this.dataModel.getFieldByKey(rule._target).visible = true;
|
||||||
|
this.AddvalidationRules(rule._target);
|
||||||
|
} else {
|
||||||
|
this.dataModel.getFieldByKey(rule._target).visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleVisibility(e, field, ckb) { //ckb the checkbox only send this parameter, it's essential to change the field value
|
toggleVisibility(e, field, ckb) { //ckb the checkbox only send this parameter, it's essential to change the field value
|
||||||
if (ckb)
|
if (ckb)
|
||||||
field.value = ckb.checked;
|
field.value = ckb.checked;
|
||||||
field.rules.forEach(rule => {
|
if(field.rules.length != undefined && field.rules.length > 1)
|
||||||
if (rule._type == "fieldValue") {
|
field.rules.forEach(rule => {
|
||||||
this.FieldValueRuleMethod(field, rule);
|
if (rule._type == "fieldValue") {
|
||||||
}
|
this.FieldValueRuleMethod(field, rule);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
else if(field.rules._type == "fieldValue"){
|
||||||
|
this.FieldValueRuleMethod(field,field.rules);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddvalidationRules(field) {
|
AddvalidationRules(field) {
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
<body data-spy="scroll" data-target="#toc">
|
<body data-spy="scroll" data-target="#toc">
|
||||||
<nav id="toc" data-toggle="toc">
|
<nav id="toc" data-toggle="toc">
|
||||||
<ul class="nav flex-column">
|
<ul class="nav flex-column">
|
||||||
<li class="nav-item" >
|
<li class="nav-item">
|
||||||
<a class="nav-link" *ngFor ="let group of dataModel.groups" href="#group.key">{{group.title}}</a>
|
<div *ngFor="let group of dataModel.groups">
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-link" href="#group.key">{{group.title}}</a>
|
||||||
|
<ul *ngFor="let field of group.groupFields">
|
||||||
|
<li *ngIf= "field.visible == 'true'" >
|
||||||
|
<a class="nav-link" href="#field.key">{{field.label}}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue