visibility changes

This commit is contained in:
Efstratios Giannopoulos 2024-03-29 16:53:47 +02:00
parent aa6768e67d
commit c0aa671337
1 changed files with 11 additions and 12 deletions

View File

@ -453,7 +453,7 @@ export class VisibilityRulesService {
}
private hideParentIfAllChildrenAreHidden(propertyDefinition: DescriptionPropertyDefinitionPersist) {
if (this.definition?.pages == null) return;
if (this.definition?.pages == null || this.definition?.pages.length == 0) return;
for (let i = 0; i < this.definition?.pages.length; i++) {
const pageEntity = this.definition?.pages[i];
const fieldKey = this.buildVisibilityKey(pageEntity.id, null);
@ -467,7 +467,7 @@ export class VisibilityRulesService {
private isHiddenPageVisibilityIfAllChildrenIsHidden(pageEntity: DescriptionTemplatePage, propertyDefinition: DescriptionPropertyDefinitionPersist): boolean{
let isHidden = true;
if (pageEntity?.sections == null) return;
if (pageEntity?.sections == null || pageEntity?.sections.length == 0) return false;
for (let i = 0; i < pageEntity.sections.length; i++) {
const sectionEntity = pageEntity.sections[i];
const fieldKey = this.buildVisibilityKey(sectionEntity.id, null);
@ -480,8 +480,9 @@ export class VisibilityRulesService {
return isHidden;
}
private isHiddenSectionIfAllChildrenIsHidden(sectionEntity: DescriptionTemplateSection, propertyDefinition: DescriptionPropertyDefinitionPersist): boolean{
private isHiddenSectionIfAllChildrenIsHidden(sectionEntity: DescriptionTemplateSection, propertyDefinition: DescriptionPropertyDefinitionPersist): boolean {
let isHidden = true;
if ((sectionEntity.sections == null || sectionEntity?.sections.length == 0) && (sectionEntity.fieldSets == null || sectionEntity?.fieldSets.length == 0)) return false;
if (sectionEntity.sections != null) {
for (let i = 0; i < sectionEntity.sections.length; i++) {
const subSectionEntity = sectionEntity.sections[i];
@ -518,16 +519,14 @@ export class VisibilityRulesService {
private isHiddenFieldSetIfAllChildrenIsHidden(fieldSetEntity: DescriptionTemplateFieldSet, ordinal: number): boolean{
let isHidden = true;
if (fieldSetEntity.fields != null) {
for (let i = 0; i < fieldSetEntity.fields.length; i++) {
const fieldEntity = fieldSetEntity.fields[i];
const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal);
const currentValue: boolean | null = (this._isVisibleMap[fieldKey] ?? true);
isHidden = isHidden && !currentValue;
}
return isHidden;
if (fieldSetEntity?.fields == null || fieldSetEntity?.fields.length == 0) return false;
for (let i = 0; i < fieldSetEntity.fields.length; i++) {
const fieldEntity = fieldSetEntity.fields[i];
const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal);
const currentValue: boolean | null = (this._isVisibleMap[fieldKey] ?? true);
isHidden = isHidden && !currentValue;
}
return true;
return isHidden;
}
private ensureFieldSetVisibility(propertyDefinition: DescriptionPropertyDefinitionPersist) {