From 802cc6b137e1209b93532a9609cedd3f6b1aa281 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 6 Mar 2026 23:11:58 +0100 Subject: [PATCH] refactor(templates): migrate 5 admin pages to shared entity selector macros Remove duplicate Tom Select dark mode CSS (~280 lines) from customers, orders, store-product-create, marketplace-letzshop, and marketplace-products pages. Replace inline store select elements and selected badges with entity_selector() and entity_selected_badge() macros. Co-Authored-By: Claude Opus 4.6 --- .../catalog/admin/store-product-create.html | 46 +------------ .../templates/customers/admin/customers.html | 66 +----------------- .../admin/marketplace-letzshop.html | 48 +------------ .../admin/marketplace-products.html | 66 +----------------- .../orders/templates/orders/admin/orders.html | 69 ++----------------- 5 files changed, 14 insertions(+), 281 deletions(-) diff --git a/app/modules/catalog/templates/catalog/admin/store-product-create.html b/app/modules/catalog/templates/catalog/admin/store-product-create.html index 342ea821..3c0c63bf 100644 --- a/app/modules/catalog/templates/catalog/admin/store-product-create.html +++ b/app/modules/catalog/templates/catalog/admin/store-product-create.html @@ -3,6 +3,7 @@ {% from 'shared/macros/headers.html' import detail_page_header %} {% from 'shared/macros/modals.html' import media_picker_modal %} {% from 'shared/macros/richtext.html' import quill_css, quill_js, quill_editor %} +{% from 'shared/macros/inputs.html' import entity_selector %} {% block title %}Create Store Product{% endblock %} @@ -16,48 +17,6 @@ {{ quill_js() }} {% endblock %} -{% block extra_head %} - - - -{% endblock %} - {% block content %} {% call detail_page_header("'Create Store Product'", '/admin/store-products') %} Add a new product to a store's catalog @@ -72,8 +31,7 @@
- + {{ entity_selector(ref_name='storeSelect', id='store-select', placeholder='Search store...', width='w-full') }}

The store whose catalog this product will be added to

diff --git a/app/modules/customers/templates/customers/admin/customers.html b/app/modules/customers/templates/customers/admin/customers.html index 6b643fce..aff73f51 100644 --- a/app/modules/customers/templates/customers/admin/customers.html +++ b/app/modules/customers/templates/customers/admin/customers.html @@ -5,84 +5,24 @@ {% from 'shared/macros/tables.html' import table_wrapper, table_header %} {% from 'shared/macros/pagination.html' import pagination %} {% from 'shared/macros/modals.html' import confirm_modal_dynamic %} +{% from 'shared/macros/inputs.html' import entity_selector, entity_selected_badge %} {% block title %}Customers{% endblock %} {% block alpine_data %}adminCustomers(){% endblock %} -{% block extra_head %} - - - -{% endblock %} - {% block content %} {% call page_header_flex(title='Customer Management', subtitle='Manage customers across all stores') %}
-
- -
+ {{ entity_selector(ref_name='storeSelect', id='store-select', placeholder='Filter by store...') }} {{ refresh_button(loading_var='loading', onclick='resetAndLoad()', variant='secondary') }}
{% endcall %} -
-
-
-
- -
-
- - -
-
- -
-
+{{ entity_selected_badge(entity_var='selectedStore', clear_fn='clearStoreFilter()', code_field='store_code', color='purple') }} {{ loading_state('Loading customers...') }} diff --git a/app/modules/marketplace/templates/marketplace/admin/marketplace-letzshop.html b/app/modules/marketplace/templates/marketplace/admin/marketplace-letzshop.html index ec5b9d16..8fa6451c 100644 --- a/app/modules/marketplace/templates/marketplace/admin/marketplace-letzshop.html +++ b/app/modules/marketplace/templates/marketplace/admin/marketplace-letzshop.html @@ -5,61 +5,17 @@ {% from 'shared/macros/headers.html' import page_header_flex, refresh_button %} {# Import modals macro - custom modals below use inline definition for specialized forms #} {% from 'shared/macros/modals.html' import modal_simple, confirm_modal %} +{% from 'shared/macros/inputs.html' import entity_selector %} {% block title %}Letzshop Management{% endblock %} {% block alpine_data %}adminMarketplaceLetzshop(){% endblock %} -{% block extra_head %} - - - -{% endblock %} - {% block content %} {% call page_header_flex(title='Letzshop Management', subtitle='Manage Letzshop integration for stores') %}
-
- -
+ {{ entity_selector(ref_name='storeSelect', id='store-select', placeholder='Search store...') }} {{ refresh_button(loading_var='loading', onclick='refreshData()', variant='secondary') }}
{% endcall %} diff --git a/app/modules/marketplace/templates/marketplace/admin/marketplace-products.html b/app/modules/marketplace/templates/marketplace/admin/marketplace-products.html index c6b38687..505056e9 100644 --- a/app/modules/marketplace/templates/marketplace/admin/marketplace-products.html +++ b/app/modules/marketplace/templates/marketplace/admin/marketplace-products.html @@ -5,84 +5,24 @@ {% from 'shared/macros/alerts.html' import loading_state, error_state %} {% from 'shared/macros/tables.html' import table_wrapper, table_header %} {% from 'shared/macros/modals.html' import modal_simple %} +{% from 'shared/macros/inputs.html' import entity_selector, entity_selected_badge %} {% block title %}Marketplace Products{% endblock %} {% block alpine_data %}adminMarketplaceProducts(){% endblock %} -{% block extra_head %} - - - -{% endblock %} - {% block content %} {% call page_header_flex(title='Marketplace Products', subtitle='Master product repository - Browse all imported products from external sources') %}
-
- -
+ {{ entity_selector(ref_name='storeSelect', id='store-select', placeholder='Filter by store...') }} {{ refresh_button(loading_var='loading', onclick='refresh()', variant='secondary') }}
{% endcall %} -
-
-
-
- -
-
- - -
-
- -
-
+{{ entity_selected_badge(entity_var='selectedStore', clear_fn='clearStoreFilter()', code_field='store_code', color='purple') }} {{ loading_state('Loading products...') }} diff --git a/app/modules/orders/templates/orders/admin/orders.html b/app/modules/orders/templates/orders/admin/orders.html index 854150a7..7816d87a 100644 --- a/app/modules/orders/templates/orders/admin/orders.html +++ b/app/modules/orders/templates/orders/admin/orders.html @@ -5,85 +5,24 @@ {% from 'shared/macros/alerts.html' import loading_state, error_state %} {% from 'shared/macros/tables.html' import table_wrapper %} {% from 'shared/macros/modals.html' import modal_simple %} -{% from 'shared/macros/inputs.html' import store_selector %} +{% from 'shared/macros/inputs.html' import entity_selector, entity_selected_badge %} {% block title %}Orders{% endblock %} {% block alpine_data %}adminOrders(){% endblock %} -{% block extra_head %} - - - -{% endblock %} - {% block content %} {% call page_header_flex(title='Orders', subtitle='Manage orders across all stores') %}
-
- -
+ {{ entity_selector(ref_name='storeSelect', id='store-select', placeholder='Search store...') }} {{ refresh_button(loading_var='loading', onclick='refresh()', variant='secondary') }}
{% endcall %} - -
-
-
-
- -
-
- - -
-
- -
-
+ +{{ entity_selected_badge(entity_var='selectedStore', clear_fn='clearStoreFilter()', code_field='store_code', color='purple') }} {{ loading_state('Loading orders...') }}