Fixed Issue With Visibility Service on initial values
This commit is contained in:
parent
7cc9854f11
commit
38d356703a
|
@ -10,8 +10,12 @@ import { Component, Input, ViewEncapsulation, OnInit } from '@angular/core';
|
|||
],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DynamicFieldCheckBoxComponent {
|
||||
export class DynamicFieldCheckBoxComponent implements OnInit {
|
||||
|
||||
@Input() field: Field;
|
||||
@Input() form: FormGroup;
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.form.get('value').value === null) { this.form.get('value').patchValue(false); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
|||
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
||||
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||
//this.multiplicity = new Multiplicity();
|
||||
// if (this.viewStyle.renderStyle === 'checkBox') {
|
||||
// this.value = this.value === 'true';
|
||||
// }
|
||||
if (this.viewStyle.renderStyle === 'checkBox') {
|
||||
this.value = this.value === 'true';
|
||||
}
|
||||
//this.multiplicity.max = 2;
|
||||
if (item.multiplicityItems) { this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field); }
|
||||
this.data = item.data;
|
||||
|
|
|
@ -55,7 +55,7 @@ export class VisibilityRulesService {
|
|||
private evaluateVisibility(visibilityRule: VisibilityRule) {
|
||||
for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) {
|
||||
const pathKey = this.fieldsPathMemory[visibilityRule.sourceVisibilityRules[i].sourceControlId];
|
||||
if (this.formGroup.get(pathKey + '.value') && ((this.formGroup.get(pathKey + '.value').value == null || this.formGroup.get(pathKey + '.value').value == null) || '' + this.formGroup.get(pathKey + '.value').value !== '' + visibilityRule.sourceVisibilityRules[i].sourceControlValue)) {
|
||||
if (this.formGroup.get(pathKey + '.value') && (this.parseValue(this.formGroup.get(pathKey + '.value').value) !== this.parseValue(visibilityRule.sourceVisibilityRules[i].sourceControlValue))) {
|
||||
if (this.formGroup.get(pathKey).parent.get('id')) {
|
||||
if (!this.checkElementVisibility(this.formGroup.get(pathKey).parent.get('id').value)) {
|
||||
const targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId];
|
||||
|
@ -88,20 +88,11 @@ export class VisibilityRulesService {
|
|||
}
|
||||
}
|
||||
|
||||
// deleteFromModel(path: string, obj: any) {
|
||||
// if (!path) return
|
||||
// const _obj = JSON.parse(JSON.stringify(obj));
|
||||
// const keys = path.split('.');
|
||||
|
||||
// keys.reduce((acc, key, index) => {
|
||||
// if (index === keys.length - 1) {
|
||||
// delete acc[key];
|
||||
// return true;
|
||||
// }
|
||||
// return acc[key];
|
||||
// }, _obj);
|
||||
// return _obj;
|
||||
// }
|
||||
parseValue(value: any) {
|
||||
if (typeof value === 'string') {
|
||||
if (value === 'true') { return true; } else if (value === 'false') { return false; } else { return value; }
|
||||
} else { return value; }
|
||||
}
|
||||
|
||||
updateValue(obj, value, path) {
|
||||
let i;
|
||||
|
|
Loading…
Reference in New Issue