diff --git a/app/templates/admin/subscription-tiers.html b/app/templates/admin/subscription-tiers.html index 6aa5402b..038ac915 100644 --- a/app/templates/admin/subscription-tiers.html +++ b/app/templates/admin/subscription-tiers.html @@ -3,7 +3,7 @@ {% extends "admin/base.html" %} {% from 'shared/macros/alerts.html' import alert_dynamic, error_state %} {% from 'shared/macros/headers.html' import page_header_refresh %} -{% from 'shared/macros/tables.html' import table_wrapper, table_header_custom, th_sortable, empty_state %} +{% from 'shared/macros/tables.html' import table_wrapper, table_header_custom, th_sortable %} {% from 'shared/macros/modals.html' import modal_confirm %} {% block title %}Subscription Tiers{% endblock %} diff --git a/app/templates/shared/macros/tables.html b/app/templates/shared/macros/tables.html index 2940986b..edaa2341 100644 --- a/app/templates/shared/macros/tables.html +++ b/app/templates/shared/macros/tables.html @@ -69,6 +69,65 @@ {% endmacro %} +{# + Sortable Table Header Cell (th_sortable) + ======================================== + Renders a single sortable table header cell for use inside table_header_custom. + + Parameters: + - key: The data key/column name for sorting + - label: Display label for the column + - sort_func: Alpine.js function name to call on click (default: 'sortBy') + - sort_order_var: Alpine.js variable for current sort order (default: 'sortOrder') + + Usage: + {% call table_header_custom() %} + {{ th_sortable('name', 'Name', 'sortBy', 'sortOrder') }} + {{ th_sortable('created_at', 'Created', 'sortBy', 'sortOrder') }} + Actions + {% endcall %} + + Required Alpine.js: + sortBy: '', + sortOrder: 'asc', + handleSort(key) { + if (this.sortBy === key) { + this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc'; + } else { + this.sortBy = key; + this.sortOrder = 'asc'; + } + this.loadData(); + } +#} +{% macro th_sortable(key, label, sort_func='sortBy', sort_order_var='sortOrder') %} + + + +{% endmacro %} + + {# Sortable Table Header =====================