From 3710a53b8d4a53b504dd9d02bf77689a24f3a311 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sun, 8 Feb 2026 22:57:11 +0100 Subject: [PATCH] Table, save --- config/current.ver | 2 +- public/assets/js/bridge/table-builder.js | 39 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/config/current.ver b/config/current.ver index eae86f0..9ce730c 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.2.75 +1.2.76 diff --git a/public/assets/js/bridge/table-builder.js b/public/assets/js/bridge/table-builder.js index 20bddd7..8863947 100644 --- a/public/assets/js/bridge/table-builder.js +++ b/public/assets/js/bridge/table-builder.js @@ -27,27 +27,45 @@ ); }; - const buildTableHtml = (rows, cols, existing) => { + const buildTableComponents = (rows, cols, existing) => { const safeRows = Math.max(1, Math.min(20, Number(rows) || 1)); const safeCols = Math.max(1, Math.min(6, Number(cols) || 2)); const cellStyle = "padding:8px;border:1px solid #e2e8f0;font-size:13px"; const headStyle = "text-align:left;padding:8px;border:1px solid #e2e8f0;background-color:#f8fafc;font-size:13px"; - let html = ''; + const tbody = { + tagName: 'tbody', + components: [], + }; for (let r = 0; r < safeRows; r++) { - html += ''; + const row = { tagName: 'tr', components: [] }; for (let c = 0; c < safeCols; c++) { const existingVal = existing?.[r]?.[c] || ''; const label = existingVal || (r === 0 ? `Spalte ${String.fromCharCode(65 + c)}` : `Zeile ${r} / ${c + 1}`); if (r === 0) { - html += `${label}`; + row.components.push({ + tagName: 'th', + attributes: { + style: headStyle, + 'data-gjs-selectable': 'false', + 'data-gjs-draggable': 'false', + }, + components: [{ type: 'textnode', content: label }], + }); } else { - html += `${label}`; + row.components.push({ + tagName: 'td', + attributes: { + style: cellStyle, + 'data-gjs-selectable': 'false', + 'data-gjs-draggable': 'false', + }, + components: [{ type: 'textnode', content: label }], + }); } } - html += ''; + tbody.components.push(row); } - html += ''; - return html; + return [tbody]; }; const openTableModal = (component) => { @@ -117,6 +135,7 @@ if (mdl && typeof mdl.set === 'function') { mdl.set('open', false); } + return false; }); const saveBtn = document.createElement('button'); @@ -129,13 +148,13 @@ const nextRows = Math.max(1, Math.min(20, Number(input.value) || 1)); const nextCols = Math.max(1, Math.min(6, Number(colInput.value) || 1)); const existing = collectTableCells(component); - const html = buildTableHtml(nextRows, nextCols, existing); + const components = buildTableComponents(nextRows, nextCols, existing); component.addAttributes && component.addAttributes({ 'data-bridge-rows': String(nextRows), 'data-bridge-cols': String(nextCols), }); if (component.components) { - component.components(html); + component.components(components); } if (component.view && component.view.render) { component.view.render();