visibility changes

This commit is contained in:
Efstratios Giannopoulos 2024-03-27 18:20:49 +02:00
parent d0ad9a8be0
commit eb770ed65e
4 changed files with 58 additions and 60 deletions

View File

@ -23,17 +23,15 @@ public class TransformerProperties {
private final String url; private final String url;
private final String transformerId; private final String transformerId;
private final List<String> codes;
private final String issuerUrl; private final String issuerUrl;
private final String clientId; private final String clientId;
private final String clientSecret; private final String clientSecret;
private final String scope; private final String scope;
@ConstructorBinding @ConstructorBinding
public TransformerSource(String url, String transformerId, List<String> codes, String issuerUrl, String clientId, String clientSecret, String scope) { public TransformerSource(String url, String transformerId, String issuerUrl, String clientId, String clientSecret, String scope) {
this.url = url; this.url = url;
this.transformerId = transformerId; this.transformerId = transformerId;
this.codes = codes;
this.issuerUrl = issuerUrl; this.issuerUrl = issuerUrl;
this.clientId = clientId; this.clientId = clientId;
this.clientSecret = clientSecret; this.clientSecret = clientSecret;
@ -60,10 +58,6 @@ public class TransformerProperties {
return scope; return scope;
} }
public List<String> getCodes() {
return codes;
}
public String getTransformerId() { public String getTransformerId() {
return transformerId; return transformerId;
} }

View File

@ -2,14 +2,12 @@ transformer:
sources: sources:
- url: http://dev04.local.cite.gr:55330/file/docx - url: http://dev04.local.cite.gr:55330/file/docx
transformerId: docx-file-transformer transformerId: docx-file-transformer
codes: [ docx, pdf ]
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE} scope: ${IDP_APIKEY_SCOPE}
- url: http://dev04.local.cite.gr:55330/file/rdajson - url: http://dev04.local.cite.gr:55330/file/rdajson
transformerId: rda-file-transformer transformerId: rda-file-transformer
codes: [ json ]
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}

View File

