added seasons list

This commit is contained in:
2026-02-01 13:25:11 +11:00
parent 96d534f045
commit 81d4ceb354
17 changed files with 660 additions and 679 deletions

View File

@@ -0,0 +1,45 @@
function paginateData(
formID,
rootPath,
initPage,
initPerPage,
initOrder,
initOrderBy,
) {
return {
page: initPage,
perPage: initPerPage,
order: initOrder || "ASC",
orderBy: initOrderBy || "name",
goToPage(n) {
this.page = n;
this.submit();
},
handleSortChange(value) {
const [field, direction] = value.split("|");
this.orderBy = field;
this.order = direction;
this.page = 1; // Reset to first page when sorting
this.submit();
},
setPerPage(n) {
this.perPage = n;
this.page = 1; // Reset to first page when changing per page
this.submit();
},
submit() {
var url = `${rootPath}?page=${this.page}&per_page=${this.perPage}&order=${this.order}&order_by=${this.orderBy}`;
htmx.find("#pagination-page").value = this.page;
htmx.find("#pagination-per-page").value = this.perPage;
htmx.find("#sort-order").value = this.order;
htmx.find("#sort-order-by").value = this.orderBy;
htmx.find(`#${formID}`).setAttribute("hx-post", url);
htmx.process(`#${formID}`);
htmx.trigger(`#${formID}`, "submit");
},
};
}