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 2024/05/08 17:39:06 UTC

(myfaces-tobago) branch main updated (b85747b439 -> 84b790649c)

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

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


    from b85747b439 feature(popup): staticBackdrop/modal
     new e6a5cb22b0 fix(lazy-sheet): fetch entries when using column panel
     new 84b790649c build(theme): rebuild after fixing lazy-sheet

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:
 .../internal/renderkit/renderer/SheetRenderer.java |   3 +-
 .../myfaces/tobago/renderkit/css/TobagoClass.java  |   1 +
 .../900-test/3000-sheet/82-lazy-2/Lazy_2.test.js   |   8 +-
 .../83-lazy-columnPanel/Lazy_ColumnPanel.test.js   |  98 +++++++++++++
 .../Lazy_ColumnPanel.xhtml}                        |  18 ++-
 tobago-theme/src/main/scss/_tobago.scss            |   3 +
 .../src/main/css/tobago.css.map                    |   2 +-
 .../src/main/css/tobago.css.map                    |   2 +-
 .../src/main/css/tobago.css.map                    |   2 +-
 .../src/main/css/tobago.css.map                    |   2 +-
 .../src/main/css/tobago.css.map                    |   2 +-
 .../tobago-theme-standard/src/main/js/tobago.js    |   4 +-
 .../src/main/js/tobago.js.map                      |   2 +-
 .../src/main/ts/tobago-css.ts                      |   1 +
 .../src/main/ts/tobago-sheet.ts                    | 154 ++++++++++++---------
 15 files changed, 217 insertions(+), 85 deletions(-)
 create mode 100644 tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.test.js
 copy tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/{82-lazy-2/Lazy_2.xhtml => 83-lazy-columnPanel/Lazy_ColumnPanel.xhtml} (84%)


(myfaces-tobago) 01/02: fix(lazy-sheet): fetch entries when using column panel

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

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

commit e6a5cb22b0d4583d20dd51121b63d4cda9f33d37
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Fri May 3 13:54:01 2024 +0200

    fix(lazy-sheet): fetch entries when using column panel
    
    * add example
    * add "tobago-column-panel" CSS class
    * fix initialization of dummy columns
    * fix copy rows/columnPanels from ajax response
    * fix nextLazyLoad()
    * make Lazy_2.test.js more robust
    * add test
    
    Issue: TOBAGO-2307
---
 .../internal/renderkit/renderer/SheetRenderer.java |   3 +-
 .../myfaces/tobago/renderkit/css/TobagoClass.java  |   1 +
 .../900-test/3000-sheet/82-lazy-2/Lazy_2.test.js   |   8 +-
 .../83-lazy-columnPanel/Lazy_ColumnPanel.test.js   |  98 +++++++++++++
 .../83-lazy-columnPanel/Lazy_ColumnPanel.xhtml     |  60 ++++++++
 tobago-theme/src/main/scss/_tobago.scss            |   3 +
 .../src/main/ts/tobago-css.ts                      |   1 +
 .../src/main/ts/tobago-sheet.ts                    | 154 ++++++++++++---------
 8 files changed, 261 insertions(+), 67 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
