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 2022/05/10 11:55:41 UTC

[myfaces-tobago] branch tobago-5.x updated (427de6cd6c -> ab6231f5e5)

This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a change to branch tobago-5.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


    from 427de6cd6c build(deps-dev): bump rollup in /tobago-example/tobago-example-demo
     new 3e052d1b41 fix(sheet): selectable
     new ab6231f5e5 build(theme): rebuild after fixing NPE in tobago-sheet.ts for integration test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../40-sheet-selector/Sheet_Selector.test.js       | 68 ++++++++++++++++++++++
 .../40-sheet-selector/Sheet_Selector.xhtml}        | 55 ++++++++++++-----
 .../tobago-theme-standard/src/main/js/tobago.js    |  2 +-
 .../src/main/js/tobago.js.map                      |  2 +-
 .../src/main/ts/tobago-sheet.ts                    | 10 ++--
 5 files changed, 116 insertions(+), 21 deletions(-)
 create mode 100644 tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.test.js
 copy tobago-example/tobago-example-demo/src/main/webapp/content/{080-sheet/40-style/Sheet_Style.xhtml => 900-test/3000-sheet/40-sheet-selector/Sheet_Selector.xhtml} (51%)


[myfaces-tobago] 02/02: build(theme): rebuild after fixing NPE in tobago-sheet.ts for integration test

Posted by hn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch tobago-5.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit ab6231f5e5d5ab2802b70a5de063a859dfaec7d0
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue May 10 13:41:49 2022 +0200

    build(theme): rebuild after fixing NPE in tobago-sheet.ts for integration test
---
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js     | 2 +-
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
index b8cb199ef0..b86ffa43cb 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -4,5 +4,5 @@
     * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
     * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
     */
-const Ne="transitionend",Re=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},De=e=>{const t=Re(e);return t&&document.querySelector(t)?t:null},Me=e=>{const t=Re(e);return t?document.querySelector(t):null},je=e=>{e.dispatchEvent(new Event(Ne))},He=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
+const Ne="transitionend",Re=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},De=e=>{const t=Re(e);return t&&document.querySelector(t)?t:null},Me=e=>{const t=Re(e);return t?document.querySelector(t):null},je=e=>{e.dispatchEvent(new Event(Ne))},He=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
 //# sourceMappingURL=tobago.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
