This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch 3112-opc-ua-multi-node-selection-editor in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit bf1d163e0a89e9bbb641d20a725c3ff7c463f60b Author: Philipp Zehnder <[email protected]> AuthorDate: Tue Aug 13 21:29:12 2024 +0200 feat(#3112): Fix tree view editor navigation --- .../utils/userInput/TreeStaticPropertyUtils.ts | 4 ++-- ...atic-runtime-resolvable-tree-input.component.ts | 25 ++++++++++++++++------ .../static-tree-input-browse-nodes.component.ts | 1 + .../static-tree-input-button-menu.component.html | 4 ++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts b/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts index ee98177d66..03f1ee619b 100644 --- a/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts +++ b/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts @@ -37,14 +37,14 @@ export class TreeStaticPropertyUtils { * Opens the text editor */ public static switchToTextEditor() { - cy.dataCy('opc-ua-editor-mode-text').click(); + cy.dataCy('editor-mode-text').click(); } /** * Opens the tree editor */ public static switchToTreeEditor() { - cy.dataCy('opc-ua-editor-mode-tree').click(); + cy.dataCy('editor-mode-tree').click(); } /** diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts index 80dce0944c..819afae9e1 100644 --- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts +++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts @@ -42,7 +42,7 @@ export class StaticRuntimeResolvableTreeInputComponent editorMode: 'tree' | 'text' = 'tree'; @ViewChild('staticTreeInputBrowseNodesComponent') - staticTreeInputBrowseNodesComponent: StaticTreeInputBrowseNodesComponent; + private staticTreeInputBrowseNodesComponent: StaticTreeInputBrowseNodesComponent; constructor( runtimeResolvableService: RuntimeResolvableService, @@ -59,7 +59,7 @@ export class StaticRuntimeResolvableTreeInputComponent ) { this.loadOptionsFromRestApi(); } else if (this.staticProperty.nodes.length > 0) { - this.staticTreeInputBrowseNodesComponent.updateNodes( + this.staticTreeInputBrowseNodesComponent?.updateNodes( this.staticProperty.nodes, ); this.showOptions = true; @@ -92,11 +92,11 @@ export class StaticRuntimeResolvableTreeInputComponent } } else { this.staticProperty.nodes = staticProperty.nodes; - this.staticTreeInputBrowseNodesComponent.updateNodes( + this.staticTreeInputBrowseNodesComponent?.updateNodes( this.staticProperty.nodes, ); } - this.staticTreeInputBrowseNodesComponent.refreshTree(); + this.staticTreeInputBrowseNodesComponent?.refreshTree(); this.performValidation(); } @@ -125,7 +125,7 @@ export class StaticRuntimeResolvableTreeInputComponent afterErrorReceived() { this.staticProperty.nodes = []; - this.staticTreeInputBrowseNodesComponent.updateNodes([]); + this.staticTreeInputBrowseNodesComponent?.updateNodes([]); this.performValidation(); } @@ -137,7 +137,7 @@ export class StaticRuntimeResolvableTreeInputComponent this.staticProperty.nextBaseNodeToResolve = undefined; this.staticProperty.selectedNodesInternalNames = []; this.staticProperty.latestFetchedNodes = []; - this.staticTreeInputBrowseNodesComponent.updateNodes([]); + this.staticTreeInputBrowseNodesComponent?.updateNodes([]); this.loadOptionsFromRestApi(); } @@ -157,7 +157,18 @@ export class StaticRuntimeResolvableTreeInputComponent this.editorMode = mode; if (mode === 'tree') { - this.reload(); + this.resetStaticPropertyStateAndReload(); } } + + /** + * The static property keeps the state of the last fetched nodes to be able + * to set the subtree to the right node. When a user switches the editor + * this state should be reset + */ + private resetStaticPropertyStateAndReload() { + this.staticProperty.latestFetchedNodes = []; + this.staticProperty.nextBaseNodeToResolve = undefined; + this.reload(); + } } diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-browse-nodes/static-tree-input-browse-nodes.component.ts b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-browse-nodes/static-tree-input-browse-nodes.component.ts index de04432f80..478c719509 100644 --- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-browse-nodes/static-tree-input-browse-nodes.component.ts +++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-browse-nodes/static-tree-input-browse-nodes.component.ts @@ -78,6 +78,7 @@ export class StaticTreeInputBrowseNodesComponent implements OnInit { } updateNodes(nodes: TreeInputNode[]) { + console.log(nodes); this.dataSource.data = nodes; } diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html index 447eb449b5..a7ae7baa17 100644 --- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html +++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html @@ -60,10 +60,10 @@ [(value)]="editorMode" (change)="onChangeEditor($event.value)" > - <mat-button-toggle data-cy="opc-ua-editor-mode-tree" value="tree" + <mat-button-toggle data-cy="editor-mode-tree" value="tree" >Tree</mat-button-toggle > - <mat-button-toggle data-cy="opc-ua-editor-mode-text" value="text" + <mat-button-toggle data-cy="editor-mode-text" value="text" >Text</mat-button-toggle > </mat-button-toggle-group>
