You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2020/04/01 14:22:12 UTC
[myfaces-tobago] branch master updated: tobago-tree: custom elements
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 71cabc1 tobago-tree: custom elements
71cabc1 is described below
commit 71cabc1cbf692cc1574ac5d8adf734c5a8b19386
Author: Henning Nöth <hn...@apache.org>
AuthorDate: Wed Apr 1 16:20:14 2020 +0200
tobago-tree: custom elements
fix: sync client with server after a node is expanded/collapsed.
issue: TOBAGO-1633: TS refactoring
---
.../src/main/npm/ts/tobago-tree.ts | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree.ts
index d3b8aa4..5c57269 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree.ts
@@ -51,7 +51,7 @@ export class Tree extends HTMLElement {
queryString += "tobago-tree-node[index='" + selectedNodeIndex + "']";
}
- if(queryString.length > 0) {
+ if (queryString.length > 0) {
return this.querySelectorAll(queryString) as NodeListOf<TreeNode>;
} else {
return null;
@@ -176,6 +176,7 @@ export class TreeNode extends HTMLElement {
this.classList.remove("tobago-treeNode-markup-expanded");
this.hideNodes(this.treeChildNodes);
+ this.ajax(event, false);
} else {
for (const icon of this.icons) {
icon.classList.remove(icon.dataset.tobagoClosed);
@@ -192,20 +193,22 @@ export class TreeNode extends HTMLElement {
this.tree.addExpandedNode(this.index);
this.classList.add("tobago-treeNode-markup-expanded");
- if (this.treeChildNodes.length === 0) {
- jsf.ajax.request(
- this.id,
- event,
- {
- execute: this.tree.id,
- render: this.tree.id
- });
- } else {
- this.showNodes(this.treeChildNodes);
- }
+ this.showNodes(this.treeChildNodes);
+ this.ajax(event, this.treeChildNodes.length === 0);
}
}
+ private ajax(event: Event, renderTree: boolean): void {
+ jsf.ajax.request(
+ this.id,
+ event,
+ {
+ "javax.faces.behavior.event": "change",
+ execute: this.tree.id,
+ render: renderTree ? this.tree.id : null
+ });
+ }
+
hideNodes(treeChildNodes: NodeListOf<TreeNode>): void {
for (const treeChildNode of treeChildNodes) {