/** * Generic list page engine. * * Reads the resource slug from
, looks up its * schema in Resources and renders a DaisyUI table with server-side * pagination, sorting and search, plus loading / empty / error states. */ (function () { "use strict"; const PAGE_SIZE = 10; document.addEventListener("DOMContentLoaded", () => { const body = document.body; if (body.dataset.page !== "list") return; if (!Auth.requireAuth()) return; const slug = body.dataset.resource; const schema = Resources[slug]; if (!schema) return; const els = { head: document.getElementById("list-head"), body: document.getElementById("list-body"), state: document.getElementById("list-state"), search: document.getElementById("list-search"), pagination: document.getElementById("list-pagination"), parentWrap: document.getElementById("list-parent-filter"), parentSelect: document.getElementById("list-parent-select"), count: document.getElementById("list-count"), }; const state = { page: 1, limit: PAGE_SIZE, search: "", sort: "", order: "desc", parentId: null, }; const columnCount = schema.columns.length + 1; // + actions // ----- rendering helpers ------------------------------------------------- function renderHead() { const cells = schema.columns .map((column) => { if (!column.sortKey) { return `Nothing here yet${state.search ? " for “" + UI.escapeHtml(state.search) + "”" : ""}.
Create the first one${UI.escapeHtml(error.message)}