{# Modal Macros ============ Reusable modal dialog components with Alpine.js integration. Usage: {% from 'shared/macros/modals.html' import modal, confirm_modal, form_modal %} Basic modal: {% call modal('editModal', 'Edit User', 'isEditModalOpen') %}

Modal content here

{% endcall %} Confirmation modal: {{ confirm_modal('deleteModal', 'Delete User', 'Are you sure?', 'deleteUser()', 'isDeleteModalOpen') }} Required Alpine.js: x-data="{ isModalOpen: false }" #} {# Modal ===== A flexible modal dialog component. Parameters: - id: Unique modal ID - title: Modal title - show_var: Alpine.js variable controlling visibility (default: 'isModalOpen') - size: 'sm' | 'md' | 'lg' | 'xl' | 'full' (default: 'md') - show_close: Whether to show close button (default: true) - show_footer: Whether to show footer slot (default: true) - close_on_backdrop: Close when clicking backdrop (default: true) - close_on_escape: Close on Escape key (default: true) #} {% macro modal(id, title, show_var='isModalOpen', size='md', show_close=true, show_footer=true, close_on_backdrop=true, close_on_escape=true) %} {% set sizes = { 'sm': 'max-w-sm', 'md': 'max-w-lg', 'lg': 'max-w-2xl', 'xl': 'max-w-4xl', 'full': 'max-w-full mx-4' } %} {% endmacro %} {# Modal Simple ============ A simpler modal without the caller pattern - just pass content. Parameters: - id: Unique modal ID - title: Modal title - show_var: Alpine.js variable controlling visibility - size: Modal size - content: HTML content for the modal body #} {% macro modal_simple(id, title, show_var='isModalOpen', size='md') %} {% set sizes = { 'sm': 'max-w-sm', 'md': 'max-w-lg', 'lg': 'max-w-2xl', 'xl': 'max-w-4xl' } %} {% endmacro %} {# Confirm Modal ============= A confirmation dialog for destructive actions. Parameters: - id: Unique modal ID - title: Modal title - message: Confirmation message - confirm_action: Alpine.js action to execute on confirm - show_var: Alpine.js variable controlling visibility - confirm_text: Confirm button text (default: 'Confirm') - cancel_text: Cancel button text (default: 'Cancel') - variant: 'danger' | 'warning' | 'info' (default: 'danger') - icon: Icon name (optional, auto-selected based on variant) #} {% macro confirm_modal(id, title, message, confirm_action, show_var='isConfirmModalOpen', confirm_text='Confirm', cancel_text='Cancel', variant='danger', icon=none) %} {% set variants = { 'danger': { 'icon_bg': 'bg-red-100 dark:bg-red-900/30', 'icon_color': 'text-red-600 dark:text-red-400', 'btn_class': 'bg-red-600 hover:bg-red-700 focus:ring-red-500' }, 'warning': { 'icon_bg': 'bg-yellow-100 dark:bg-yellow-900/30', 'icon_color': 'text-yellow-600 dark:text-yellow-400', 'btn_class': 'bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500' }, 'info': { 'icon_bg': 'bg-blue-100 dark:bg-blue-900/30', 'icon_color': 'text-blue-600 dark:text-blue-400', 'btn_class': 'bg-blue-600 hover:bg-blue-700 focus:ring-blue-500' } } %} {% set icons = { 'danger': 'exclamation-triangle', 'warning': 'exclamation', 'info': 'information-circle' } %} {% set modal_icon = icon if icon else icons[variant] %} {% set style = variants[variant] %} {% endmacro %} {# Form Modal ========== A modal optimized for forms with loading state support. Parameters: - id: Unique modal ID - title: Modal title - show_var: Alpine.js variable controlling visibility - submit_action: Alpine.js action for form submission - submit_text: Submit button text (default: 'Save') - loading_var: Alpine.js variable for loading state (default: 'saving') - loading_text: Text shown while loading (default: 'Saving...') - size: Modal size (default: 'md') #} {% macro form_modal(id, title, show_var='isFormModalOpen', submit_action='submitForm()', submit_text='Save', loading_var='saving', loading_text='Saving...', size='md') %} {% set sizes = { 'sm': 'max-w-sm', 'md': 'max-w-lg', 'lg': 'max-w-2xl', 'xl': 'max-w-4xl' } %} {% endmacro %} {# Slide-over Panel ================ A side panel that slides in from the right. Parameters: - id: Unique panel ID - title: Panel title - show_var: Alpine.js variable controlling visibility - width: 'sm' | 'md' | 'lg' | 'xl' (default: 'md') #} {% macro slide_over(id, title, show_var='isPanelOpen', width='md') %} {% set widths = { 'sm': 'max-w-sm', 'md': 'max-w-md', 'lg': 'max-w-lg', 'xl': 'max-w-xl' } %} {% endmacro %} {# Job Details Modal ================= A mobile-friendly modal for displaying import job details. Used in marketplace and imports admin pages. Parameters: - show_var: Alpine.js variable controlling visibility (default: 'showJobModal') - job_var: Alpine.js variable containing the job data (default: 'selectedJob') - close_action: Alpine.js action to close modal (default: 'closeJobModal()') - get_vendor_name: Function to get vendor name from ID (default: 'getVendorName') - show_created_by: Whether to show Created By field (default: false) Required Alpine.js state: - showJobModal: boolean - selectedJob: object with job data (fields: id, vendor_id, marketplace, status, source_url, imported, updated, error_count, total_processed, started_at, completed_at, language) - closeJobModal(): function to close and clear - getVendorName(id): function to resolve vendor name - formatDate(date): function to format dates #} {% macro job_details_modal(show_var='showJobModal', job_var='selectedJob', close_action='closeJobModal()', get_vendor_name='getVendorName', show_created_by=false) %}
{# Modal Header #}

Import Job #

{# Modal Content #}
{# Status Badge #}
Status
{# Progress Stats Cards #}

Imported

Updated

Errors

Total

{# Details Table #}
{% if show_created_by %} {% endif %}
Vendor
Marketplace
Language
Source URL
Started At
Completed At
Created By
{# Error Message #}

Error Message

{# Detailed Import Errors #}

Import Errors

{# Errors List #}
{# Pagination for errors #}
Showing of errors
{# Modal Footer #}
{% endmacro %}