@ -570,7 +570,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
permissionPerSection => { permissionPerSection => {
const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription); const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription);
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit); this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit);
this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
// this.selectedSystemFields = this.selectedSystemFieldDisabled(); // this.selectedSystemFields = this.selectedSystemFieldDisabled();
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
@ -795,6 +795,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionTemplateService.getSingle(descriptionTemplateId, DescriptionEditorResolver.descriptionTemplateLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(descriptionTemplate => { this.descriptionTemplateService.getSingle(descriptionTemplateId, DescriptionEditorResolver.descriptionTemplateLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(descriptionTemplate => {
this.editorModel.properties = new DescriptionPropertyDefinitionEditorModel(this.editorModel.validationErrorModel).fromModel(null, descriptionTemplate, null); this.editorModel.properties = new DescriptionPropertyDefinitionEditorModel(this.editorModel.validationErrorModel).fromModel(null, descriptionTemplate, null);
this.formGroup.setControl('properties', this.editorModel.buildProperties()); this.formGroup.setControl('properties', this.editorModel.buildProperties());
this.item.descriptionTemplate = descriptionTemplate; this.item.descriptionTemplate = descriptionTemplate;
@ -802,6 +803,8 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
const sectionId = this.item.dmpDescriptionTemplate.sectionId; const sectionId = this.item.dmpDescriptionTemplate.sectionId;
this.item.dmpDescriptionTemplate = this.item.dmp.dmpDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == descriptionTemplate.groupId); this.item.dmpDescriptionTemplate = this.item.dmp.dmpDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == descriptionTemplate.groupId);
this.formGroup.get('dmpDescriptionTemplateId').setValue(this.item.dmpDescriptionTemplate.id); this.formGroup.get('dmpDescriptionTemplateId').setValue(this.item.dmpDescriptionTemplate.id);
if (descriptionTemplate.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
}); });
// this.formGroup.removeControl('descriptionProfileDefinition'); // this.formGroup.removeControl('descriptionProfileDefinition');
// this.getDefinition(profiledId); // this.getDefinition(profiledId);

View File

@ -13,6 +13,7 @@ export class VisibilityRulesService {
private definition: DescriptionTemplateDefinition; private definition: DescriptionTemplateDefinition;
private rulesBySources: Map<String, RuleWithTarget[]> ; private rulesBySources: Map<String, RuleWithTarget[]> ;
public isVisibleMap: { [key: string]: boolean } = null; public isVisibleMap: { [key: string]: boolean } = null;
private _isVisibleMap: { [key: string]: boolean } = null;
constructor( constructor(
protected formService: FormService protected formService: FormService
@ -23,7 +24,7 @@ export class VisibilityRulesService {
this.definition = definition; this.definition = definition;
this.form = form; this.form = form;
this.rulesBySources = null; this.rulesBySources = null;
this.isVisibleMap = null; this._isVisibleMap = null;
this.calculateVisibility(); this.calculateVisibility();
} }
@ -52,12 +53,12 @@ export class VisibilityRulesService {
public reloadVisibility() { public reloadVisibility() {
this.rulesBySources = null; this.rulesBySources = null;
this.isVisibleMap = null; this._isVisibleMap = null;
this.calculateVisibility(); this.calculateVisibility();
} }
private calculateVisibility(){ private calculateVisibility(){
if (this.isVisibleMap != null) return; if (this._isVisibleMap != null) return;
if (this.definition == null || this.form == null) return; if (this.definition == null || this.form == null) return;
this.initRules(); this.initRules();
@ -66,6 +67,7 @@ export class VisibilityRulesService {
this.setDefaultVisibilityForNotCaclucted(); this.setDefaultVisibilityForNotCaclucted();
this.hideParentIfAllChildrenAreHidden(); this.hideParentIfAllChildrenAreHidden();
this.ensureFieldSetVisibility(); this.ensureFieldSetVisibility();
this.isVisibleMap = this._isVisibleMap;
} }
private initRules(){ private initRules(){
@ -176,11 +178,11 @@ export class VisibilityRulesService {
} }
private buildTargetVisibility(){ private buildTargetVisibility(){
this.isVisibleMap = {}; this._isVisibleMap = {};
const propertyDefinition: DescriptionPropertyDefinitionPersist = this.formService.getValue(this.form.getRawValue()) as DescriptionPropertyDefinitionPersist;
this.rulesBySources.forEach((ruleForSource: RuleWithTarget[], ruleForSourceKey: string) => { this.rulesBySources.forEach((ruleForSource: RuleWithTarget[], ruleForSourceKey: string) => {
for (let i = 0; i < ruleForSource.length; i++) { for (let i = 0; i < ruleForSource.length; i++) {
const rule = ruleForSource[i]; const rule = ruleForSource[i];
const propertyDefinition: DescriptionPropertyDefinitionPersist = this.formService.getValue(this.form.value) as DescriptionPropertyDefinitionPersist;
if (propertyDefinition.fieldSets != null) { if (propertyDefinition.fieldSets != null) {
new Map(Object.entries(propertyDefinition.fieldSets)).forEach((propertyDefinitionFieldSet: DescriptionPropertyDefinitionFieldSetPersist, propertyDefinitionFieldSetKey: string) => { new Map(Object.entries(propertyDefinition.fieldSets)).forEach((propertyDefinitionFieldSet: DescriptionPropertyDefinitionFieldSetPersist, propertyDefinitionFieldSetKey: string) => {
if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) { if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) {
@ -192,21 +194,22 @@ export class VisibilityRulesService {
if (new Map(Object.entries(definitionFieldSetItem.fields)).has(rule.target)){ //Rule applies only for current multiple item if (new Map(Object.entries(definitionFieldSetItem.fields)).has(rule.target)){ //Rule applies only for current multiple item
const fieldKey = this.buildVisibilityKey(rule.target, definitionFieldSetItem.ordinal); const fieldKey = this.buildVisibilityKey(rule.target, definitionFieldSetItem.ordinal);
const currentState = this.isVisibleMap[fieldKey] ?? false; const currentState = this._isVisibleMap[fieldKey] ?? false;
this.isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field); this._isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field);
//console.log(fieldKey + " " + this._isVisibleMap[fieldKey] + " " + field.textListValue);
} else if (this.getDescriptionTemplateDefinitionFieldById(this.definition, rule.target).length > 0 || this.getDescriptionTemplateDefinitionFieldSetById(this.definition, rule.target).length > 0) { //Rule applies to different fieldset, so we apply for all multiple items } else if (this.getDescriptionTemplateDefinitionFieldById(this.definition, rule.target).length > 0 || this.getDescriptionTemplateDefinitionFieldSetById(this.definition, rule.target).length > 0) { //Rule applies to different fieldset, so we apply for all multiple items
const ordinals: number[] = this.getKeyOrdinals(rule.target, propertyDefinition); const ordinals: number[] = this.getKeyOrdinals(rule.target, propertyDefinition);
for (let k = 0; k < ordinals.length; k++) { for (let k = 0; k < ordinals.length; k++) {
const ordinal = ordinals[j]; const ordinal = ordinals[j];
const fieldKey = this.buildVisibilityKey(rule.target, ordinal); const fieldKey = this.buildVisibilityKey(rule.target, ordinal);
const currentState = this.isVisibleMap[fieldKey] ?? false; const currentState = this._isVisibleMap[fieldKey] ?? false;
this.isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field); this._isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field);
} }
} else { } else {
const fieldKey = this.buildVisibilityKey(rule.target, null); //Ordinal is null if target not on field const fieldKey = this.buildVisibilityKey(rule.target, null); //Ordinal is null if target not on field
const currentState = this.isVisibleMap[fieldKey] ?? false; const currentState = this._isVisibleMap[fieldKey] ?? false;
this.isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field); this._isVisibleMap[fieldKey] = currentState || this.ruleIsTrue(rule, field);
} }
} }
}); });
@ -276,7 +279,7 @@ export class VisibilityRulesService {
for (let i = 0; i < this.definition?.pages.length; i++) { for (let i = 0; i < this.definition?.pages.length; i++) {
const pageEntity = this.definition?.pages[i]; const pageEntity = this.definition?.pages[i];
const fieldKey = this.buildVisibilityKey(pageEntity.id, null); const fieldKey = this.buildVisibilityKey(pageEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
this.expandPageVisibility(pageEntity, currentValue); this.expandPageVisibility(pageEntity, currentValue);
} }
} }
@ -286,16 +289,16 @@ export class VisibilityRulesService {
for (let i = 0; i < pageEntity.sections.length; i++) { for (let i = 0; i < pageEntity.sections.length; i++) {
const sectionEntity = pageEntity.sections[i]; const sectionEntity = pageEntity.sections[i];
const fieldKey = this.buildVisibilityKey(sectionEntity.id, null); const fieldKey = this.buildVisibilityKey(sectionEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue != null){ if (currentValue != null){
if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
this.expandSectionVisibility(sectionEntity, currentValue); this.expandSectionVisibility(sectionEntity, currentValue);
} else { } else {
this.expandSectionVisibility(sectionEntity, currentValue); this.expandSectionVisibility(sectionEntity, currentValue);
} }
} else { } else {
if (parentVisibility != null) this.isVisibleMap[fieldKey] = parentVisibility; if (parentVisibility != null) this._isVisibleMap[fieldKey] = parentVisibility;
this.expandSectionVisibility(sectionEntity, parentVisibility); this.expandSectionVisibility(sectionEntity, parentVisibility);
} }
} }
@ -305,41 +308,41 @@ export class VisibilityRulesService {
for (let i = 0; i < sectionEntity.sections.length; i++) { for (let i = 0; i < sectionEntity.sections.length; i++) {
const subSectionEntity = sectionEntity.sections[i]; const subSectionEntity = sectionEntity.sections[i];
const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null); const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue != null){ if (currentValue != null){
if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
this.expandSectionVisibility(subSectionEntity, currentValue); this.expandSectionVisibility(subSectionEntity, currentValue);
} else { } else {
this.expandSectionVisibility(subSectionEntity, currentValue); this.expandSectionVisibility(subSectionEntity, currentValue);
} }
} else { } else {
if (parentVisibility != null) this.isVisibleMap[fieldKey] = parentVisibility; if (parentVisibility != null) this._isVisibleMap[fieldKey] = parentVisibility;
this.expandSectionVisibility(subSectionEntity, parentVisibility); this.expandSectionVisibility(subSectionEntity, parentVisibility);
} }
} }
} }
if (sectionEntity.fieldSets != null) { if (sectionEntity.fieldSets != null) {
const propertyDefinition = this.formService.getValue(this.form.getRawValue()) as DescriptionPropertyDefinitionPersist;
for (let i = 0; i < sectionEntity.fieldSets.length; i++) { for (let i = 0; i < sectionEntity.fieldSets.length; i++) {
const fieldSetEntity = sectionEntity.fieldSets[i]; const fieldSetEntity = sectionEntity.fieldSets[i];
const propertyDefinition = this.formService.getValue(this.form.value) as DescriptionPropertyDefinitionPersist;
if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) { if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) {
const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id) const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id)
if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) { if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) {
for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) { for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) {
const definitionFieldSetItem = propertyDefinitionFieldSet.items[j]; const definitionFieldSetItem = propertyDefinitionFieldSet.items[j];
const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal); const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue != null){ if (currentValue != null){
if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
this.expandFieldSetVisibility(fieldSetEntity, currentValue, definitionFieldSetItem.ordinal); this.expandFieldSetVisibility(fieldSetEntity, currentValue, definitionFieldSetItem.ordinal);
} else { } else {
this.expandFieldSetVisibility(fieldSetEntity, currentValue, definitionFieldSetItem.ordinal); this.expandFieldSetVisibility(fieldSetEntity, currentValue, definitionFieldSetItem.ordinal);
} }
} else { } else {
if (parentVisibility != null) this.isVisibleMap[fieldKey] = parentVisibility; if (parentVisibility != null) this._isVisibleMap[fieldKey] = parentVisibility;
this.expandFieldSetVisibility(fieldSetEntity, parentVisibility, definitionFieldSetItem.ordinal); this.expandFieldSetVisibility(fieldSetEntity, parentVisibility, definitionFieldSetItem.ordinal);
} }
} }
@ -354,13 +357,13 @@ export class VisibilityRulesService {
for (let i = 0; i < fieldSetEntity.fields.length; i++) { for (let i = 0; i < fieldSetEntity.fields.length; i++) {
const fieldEntity = fieldSetEntity.fields[i]; const fieldEntity = fieldSetEntity.fields[i];
const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal); const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue != null){ if (currentValue != null){
if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden if (parentVisibility != null && !parentVisibility) { //Parent is hidden so all childs should be hidden
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
} }
} else if (parentVisibility != null){ } else if (parentVisibility != null){
this.isVisibleMap[fieldKey] = parentVisibility; this._isVisibleMap[fieldKey] = parentVisibility;
} }
} }
} }
@ -371,8 +374,8 @@ export class VisibilityRulesService {
for (let i = 0; i < this.definition?.pages.length; i++) { for (let i = 0; i < this.definition?.pages.length; i++) {
const pageEntity = this.definition?.pages[i]; const pageEntity = this.definition?.pages[i];
const fieldKey = this.buildVisibilityKey(pageEntity.id, null); const fieldKey = this.buildVisibilityKey(pageEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue == null) this.isVisibleMap[fieldKey] = true; if (currentValue == null) this._isVisibleMap[fieldKey] = true;
this.setDefaultPageVisibility(pageEntity); this.setDefaultPageVisibility(pageEntity);
} }
} }
@ -382,9 +385,9 @@ export class VisibilityRulesService {
for (let i = 0; i < pageEntity.sections.length; i++) { for (let i = 0; i < pageEntity.sections.length; i++) {
const sectionEntity = pageEntity.sections[i]; const sectionEntity = pageEntity.sections[i];
const fieldKey = this.buildVisibilityKey(sectionEntity.id, null); const fieldKey = this.buildVisibilityKey(sectionEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue == null){ if (currentValue == null){
this.isVisibleMap[fieldKey] = true; this._isVisibleMap[fieldKey] = true;
this.setDefaultSectionVisibility(sectionEntity); this.setDefaultSectionVisibility(sectionEntity);
} }
} }
@ -395,27 +398,27 @@ export class VisibilityRulesService {
for (let i = 0; i < sectionEntity.sections.length; i++) { for (let i = 0; i < sectionEntity.sections.length; i++) {
const subSectionEntity = sectionEntity.sections[i]; const subSectionEntity = sectionEntity.sections[i];
const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null); const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue == null){ if (currentValue == null){
this.isVisibleMap[fieldKey] = true; this._isVisibleMap[fieldKey] = true;
this.setDefaultSectionVisibility(subSectionEntity); this.setDefaultSectionVisibility(subSectionEntity);
} }
} }
} }
if (sectionEntity.fieldSets != null) { if (sectionEntity.fieldSets != null) {
const propertyDefinition = this.formService.getValue(this.form.getRawValue()) as DescriptionPropertyDefinitionPersist;
for (let i = 0; i < sectionEntity.fieldSets.length; i++) { for (let i = 0; i < sectionEntity.fieldSets.length; i++) {
const fieldSetEntity = sectionEntity.fieldSets[i]; const fieldSetEntity = sectionEntity.fieldSets[i];
const propertyDefinition = this.formService.getValue(this.form.value) as DescriptionPropertyDefinitionPersist;
if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) { if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) {
const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id) const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id)
if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) { if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) {
for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) { for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) {
const definitionFieldSetItem = propertyDefinitionFieldSet.items[j]; const definitionFieldSetItem = propertyDefinitionFieldSet.items[j];
const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal); const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue == null){ if (currentValue == null){
this.isVisibleMap[fieldKey] = true; this._isVisibleMap[fieldKey] = true;
this.setDefaultFieldSetVisibility(fieldSetEntity, definitionFieldSetItem.ordinal); this.setDefaultFieldSetVisibility(fieldSetEntity, definitionFieldSetItem.ordinal);
} }
} }
@ -430,9 +433,9 @@ export class VisibilityRulesService {
for (let i = 0; i < fieldSetEntity.fields.length; i++) { for (let i = 0; i < fieldSetEntity.fields.length; i++) {
const fieldEntity = fieldSetEntity.fields[i]; const fieldEntity = fieldSetEntity.fields[i];
const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal); const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal);
const currentValue: boolean | null = this.isVisibleMap[fieldKey] ?? null; const currentValue: boolean | null = this._isVisibleMap[fieldKey] ?? null;
if (currentValue == null){ if (currentValue == null){
this.isVisibleMap[fieldKey] = true; this._isVisibleMap[fieldKey] = true;
} }
} }
} }
@ -445,8 +448,8 @@ export class VisibilityRulesService {
const fieldKey = this.buildVisibilityKey(pageEntity.id, null); const fieldKey = this.buildVisibilityKey(pageEntity.id, null);
const isCurrentHidden = this.isHiddenPageVisibilityIfAllChildrenIsHidden(pageEntity); const isCurrentHidden = this.isHiddenPageVisibilityIfAllChildrenIsHidden(pageEntity);
if (isCurrentHidden && (this.isVisibleMap[fieldKey] ?? true)) { if (isCurrentHidden && (this._isVisibleMap[fieldKey] ?? true)) {
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
} }
} }
} }
@ -458,8 +461,8 @@ export class VisibilityRulesService {
const sectionEntity = pageEntity.sections[i]; const sectionEntity = pageEntity.sections[i];
const fieldKey = this.buildVisibilityKey(sectionEntity.id, null); const fieldKey = this.buildVisibilityKey(sectionEntity.id, null);
const isCurrentHidden = this.isHiddenSectionIfAllChildrenIsHidden(sectionEntity); const isCurrentHidden = this.isHiddenSectionIfAllChildrenIsHidden(sectionEntity);
if (isCurrentHidden && (this.isVisibleMap[fieldKey] ?? true)) { if (isCurrentHidden && (this._isVisibleMap[fieldKey] ?? true)) {
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
} }
isHidden = isHidden && isCurrentHidden; isHidden = isHidden && isCurrentHidden;
} }
@ -473,16 +476,16 @@ export class VisibilityRulesService {
const subSectionEntity = sectionEntity.sections[i]; const subSectionEntity = sectionEntity.sections[i];
const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null); const fieldKey = this.buildVisibilityKey(subSectionEntity.id, null);
const isCurrentHidden = this.isHiddenSectionIfAllChildrenIsHidden(subSectionEntity); const isCurrentHidden = this.isHiddenSectionIfAllChildrenIsHidden(subSectionEntity);
if (isCurrentHidden && (this.isVisibleMap[fieldKey] ?? true)) { if (isCurrentHidden && (this._isVisibleMap[fieldKey] ?? true)) {
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
} }
isHidden = isHidden && isCurrentHidden; isHidden = isHidden && isCurrentHidden;
} }
} }
if (sectionEntity.fieldSets != null) { if (sectionEntity.fieldSets != null) {
const propertyDefinition = this.formService.getValue(this.form.getRawValue()) as DescriptionPropertyDefinitionPersist;
for (let i = 0; i < sectionEntity.fieldSets.length; i++) { for (let i = 0; i < sectionEntity.fieldSets.length; i++) {
const fieldSetEntity = sectionEntity.fieldSets[i]; const fieldSetEntity = sectionEntity.fieldSets[i];
const propertyDefinition = this.formService.getValue(this.form.value) as DescriptionPropertyDefinitionPersist;
if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) { if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) {
const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id) const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id)
if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) { if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) {
@ -490,8 +493,8 @@ export class VisibilityRulesService {
const definitionFieldSetItem = propertyDefinitionFieldSet.items[j]; const definitionFieldSetItem = propertyDefinitionFieldSet.items[j];
const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal); const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal);
const isCurrentHidden = this.isHiddenFieldSetIfAllChildrenIsHidden(fieldSetEntity, definitionFieldSetItem.ordinal); const isCurrentHidden = this.isHiddenFieldSetIfAllChildrenIsHidden(fieldSetEntity, definitionFieldSetItem.ordinal);
if (isCurrentHidden && (this.isVisibleMap[fieldKey] ?? true)) { if (isCurrentHidden && (this._isVisibleMap[fieldKey] ?? true)) {
this.isVisibleMap[fieldKey] = false; this._isVisibleMap[fieldKey] = false;
} }
isHidden = isHidden && isCurrentHidden; isHidden = isHidden && isCurrentHidden;
} }
@ -508,7 +511,7 @@ export class VisibilityRulesService {
for (let i = 0; i < fieldSetEntity.fields.length; i++) { for (let i = 0; i < fieldSetEntity.fields.length; i++) {
const fieldEntity = fieldSetEntity.fields[i]; const fieldEntity = fieldSetEntity.fields[i];
const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal); const fieldKey = this.buildVisibilityKey(fieldEntity.id, ordinal);
const currentValue: boolean | null = (this.isVisibleMap[fieldKey] ?? true); const currentValue: boolean | null = (this._isVisibleMap[fieldKey] ?? true);
isHidden = isHidden && !currentValue; isHidden = isHidden && !currentValue;
} }
return isHidden; return isHidden;
@ -540,23 +543,23 @@ export class VisibilityRulesService {
} }
} }
if (sectionEntity.fieldSets != null) { if (sectionEntity.fieldSets != null) {
const propertyDefinition = this.formService.getValue(this.form.getRawValue()) as DescriptionPropertyDefinitionPersist;
for (let i = 0; i < sectionEntity.fieldSets.length; i++) { for (let i = 0; i < sectionEntity.fieldSets.length; i++) {
const fieldSetEntity = sectionEntity.fieldSets[i]; const fieldSetEntity = sectionEntity.fieldSets[i];
let isHidden = true; let isHidden = true;
const propertyDefinition = this.formService.getValue(this.form.value) as DescriptionPropertyDefinitionPersist;
if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) { if (propertyDefinition.fieldSets != null && new Map(Object.entries(propertyDefinition.fieldSets)).has(fieldSetEntity.id)) {
const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id) const propertyDefinitionFieldSet = new Map(Object.entries(propertyDefinition.fieldSets)).get(fieldSetEntity.id)
if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) { if (propertyDefinitionFieldSet.items != null && propertyDefinitionFieldSet.items.length > 0) {
for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) { for (let j = 0; j < propertyDefinitionFieldSet.items.length; j++) {
const definitionFieldSetItem = propertyDefinitionFieldSet.items[j]; const definitionFieldSetItem = propertyDefinitionFieldSet.items[j];
const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal); const fieldKey = this.buildVisibilityKey(fieldSetEntity.id, definitionFieldSetItem.ordinal);
const isCurrentHidden = !this.isVisibleMap[fieldKey] ?? false; const isCurrentHidden = !this._isVisibleMap[fieldKey] ?? false;
isHidden = isHidden && isCurrentHidden; isHidden = isHidden && isCurrentHidden;
} }
} }
} }
const globalFieldSetKey = this.buildVisibilityKey(fieldSetEntity.id, null); const globalFieldSetKey = this.buildVisibilityKey(fieldSetEntity.id, null);
this.isVisibleMap[globalFieldSetKey] = !isHidden; this._isVisibleMap[globalFieldSetKey] = !isHidden;
} }
} }
} }