index 6e4d7ce01f..dd90320516 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
@@ -737,7 +737,8 @@ public class SheetRenderer<T extends AbstractUISheet> extends RendererBase<T> {
 
       if (panel != null) {
         writer.startElement(HtmlElements.TR);
-        writer.writeClassAttribute(panel.getCustomClass());
+        writer.writeNameAttribute(String.valueOf(rowIndex));
+        writer.writeClassAttribute(TobagoClass.COLUMN__PANEL, panel.getCustomClass());
         writer.startElement(HtmlElements.TD);
         writer.writeAttribute(HtmlAttributes.COLSPAN, colSpan);
         panel.encodeAll(facesContext);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
index 54b8c0982b..89d5ce9a9f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
@@ -51,6 +51,7 @@ public enum TobagoClass implements CssItem {
   CIRCLE__9("tobago-circle-9"),
   CLOSE("tobago-close"),
   COLLAPSED("tobago-collapsed"),
+  COLUMN__PANEL("tobago-column-panel"),
   CONTROLS("tobago-controls"),
   DELETED("tobago-deleted"),
   DESCENDING("tobago-descending"),
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/82-lazy-2/Lazy_2.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/82-lazy-2/Lazy_2.test.js
index 7dddffe26f..ed07821d73 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/82-lazy-2/Lazy_2.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/82-lazy-2/Lazy_2.test.js
@@ -34,7 +34,7 @@ it("focus row index 500 and scroll up", function (done) {
 
   const test = new JasmineTestTool(done);
   test.do(() => timestamp = Date.now());
-  test.wait(() => Date.now() - timestamp > 100);
+  test.wait(() => Date.now() - timestamp > 200);
   test.do(() => focusRowIndex(500));
   test.wait(() => isLoaded(500));
   test.do(() => expect(isLoaded(499)).toBeFalse());
@@ -42,7 +42,7 @@ it("focus row index 500 and scroll up", function (done) {
   test.do(() => expect(isLoaded(530)).toBeFalse());
 
   test.do(() => timestamp = Date.now());
-  test.wait(() => Date.now() - timestamp > 100);
+  test.wait(() => Date.now() - timestamp > 200);
   test.do(() => focusRowIndex(499));
   test.wait(() => isLoaded(470));
   test.do(() => expect(isLoaded(469)).toBeFalse());
@@ -67,13 +67,13 @@ it("focus row index 2, select row 1 and 40, then press 'Period'", function (done
   const test = new JasmineTestTool(done);
   test.setup(() => selectedInput().value === "[]", null, "click", resetSelectedButton);
   test.do(() => timestamp = Date.now());
-  test.wait(() => Date.now() - timestamp > 100);
+  test.wait(() => Date.now() - timestamp > 200);
   test.do(() => focusRowIndex(2));
   test.wait(() => isLoaded(30));
   test.do(() => expect(isLoaded(0, 59)).toBeTrue());
   test.do(() => expect(isLoaded(60)).toBeFalse());
   test.do(() => timestamp = Date.now());
-  test.wait(() => Date.now() - timestamp > 100);
+  test.wait(() => Date.now() - timestamp > 200);
   test.event("click", row1, () => selectedInput().value === "[1]");
   test.event("click", row40, () => selectedInput().value === "[1,40]");
   test.event("click", periodButton, () => Number(actionCountOut().textContent) > actionCount);
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.test.js
new file mode 100644
index 0000000000..0abfe2c83b
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.test.js
@@ -0,0 +1,98 @@
+/*
+ * 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("initial load", function (done) {
+  const submit = elementByIdFn("page:mainForm:submit");
+
+  const test = new JasmineTestTool(done);
+  test.setup(() => isLoaded(0) && isLoaded(9), null, "click", submit);
+  test.do(() => expect(isLoaded(0)).toBeTrue());
+  test.do(() => expect(isLoaded(9)).toBeTrue());
+  test.do(() => expect(isLoaded(10)).toBeFalse());
+  test.start();
+});
+
+it("focus row index 200 and scroll up", function (done) {
+  let timestamp;
+
+  const test = new JasmineTestTool(done);
+  test.do(() => timestamp = Date.now());
+  test.wait(() => Date.now() - timestamp > 200);
+  test.do(() => focusRowIndex(200));
+  test.wait(() => isLoaded(200));
+  test.do(() => expect(isLoaded(199)).toBeFalse());
+  test.do(() => expect(isLoaded(200, 209)).toBeTrue());
+  test.do(() => expect(isLoaded(210)).toBeFalse());
+
+  test.do(() => timestamp = Date.now());
+  test.wait(() => Date.now() - timestamp > 200);
+  test.do(() => focusRowIndex(199));
+  test.wait(() => isLoaded(199));
+  test.do(() => expect(isLoaded(189)).toBeFalse());
+  test.do(() => expect(isLoaded(190, 209)).toBeTrue());
+  test.do(() => expect(isLoaded(210)).toBeFalse());
+  test.start();
+});
+
+it("focus row index 300 and scroll down", function (done) {
+  let timestamp;
+
+  const test = new JasmineTestTool(done);
+  test.do(() => timestamp = Date.now());
+  test.wait(() => Date.now() - timestamp > 200);
+  test.do(() => focusRowIndex(300));
+  test.wait(() => isLoaded(300));
+  test.do(() => expect(isLoaded(299)).toBeFalse());
+  test.do(() => expect(isLoaded(300, 309)).toBeTrue());
+  test.do(() => expect(isLoaded(310)).toBeFalse());
+
+  test.do(() => timestamp = Date.now());
+  test.wait(() => Date.now() - timestamp > 200);
+  test.do(() => focusRowIndex(301));
+  test.wait(() => isLoaded(310));
+  test.do(() => expect(isLoaded(299)).toBeFalse());
+  test.do(() => expect(isLoaded(300, 319)).toBeTrue());
+  test.do(() => expect(isLoaded(320)).toBeFalse());
+  test.start();
+});
+
+function isLoaded(startRow, endRow) {
+  if (endRow === undefined) {
+    endRow = startRow;
+  }
+  for (let i = startRow; i <= endRow; i++) {
+    if (row(i).getAttribute("dummy") != null || rowColumnPanel(i) === null) {
+      return false;
+    }
+  }
+  return true;
+}
+
+function row(rowIndex) {
+  return querySelectorFn("tr[row-index='" + rowIndex + "']")();
+}
+
+function rowColumnPanel(rowIndex) {
+  return querySelectorFn("tr[name='" + rowIndex + "'].tobago-column-panel")();
+}
+
+function focusRowIndex(rowIndex) {
+  querySelectorFn("#page\\:mainForm\\:sheet .tobago-body")().scrollTop = row(rowIndex).offsetTop;
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.xhtml
new file mode 100644
index 0000000000..68f90d803d
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.xhtml
@@ -0,0 +1,60 @@
+<?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:f="jakarta.faces.core"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="jakarta.faces.facelets">
+  <tc:button id="submit" label="submit"/>
+  <tc:button id="ajax" label="Ajax">
+    <f:ajax execute="sheet" render="sheet"/>
+  </tc:button>
+  <tc:button id="resetSelected" label="resetSelected" action="#{sheetController.lazyTwoState.resetSelected()}"/>
+  <tc:panel id="parameter">
+    <tc:out id="timestamp" label="Timestamp" value="#{eventController.currentTimestamp}"/>
+    <tc:out id="selectedRows" label="Selected" value="#{sheetController.lazyTwoState.selectedRows}"/>
+    <tc:out id="actionCount" label="Action count" value="#{sheetController.actionCount}"/>
+    <tc:out id="actionListenerCount" label="ActionListener count" value="#{sheetController.actionListenerCount}"/>
+  </tc:panel>
+
+  <tc:sheet id="sheet" value="#{sheetController.hugeSolarList}" var="luminary"
+            lazyRows="10" lazy="true"
+            columns="1fr" markup="small">
+    <tc:style maxHeight="500px"/>
+    <tc:columnSelector/>
+    <tc:column id="nameColumn" label="Name" sortable="true">
+      <tc:out id="name" value="#{luminary.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit" sortable="true">
+      <tc:button id="orbit" label="#{luminary.orbit}" action="#{sheetController.increaseActionCount()}"
+                 actionListener="#{sheetController.increaseActionListenerCount}"/>
+    </tc:column>
+    <tc:column label="Period (Days)">
+      <tc:button id="period" label="#{luminary.period}" action="#{sheetController.increaseActionCount}"
+                 actionListener="#{sheetController.increaseActionListenerCount}">
+        <f:ajax execute="sheet" render=":::parameter"/>
+      </tc:button>
+    </tc:column>
+    <tc:columnPanel>
+      <tc:in label="Discoverer" value="#{luminary.discoverer}" readonly="true"/>
+      <tc:in label="Year" value="#{luminary.discoverYear}" readonly="true"/>
+    </tc:columnPanel>
+  </tc:sheet>
+</ui:composition>
diff --git a/tobago-theme/src/main/scss/_tobago.scss b/tobago-theme/src/main/scss/_tobago.scss
index 4e7608fb38..0312dc6c68 100644
--- a/tobago-theme/src/main/scss/_tobago.scss
+++ b/tobago-theme/src/main/scss/_tobago.scss
@@ -1639,6 +1639,9 @@ tobago-sheet {
     .table {
       margin-bottom: 0; //remove bootstrap styling; margins are set on tobago-sheet
 
+      .tobago-column-panel {
+      }
+
       td {
         overflow: hidden;
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-css.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-css.ts
index a62e727c8f..8b44c084f4 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-css.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-css.ts
@@ -47,6 +47,7 @@ export enum Css {
   TOAST_CONTAINER = "toast-container",
   TOAST_HEADER = "toast-header",
   TOBAGO_COLLAPSED = "tobago-collapsed",
+  TOBAGO_COLUMN_PANEL = "tobago-column-panel",
   TOBAGO_DISABLED = "tobago-disabled",
   TOBAGO_DROP_ZONE = "tobago-drop-zone",
   TOBAGO_DROPDOWN_MENU = "tobago-dropdown-menu",
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 d4ea792861..ef8b2f500c 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
@@ -75,7 +75,7 @@ export class Sheet extends HTMLElement {
     return ["INPUT", "TEXTAREA", "SELECT", "A", "BUTTON"].indexOf(element.tagName) > -1;
   }
 
-  private static getRowTemplate(columns: number, rowIndex: number): string {
+  private static getDummyRowTemplate(columns: number, rowIndex: number): string {
     return `<tr row-index="${rowIndex}" dummy="dummy">
 <td colspan="${columns}"> </td>
 </tr>`;
@@ -219,34 +219,20 @@ export class Sheet extends HTMLElement {
 
     if (lazy) {
       // prepare the sheet with some auto-created (empty) rows
-      const rowCount = this.rowCount;
-      const sheetBody = this.sheetBody;
       const tableBody = this.tableBody;
       const columns = tableBody.rows[0].cells.length;
-      const firstShownRow = tableBody.rows[0];
-      let current: HTMLTableRowElement = tableBody.rows[0]; // current row in this algorithm, begin with first
-      // the algorithm goes straight through all rows, not selectors, because of performance
-      for (let i = 0; i < rowCount; i++) {
-        if (current) {
-          const rowIndex = Number(current.getAttribute("row-index"));
-          if (i < rowIndex) {
-            const template = Sheet.getRowTemplate(columns, i);
-            current.insertAdjacentHTML("beforebegin", template);
-          } else if (i === rowIndex) {
-            current = current.nextElementSibling as HTMLTableRowElement;
-            // } else { TBD: I think this is not possible
-            //   const template = Sheet.getRowTemplate(columns, i);
-            //   current.insertAdjacentHTML("afterend", template);
-            //   current = current.nextElementSibling as HTMLTableRowElement;
-          }
-        } else {
-          const template = Sheet.getRowTemplate(columns, i);
-          tableBody.insertAdjacentHTML("beforeend", template);
-        }
+
+      const firstRow: HTMLTableRowElement = tableBody.rows[0];
+      for (let i = 0; i < this.getRowIndex(firstRow); i++) {
+        firstRow.insertAdjacentHTML("beforebegin", Sheet.getDummyRowTemplate(columns, i));
+      }
+      const lastRow: HTMLTableRowElement = tableBody.rows[tableBody.rows.length - 1];
+      for (let i = this.getRowIndex(lastRow) + 1; i < this.rowCount; i++) {
+        tableBody.insertAdjacentHTML("beforeend", Sheet.getDummyRowTemplate(columns, i));
       }
 
-      sheetBody.addEventListener("scroll", this.lazyCheck.bind(this));
-      this.sheetBody.scrollTop = firstShownRow.offsetTop; //triggers scroll event -> lazyCheck()
+      this.sheetBody.addEventListener("scroll", this.lazyCheck.bind(this));
+      this.sheetBody.scrollTop = firstRow.offsetTop; //triggers scroll event -> lazyCheck()
     }
 
     // ---------------------------------------------------------------------------------------- //
@@ -346,19 +332,19 @@ export class Sheet extends HTMLElement {
     const rowElements = this.tableBody.rows;
     let min = 0;
     let max = rowElements.length;
-    let rowIndex: number;
+    let index: number;
     while (min < max) {
-      rowIndex = Math.round((max - min) / 2) + min;
-      if (rowElements[rowIndex] === undefined
-          || rowElements[rowIndex].offsetTop > this.sheetBody.scrollTop) {
-        rowIndex--;
-        max = rowIndex;
+      index = Math.round((max - min) / 2) + min;
+      if (rowElements[index] === undefined
+          || rowElements[index].offsetTop > this.sheetBody.scrollTop) {
+        index--;
+        max = index;
       } else {
-        min = rowIndex;
+        min = index;
       }
     }
 
-    return rowIndex;
+    return this.getRowIndex(rowElements[index]);
   }
 
   // -------------------------------------------------------------------------------------- //
@@ -419,36 +405,59 @@ export class Sheet extends HTMLElement {
 
   nextLazyLoad(): number {
     const rows = this.rows > 0 ? this.rows : this.lazyRows;
-    const rowElements = this.tableBody.rows;
     const firstVisibleRowIndex = this.firstVisibleRowIndex;
-
-    for (let rowIndex = firstVisibleRowIndex + 1; rowIndex < firstVisibleRowIndex + rows; rowIndex++) {
-      if (rowIndex >= 0 && rowIndex < rowElements.length && rowElements[rowIndex].hasAttribute("dummy")) {
-        this.upperRowsUpdate = false;
-        if (rowElements[firstVisibleRowIndex].hasAttribute("dummy")) {
-          return firstVisibleRowIndex;
-        } else if (rowIndex + rows - 1 < rowElements.length) {
-          return rowIndex;
-        } else {
-          return rowElements.length - rows;
-        }
+    const firstVisibleRow = this.tableBody.querySelector(`tr[row-index='${firstVisibleRowIndex}']`);
+
+    const maxNextLazyLoad = firstVisibleRowIndex + rows - 1;
+    const nextDummyRowIndex = this.getNextDummyRowIndex(firstVisibleRow.nextElementSibling, rows - 1);
+    if (nextDummyRowIndex && nextDummyRowIndex <= maxNextLazyLoad) {
+      this.upperRowsUpdate = false;
+      if (firstVisibleRow.hasAttribute("dummy")) {
+        return firstVisibleRowIndex;
+      } else {
+        return nextDummyRowIndex;
       }
     }
 
-    for (let rowIndex = firstVisibleRowIndex; rowIndex > firstVisibleRowIndex - rows; rowIndex--) {
-      if (rowIndex >= 0 && rowIndex < rowElements.length && rowElements[rowIndex].hasAttribute("dummy")) {
-        this.upperRowsUpdate = true;
-        if (rowIndex - rows + 1 >= 0) {
-          return rowIndex - rows + 1;
-        } else {
-          return 0;
-        }
-      }
+    const minNextLazyLoad = firstVisibleRowIndex - rows;
+    const prevDummyRowIndex = this.getPreviousDummyRowIndex(firstVisibleRow, rows);
+    if (prevDummyRowIndex && prevDummyRowIndex >= minNextLazyLoad) {
+      this.upperRowsUpdate = true;
+      const prevLazyLoad = prevDummyRowIndex - rows + 1;
+      return prevLazyLoad >= 0 ? prevLazyLoad : 0;
     }
 
     return null;
   }
 
+  private getNextDummyRowIndex(row: Element, iterationCount: number): number {
+    if (row && iterationCount > 0) {
+      if (row.hasAttribute("dummy")) {
+        return Number(row.getAttribute("row-index"));
+      } else if (row.classList.contains(Css.TOBAGO_COLUMN_PANEL)) {
+        return this.getNextDummyRowIndex(row.nextElementSibling, iterationCount);
+      } else {
+        return this.getNextDummyRowIndex(row.nextElementSibling, --iterationCount);
+      }
+    } else {
+      return null;
+    }
+  }
+
+  private getPreviousDummyRowIndex(row: Element, iterationCount: number): number {
+    if (row && iterationCount > 0) {
+      if (row.hasAttribute("dummy")) {
+        return Number(row.getAttribute("row-index"));
+      } else if (row.classList.contains(Css.TOBAGO_COLUMN_PANEL)) {
+        return this.getPreviousDummyRowIndex(row.previousElementSibling, iterationCount);
+      } else {
+        return this.getPreviousDummyRowIndex(row.previousElementSibling, --iterationCount);
+      }
+    } else {
+      return null;
+    }
+  }
+
   lazyResponse(event: EventData): void {
     let updates: NodeListOf<Element>;
     if (event.status === "complete") {
@@ -476,14 +485,26 @@ export class Sheet extends HTMLElement {
           const sheetSelectionMode = this.dataset.tobagoSelectionMode;
           const columnSelectorSelectionMode = this.getSelectorAllCheckbox()?.dataset.tobagoSelectionMode;
           for (const newRow of newRows) {
-            const rowIndex = Number(newRow.getAttribute("row-index"));
-            const row = tbody.querySelector(`tr[row-index='${rowIndex}']`);
-            row.insertAdjacentElement("afterend", newRow);
-            row.remove();
-            if (sheetSelectionMode !== "none") {
-              this.initTableRowForSelection(newRow, sheetSelectionMode);
-            } else if (columnSelectorSelectionMode) {
-              this.initTableCellForSelection(row.querySelector("td:first-child"), columnSelectorSelectionMode);
+            if (newRow.hasAttribute("row-index")) {
+              const rowIndex = Number(newRow.getAttribute("row-index"));
+              const row = tbody.querySelector(`tr[row-index='${rowIndex}']`);
+              row.insertAdjacentElement("afterend", newRow);
+              row.remove();
+              if (sheetSelectionMode !== "none") {
+                this.initTableRowForSelection(newRow, sheetSelectionMode);
+              } else if (columnSelectorSelectionMode) {
+                this.initTableCellForSelection(row.querySelector("td:first-child"), columnSelectorSelectionMode);
+              }
+            } else if (newRow.classList.contains(Css.TOBAGO_COLUMN_PANEL)) {
+              const rowIndex = Number(newRow.getAttribute("name"));
+              const columnPanel = tbody.querySelector(`tr[name='${rowIndex}'].${Css.TOBAGO_COLUMN_PANEL}`);
+              if (columnPanel) {
+                columnPanel.insertAdjacentElement("afterend", newRow);
+                columnPanel.remove();
+              } else {
+                const row = tbody.querySelector(`tr[row-index='${rowIndex}']`);
+                row.insertAdjacentElement("afterend", newRow);
+              }
             }
           }
 
@@ -503,6 +524,15 @@ export class Sheet extends HTMLElement {
     }
   }
 
+  private getRowIndex(row: HTMLTableRowElement): number {
+    if (row.hasAttribute("row-index")) {
+      return Number(row.getAttribute("row-index"));
+    } else if (row.classList.contains(Css.TOBAGO_COLUMN_PANEL)) {
+      return Number(row.getAttribute("name"));
+    }
+    return null;
+  }
+
   lazyError(data: ErrorData): void {
     console.error(`Sheet lazy loading error:
 Error Name: ${data.errorName}


(myfaces-tobago) 02/02: build(theme): rebuild after fixing lazy-sheet

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

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

commit 84b790649ccfb3a53285bfc185e825da7feed344
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Wed May 8 17:10:58 2024 +0200

    build(theme): rebuild after fixing lazy-sheet
---
 tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map | 2 +-
 tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map     | 2 +-
 tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map    | 2 +-
 tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map       | 2 +-
 tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map       | 2 +-
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js             | 4 ++--
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map         | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
index 8642efd556..aa7782ea64 100644
--- a/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-charlotteville/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
+{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
index bae01459af..fa3d59e394 100644
--- a/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-roxborough/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
+{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
index f1462bb51b..e0071b3522 100644
--- a/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-scarborough/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
+{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_bo [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
index 94af5c4d3e..5268b3a5c8 100644
--- a/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-speyside/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/_type.scss [...]
\ No newline at end of file
+{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../scss/_custom.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/_type.scss [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map b/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
index 086efc913a..c0891b7ccf 100644
--- a/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
+++ b/tobago-theme/tobago-theme-standard/src/main/css/tobago.css.map
@@ -1 +1 @@
-{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_border-radius.scss","../. [...]
\ No newline at end of file
+{"version":3,"sources":["tobago.css","../scss/tobago-theme.scss","../../../../node_modules/bootstrap/scss/mixins/_banner.scss","../../../../node_modules/bootstrap/scss/_root.scss","../../../../node_modules/bootstrap/scss/vendor/_rfs.scss","../../../../node_modules/bootstrap/scss/mixins/_color-mode.scss","../../../../node_modules/bootstrap/scss/_reboot.scss","../../../../node_modules/bootstrap/scss/_variables.scss","../../../../node_modules/bootstrap/scss/mixins/_border-radius.scss","../. [...]
\ No newline at end of file
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 7c5d4e0ab4..a4b6b24d98 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -1,4 +1,4 @@
-!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.BOTTOM_0="bottom-0",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.END_0="end-0",e.FADE="fade",e.FIXED_BOTTOM="fixed-bo [...]
+!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.BOTTOM_0="bottom-0",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.END_0="end-0",e.FADE="fade",e.FIXED_BOTTOM="fixed-bo [...]
 /*!
       * Bootstrap v5.3.3 (https://getbootstrap.com/)
       * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
@@ -15,5 +15,5 @@ const Me=new Map,Be={set(e,t,s){Me.has(e)||Me.set(e,new Map);const n=Me.get(e);n
       ${s>0?" tabindex='"+String(s)+"'":""}
       @click="${this.removeBadge.bind(this)}"
       @focus="${this.focusEvent.bind(this)}"
-      @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){var t;const s=e.target.closest(".btn-group").dataset.tobagoValue,n=this.hiddenSelect.querySelector(`[value="${s}"]`);n.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=i.previousElementSibling,r="SPAN"===(null===(t=i.nextElementSibling)||void 0===t?void 0:t.tagName)?i.nextElementSibling:null;o?o.querySelector("button.btn.badge").focus():r?r.querySelector("button.btn.ba [...]
+      @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){var t;const s=e.target.closest(".btn-group").dataset.tobagoValue,n=this.hiddenSelect.querySelector(`[value="${s}"]`);n.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=i.previousElementSibling,r="SPAN"===(null===(t=i.nextElementSibling)||void 0===t?void 0:t.tagName)?i.nextElementSibling:null;o?o.querySelector("button.btn.badge").focus():r?r.querySelector("button.btn.ba [...]
 //# 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 c8e26203a8..ea4df65f36 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-css.ts","../ts/tobago-collapse-operation.ts","../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/@poppe [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-collapse-operation.ts","../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/@poppe [...]
\ No newline at end of file