Update iOS webapp styling and backend target
This commit is contained in:
58
backend/target/backend-1/excel-preview.js
Normal file
58
backend/target/backend-1/excel-preview.js
Normal file
@@ -0,0 +1,58 @@
|
||||
(function () {
|
||||
function isFilled(cell) {
|
||||
return cell !== null && cell !== undefined && String(cell).trim() !== "";
|
||||
}
|
||||
|
||||
function escapeText(value) {
|
||||
return String(value ?? "")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
window.WorkbenchExcelPreview = {
|
||||
filledRows(rows) {
|
||||
return rows.filter(row => Array.isArray(row) && row.some(isFilled));
|
||||
},
|
||||
|
||||
render(containerId, headers, rows) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
|
||||
if (!rows || rows.length === 0) {
|
||||
container.innerHTML = '<div class="empty-preview">Keine Excel-Daten geladen.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const headerHtml = headers
|
||||
.map(header => `<th>${escapeText(header)}</th>`)
|
||||
.join("");
|
||||
|
||||
const bodyHtml = rows
|
||||
.map(row => `<tr>${headers.map((_, index) => `<td>${escapeText(row[index])}</td>`).join("")}</tr>`)
|
||||
.join("");
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="excel-preview-scroll">
|
||||
<table class="excel-preview-table">
|
||||
<thead><tr>${headerHtml}</tr></thead>
|
||||
<tbody>${bodyHtml}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="preview-count">${rows.length} Zeilen geladen</div>
|
||||
`;
|
||||
},
|
||||
|
||||
rowsToObjects(headers, rows) {
|
||||
return rows.map(row => {
|
||||
const obj = {};
|
||||
headers.forEach((header, index) => {
|
||||
obj[header] = row[index] || "";
|
||||
});
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user