index 438474a675..272655618e 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
@@ -1 +1 @@
-{"version":3,"file":"tobago.js","sources":["../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js","../../../../node_m [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js","../../../../node_m [...]
\ No newline at end of file


[myfaces-tobago] 01/02: fix(sheet): selectable

Posted by hn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch tobago-5.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 3e052d1b415da7d988b26432e445a6a4ce939648
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue May 10 12:41:59 2022 +0200

    fix(sheet): selectable
    
    * add test
    * fix NPE in tobago-sheet.ts for integration test
    
    Issue: TOBAGO-2131
---
 .../40-sheet-selector/Sheet_Selector.test.js       | 68 ++++++++++++++++++
 .../40-sheet-selector/Sheet_Selector.xhtml         | 82 ++++++++++++++++++++++
 .../src/main/ts/tobago-sheet.ts                    | 10 +--
 3 files changed, 156 insertions(+), 4 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.test.js
new file mode 100644
index 0000000000..930113b8e1
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.test.js
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {elementByIdFn, querySelectorFn} from "/script/tobago-test.js";
+import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
+
+it("default sheet", function (done) {
+  const reloadFn = elementByIdFn("page:mainForm:reload");
+  const selectedFn = elementByIdFn("page:mainForm:sheetDefault::selected");
+  const row2Fn = querySelectorFn("#page\\:mainForm\\:sheetDefault tr[row-index='2']");
+  const row4Fn = querySelectorFn("#page\\:mainForm\\:sheetDefault tr[row-index='4']");
+
+  const test = new JasmineTestTool(done);
+  test.setup(() => selectedFn().value === "[]", "click", reloadFn);
+  test.do(() => expect(selectedFn().value).toEqual("[]"));
+  test.event("click", row2Fn, () => selectedFn().value === "[2]");
+  test.do(() => expect(selectedFn().value).toEqual("[2]"));
+  test.event("click", row4Fn, () => selectedFn().value === "[4]");
+  test.do(() => expect(selectedFn().value).toEqual("[4]"));
+  test.start();
+});
+
+it("columnSelector sheet", function (done) {
+  const reloadFn = elementByIdFn("page:mainForm:reload");
+  const selectedFn = elementByIdFn("page:mainForm:sheetColumnSelector::selected");
+  const row2Fn = querySelectorFn("#page\\:mainForm\\:sheetColumnSelector tr[row-index='2']");
+  const row4Fn = querySelectorFn("#page\\:mainForm\\:sheetColumnSelector tr[row-index='4']");
+
+  const test = new JasmineTestTool(done);
+  test.setup(() => selectedFn().value === "[]", "click", reloadFn);
+  test.do(() => expect(selectedFn().value).toEqual("[]"));
+  test.event("click", row2Fn, () => selectedFn().value === "[2]");
+  test.do(() => expect(selectedFn().value).toEqual("[2]"));
+  test.event("click", row4Fn, () => selectedFn().value === "[2,4]");
+  test.do(() => expect(selectedFn().value).toEqual("[2,4]"));
+  test.start();
+});
+
+it("disabled columnSelector sheet", function (done) {
+  const reloadFn = elementByIdFn("page:mainForm:reload");
+  const sheetFn = elementByIdFn("page:mainForm:sheetColumnSelectorDisabled");
+  const selectedFn = elementByIdFn("page:mainForm:sheetColumnSelectorDisabled::selected");
+  const row2Fn = querySelectorFn("#page\\:mainForm\\:sheetColumnSelectorDisabled tr[row-index='2']");
+  const row4Fn = querySelectorFn("#page\\:mainForm\\:sheetColumnSelectorDisabled tr[row-index='4']");
+
+  const test = new JasmineTestTool(done);
+  test.setup(() => sheetFn().getAttribute("data-tobago-last-clicked-row-index") === null, "click", reloadFn);
+  test.do(() => expect(selectedFn().value).toEqual("[]"));
+  test.event("click", row2Fn, () => sheetFn().getAttribute("data-tobago-last-clicked-row-index") === "2");
+  test.do(() => expect(selectedFn().value).toEqual("[]"));
+  test.event("click", row4Fn, () => sheetFn().getAttribute("data-tobago-last-clicked-row-index") === "4");
+  test.do(() => expect(selectedFn().value).toEqual("[]"));
+  test.start();
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.xhtml
new file mode 100644
index 0000000000..7ba8b5c538
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/40-sheet-selector/Sheet_Selector.xhtml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<ui:composition template="/main.xhtml"
+                xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+  <tc:link id="reload" label="Reload" link="Sheet_Selector.xhtml"/>
+
+  <tc:sheet id="sheetDefault" value="#{sheetController.solarList}" var="object" rows="6">
+    <tc:column label="Name">
+      <tc:out value="#{object.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit">
+      <tc:out value="#{object.orbit}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Period (Days)">
+      <tc:out value="#{object.period}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Discoverer">
+      <tc:out value="#{object.discoverer}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Year">
+      <tc:out value="#{object.discoverYear}" labelLayout="skip"/>
+    </tc:column>
+  </tc:sheet>
+
+  <tc:sheet id="sheetColumnSelector" value="#{sheetController.solarList}" var="object" rows="6">
+    <tc:columnSelector/>
+    <tc:column label="Name">
+      <tc:out value="#{object.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit">
+      <tc:out value="#{object.orbit}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Period (Days)">
+      <tc:out value="#{object.period}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Discoverer">
+      <tc:out value="#{object.discoverer}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Year">
+      <tc:out value="#{object.discoverYear}" labelLayout="skip"/>
+    </tc:column>
+  </tc:sheet>
+
+  <tc:sheet id="sheetColumnSelectorDisabled" value="#{sheetController.solarList}" var="object" rows="6">
+    <tc:columnSelector disabled="true"/>
+    <tc:column label="Name">
+      <tc:out value="#{object.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit">
+      <tc:out value="#{object.orbit}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Period (Days)">
+      <tc:out value="#{object.period}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Discoverer">
+      <tc:out value="#{object.discoverer}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Year">
+      <tc:out value="#{object.discoverYear}" labelLayout="skip"/>
+    </tc:column>
+  </tc:sheet>
+
+</ui:composition>
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
index 380c92bcfd..35cf8e18b8 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
@@ -622,11 +622,13 @@ Type: ${data.type}`);
     const row = event.currentTarget as HTMLTableRowElement;
     if (row.classList.contains("tobago-selected") || !Sheet.isInputElement(row)) {
 
-      if (Math.abs(this.mousedownOnRowData.x - event.clientX)
+      if (this.mousedownOnRowData) { // integration test: mousedownOnRowData may be 'null'
+        if (Math.abs(this.mousedownOnRowData.x - event.clientX)
           + Math.abs(this.mousedownOnRowData.y - event.clientY) > 5) {
-        // The user has moved the mouse. We assume, the user want to select some text inside the sheet,
-        // so we doesn't select the row.
-        return;
+          // The user has moved the mouse. We assume, the user want to select some text inside the sheet,
+          // so we doesn't select the row.
+          return;
+        }
       }
 
       if (window.getSelection) {