From 13436a453bb2364060c52cee02dd7687e6d20224 Mon Sep 17 00:00:00 2001 From: "alejandro.bulgaris@qcif.edu.au" Date: Tue, 10 Oct 2023 03:38:48 +0000 Subject: [PATCH 1/5] Add tree node exapad collapse status list --- .../shared/form/field-andsvocab.component.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/angular-legacy/shared/form/field-andsvocab.component.ts b/angular-legacy/shared/form/field-andsvocab.component.ts index ea98c4a84f..7df6a0d1f1 100644 --- a/angular-legacy/shared/form/field-andsvocab.component.ts +++ b/angular-legacy/shared/form/field-andsvocab.component.ts @@ -177,6 +177,7 @@ export class ANDSVocabComponent extends SimpleComponent { readonly STATUS_EXPANDED = 4; loadState: any; initialised:boolean = false; + treeNodeLiveStatusIDs: any = []; constructor(@Inject(ElementRef) elementRef: ElementRef) { super(); @@ -238,6 +239,7 @@ export class ANDSVocabComponent extends SimpleComponent { } } + //This method is called when the record edit view is first loaded and sets state and expand nodes that have checkboxes selected protected startTreeInit() { this.treeInitListener = Observable.interval(1000).subscribe(()=> { @@ -279,6 +281,7 @@ export class ANDSVocabComponent extends SimpleComponent { event = eventArr[1]; } let currentState = this.getNodeSelected(event.node.id); + switch(event.eventName) { case "nodeActivate": if (currentState == undefined) { @@ -296,6 +299,8 @@ export class ANDSVocabComponent extends SimpleComponent { this.updateSingleNodeSelectedState(event.node, false); break; } + + this.expandCollapseNode(event.node); } protected updateSingleNodeSelectedState(node, state) { @@ -315,6 +320,7 @@ export class ANDSVocabComponent extends SimpleComponent { this.nodeEventSubject.next(event); } + //This method is called when the record edit view is first loaded populates expandNodeIds list public updateTreeView(that) { const state = that.andsTree.treeModel.getState(); that.expandNodeIds = []; @@ -329,8 +335,15 @@ export class ANDSVocabComponent extends SimpleComponent { that.andsTree.treeModel.setState(state); that.andsTree.treeModel.update(); that.expandNodeIds = _.sortBy(that.expandNodeIds, (o) => { return _.isString(o) ? o.length : 0 }); + + //Populate a list of expanded node ids on first load based of expandNodeIds + for(let i = 0; i < that.expandNodeIds.length; i++) { + let nodeId = that.expandNodeIds[i]; + that.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'exapanded'}); + } } + //Takes the first entry in expandNodeIds list and expands the node and the removed the id from the list protected expandNodes() { if (!_.isEmpty(this.expandNodeIds)) { const parentId = this.expandNodeIds[0]; @@ -342,6 +355,27 @@ export class ANDSVocabComponent extends SimpleComponent { } } + protected expandCollapseNode(nodeEvent: any) { + const nodeId = _.get(nodeEvent,'id',''); + let nodeStatusObject = _.find(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); + let nodeStatus = 'collapsed'; + if(!_.isUndefined(nodeStatusObject)) { + nodeStatus = _.get(nodeStatusObject, 'nodeStatus', 'collapsed'); + } + const node = this.andsTree.treeModel.getNodeById(nodeId); + if (node) { + if(nodeStatus == 'collapsed') { + node.expand(); + _.remove(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); + this.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'exapanded'}); + } else { + node.collapse(); + _.remove(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); + this.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'collapsed'}); + } + } + } + protected collapseNodes() { this.andsTree.treeModel.collapseAll(); } From 0cc76f85105a4abed919208db9f8938784c00c7d Mon Sep 17 00:00:00 2001 From: "alejandro.bulgaris@qcif.edu.au" Date: Tue, 10 Oct 2023 04:39:44 +0000 Subject: [PATCH 2/5] Ignore six digit codes that don't need to expand collapse --- .../shared/form/field-andsvocab.component.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/angular-legacy/shared/form/field-andsvocab.component.ts b/angular-legacy/shared/form/field-andsvocab.component.ts index 7df6a0d1f1..27513721c9 100644 --- a/angular-legacy/shared/form/field-andsvocab.component.ts +++ b/angular-legacy/shared/form/field-andsvocab.component.ts @@ -339,6 +339,12 @@ export class ANDSVocabComponent extends SimpleComponent { //Populate a list of expanded node ids on first load based of expandNodeIds for(let i = 0; i < that.expandNodeIds.length; i++) { let nodeId = that.expandNodeIds[i]; + + //Ignore child nodes with 6 digit codes + if(nodeId.length > 4) { + continue; + } + that.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'exapanded'}); } } @@ -357,6 +363,12 @@ export class ANDSVocabComponent extends SimpleComponent { protected expandCollapseNode(nodeEvent: any) { const nodeId = _.get(nodeEvent,'id',''); + + //Ignore child nodes with 6 digit codes + if(nodeId.length > 4) { + return; + } + let nodeStatusObject = _.find(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); let nodeStatus = 'collapsed'; if(!_.isUndefined(nodeStatusObject)) { From 85dd28ca77e6b18007ea3c34d9f4abd3e5606677 Mon Sep 17 00:00:00 2001 From: "alejandro.bulgaris@qcif.edu.au" Date: Tue, 10 Oct 2023 04:53:23 +0000 Subject: [PATCH 3/5] Refactor to use isCollapsed property from the node --- .../shared/form/field-andsvocab.component.ts | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/angular-legacy/shared/form/field-andsvocab.component.ts b/angular-legacy/shared/form/field-andsvocab.component.ts index 27513721c9..2bb879e9f8 100644 --- a/angular-legacy/shared/form/field-andsvocab.component.ts +++ b/angular-legacy/shared/form/field-andsvocab.component.ts @@ -335,18 +335,6 @@ export class ANDSVocabComponent extends SimpleComponent { that.andsTree.treeModel.setState(state); that.andsTree.treeModel.update(); that.expandNodeIds = _.sortBy(that.expandNodeIds, (o) => { return _.isString(o) ? o.length : 0 }); - - //Populate a list of expanded node ids on first load based of expandNodeIds - for(let i = 0; i < that.expandNodeIds.length; i++) { - let nodeId = that.expandNodeIds[i]; - - //Ignore child nodes with 6 digit codes - if(nodeId.length > 4) { - continue; - } - - that.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'exapanded'}); - } } //Takes the first entry in expandNodeIds list and expands the node and the removed the id from the list @@ -365,25 +353,16 @@ export class ANDSVocabComponent extends SimpleComponent { const nodeId = _.get(nodeEvent,'id',''); //Ignore child nodes with 6 digit codes - if(nodeId.length > 4) { + if(nodeId == '' || nodeId.length > 4) { return; } - let nodeStatusObject = _.find(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); - let nodeStatus = 'collapsed'; - if(!_.isUndefined(nodeStatusObject)) { - nodeStatus = _.get(nodeStatusObject, 'nodeStatus', 'collapsed'); - } const node = this.andsTree.treeModel.getNodeById(nodeId); if (node) { - if(nodeStatus == 'collapsed') { + if(_.get(node, 'isCollapsed', false)) { node.expand(); - _.remove(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); - this.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'exapanded'}); } else { node.collapse(); - _.remove(this.treeNodeLiveStatusIDs, (o: any) => { return o.nodeId == nodeId }); - this.treeNodeLiveStatusIDs.push({nodeId: nodeId, nodeStatus: 'collapsed'}); } } } From cf03154194f7be64ceea412c631d710662d7e9c0 Mon Sep 17 00:00:00 2001 From: "alejandro.bulgaris@qcif.edu.au" Date: Tue, 10 Oct 2023 05:18:31 +0000 Subject: [PATCH 4/5] Add property to disable expand collapse toggle by name --- angular-legacy/shared/form/field-andsvocab.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/angular-legacy/shared/form/field-andsvocab.component.ts b/angular-legacy/shared/form/field-andsvocab.component.ts index 2bb879e9f8..7f9ad48d1b 100644 --- a/angular-legacy/shared/form/field-andsvocab.component.ts +++ b/angular-legacy/shared/form/field-andsvocab.component.ts @@ -46,6 +46,7 @@ export class ANDSVocabField extends FieldBase { public disableCheckboxRegexPattern:string; public disableCheckboxRegexTestValue:string; public disableCheckboxRegexCaseSensitive: boolean; + public disableExpandCollapseToggleByName: boolean; public component:any; constructor(options: any, injector: any) { @@ -56,6 +57,7 @@ export class ANDSVocabField extends FieldBase { this.disableCheckboxRegexPattern = options['disableCheckboxRegexPattern'] || ""; this.disableCheckboxRegexTestValue = options['disableCheckboxRegexTestValue'] || ""; this.disableCheckboxRegexCaseSensitive = options['disableCheckboxRegexCaseSensitive'] || true; + this.disableExpandCollapseToggleByName = options['disableExpandCollapseToggleByName'] || false; this.andsService = this.getFromInjector(ANDSService); } @@ -300,7 +302,9 @@ export class ANDSVocabComponent extends SimpleComponent { break; } - this.expandCollapseNode(event.node); + if(!this.field.disableExpandCollapseToggleByName) { + this.expandCollapseNode(event.node); + } } protected updateSingleNodeSelectedState(node, state) { From fa2a5517cad40eaff11f195a9ef281cab82295f5 Mon Sep 17 00:00:00 2001 From: "alejandro.bulgaris@qcif.edu.au" Date: Wed, 11 Oct 2023 03:25:36 +0000 Subject: [PATCH 5/5] Add generic property to skip expand collapse event processing --- angular-legacy/shared/form/field-andsvocab.component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/angular-legacy/shared/form/field-andsvocab.component.ts b/angular-legacy/shared/form/field-andsvocab.component.ts index 7f9ad48d1b..c7ef1ccfab 100644 --- a/angular-legacy/shared/form/field-andsvocab.component.ts +++ b/angular-legacy/shared/form/field-andsvocab.component.ts @@ -47,6 +47,7 @@ export class ANDSVocabField extends FieldBase { public disableCheckboxRegexTestValue:string; public disableCheckboxRegexCaseSensitive: boolean; public disableExpandCollapseToggleByName: boolean; + public skipLeafNodeExpandCollapseProcessing: number; public component:any; constructor(options: any, injector: any) { @@ -58,6 +59,7 @@ export class ANDSVocabField extends FieldBase { this.disableCheckboxRegexTestValue = options['disableCheckboxRegexTestValue'] || ""; this.disableCheckboxRegexCaseSensitive = options['disableCheckboxRegexCaseSensitive'] || true; this.disableExpandCollapseToggleByName = options['disableExpandCollapseToggleByName'] || false; + this.skipLeafNodeExpandCollapseProcessing = options['skipLeafNodeExpandCollapseProcessing'] || 4; this.andsService = this.getFromInjector(ANDSService); } @@ -179,7 +181,6 @@ export class ANDSVocabComponent extends SimpleComponent { readonly STATUS_EXPANDED = 4; loadState: any; initialised:boolean = false; - treeNodeLiveStatusIDs: any = []; constructor(@Inject(ElementRef) elementRef: ElementRef) { super(); @@ -356,8 +357,8 @@ export class ANDSVocabComponent extends SimpleComponent { protected expandCollapseNode(nodeEvent: any) { const nodeId = _.get(nodeEvent,'id',''); - //Ignore child nodes with 6 digit codes - if(nodeId == '' || nodeId.length > 4) { + //Ignore expand collapse processing if id string value has length that exceeds default + if(nodeId == '' || nodeId.length > this.field.skipLeafNodeExpandCollapseProcessing) { return; }