{# Plugin Configuration Partial - Server-side rendered form #} {# This template is loaded via HTMX when a plugin tab is clicked #} {# ===== MACROS FOR FORM FIELD GENERATION ===== #} {# Render a single form field based on schema type #} {% macro render_field(key, prop, value, prefix='', plugin_id='') %} {% set full_key = (prefix ~ '.' ~ key) if prefix else key %} {% set field_id = (plugin_id ~ '-' ~ full_key)|replace('.', '-')|replace('_', '-') %} {% set label = prop.title if prop.title else key|replace('_', ' ')|title %} {% set description = prop.description if prop.description else '' %} {% set field_type = prop.type if prop.type is string else (prop.type[0] if prop.type is iterable else 'string') %} {# Handle nested objects recursively #} {% if field_type == 'object' and prop.properties %} {{ render_nested_section(key, prop, value, prefix, plugin_id) }} {% else %}
{{ description }}
{% endif %} {# Boolean checkbox #} {% if field_type == 'boolean' %} {# Enum dropdown #} {% elif prop.enum %} {# Number input #} {% elif field_type in ['number', 'integer'] %} {# Array - check if it's a file upload widget #} {% elif field_type == 'array' %} {% set x_widget = prop.get('x-widget') or prop.get('x_widget') %} {% if x_widget == 'file-upload' %} {# File upload widget for arrays #} {% set upload_config = prop.get('x-upload-config') or {} %} {% set max_files = upload_config.get('max_files', 10) %} {% set allowed_types = upload_config.get('allowed_types', ['image/png', 'image/jpeg', 'image/bmp', 'image/gif']) %} {% set max_size_mb = upload_config.get('max_size_mb', 5) %} {% set plugin_id_from_config = upload_config.get('plugin_id', plugin_id) %} {% set array_value = value if value is not none and value is iterable and value is not string else (prop.default if prop.default is defined and prop.default is iterable and prop.default is not string else []) %}Drag and drop images here or click to browse
Max {{ max_files }} files, {{ max_size_mb }}MB each (PNG, JPG, GIF, BMP)
Remember to save configuration after upload
{{ img.get('original_filename') or img.get('filename', 'Image') }}
{% if img.get('size') %}{{ (img.get('size') / 1024)|round }} KB{% endif %} {% if img.get('uploaded_at') %} • {{ img.get('uploaded_at') }}{% endif %}
{% if has_schedule %}Scheduled
{% endif %}Separate multiple values with commas
{% endif %} {# Text input (default) #} {% else %} {% endif %}{{ plugin.description or 'Plugin configuration' }}