{# core/ui/templates/partials/components/ui_macros.html Generische UI-Makros – AstrapiFlaskUi V3 Standard-URL-Konventionen: CRUD: POST /api/{module}/{item}/run Debug: POST /api/{module}/{item}/run?debug=true Logs: GET /api/{module}/{item}/logs #} {% macro edit_button(module=None, item=None, container_id=None, loading_id=None, item_prefix='') %} {% endmacro %} {% macro delete_button(module=None, item=None, container_id=None, loading_id=None, description=None, item_prefix='') %} {% endmacro %} {% macro toggle_switch(module=None, item=None, container_id=None, loading_id=None, enabled=False, description=None) %} {% endmacro %} {% macro toggle_button(module=None, item=None, container_id=None, loading_id=None, enabled=False, description=None) %} {{ toggle_switch(module=module, item=item, container_id=container_id, loading_id=loading_id, enabled=enabled, description=description) }} {% endmacro %} {% macro add_button(module=None, container_id=None, loading_id=None) %} {% endmacro %} {% macro action_button(label, url, title=None, css_class="btn-ghost btn-sm", target="body", swap="beforeend") %} {% endmacro %} {% macro status_inline(status) %} {% set _s = status | lower if status else '' %} {% if _s == 'ok' %} OK {% elif _s == 'error' or _s.startswith('fehler') %} Fehler {% elif _s == 'warning' %} Warnung {% elif _s == 'running' or _s == 'building' %} läuft {% elif _s == 'pending' %} ●Pending {% elif _s %} {{ status }} {% else %} Neu {% endif %} {% endmacro %} {% macro refresh_button(endpoint="/", container_id=None, loading_id=None) %} {% endmacro %} {# ── Runnable-Modul-Makros ────────────────────────────────────────────────── #} {# Standard-Konvention: POST /api/{module}/{item}/run[?debug=true] #} {# GET /api/{module}/{item}/logs #} {% macro run_button(module=None, item=None, container_id=None, enabled=True) %} {% endmacro %} {% macro run_debug_button(module=None, item=None, container_id=None) %} {% endmacro %} {% macro log_button(module=None, item=None) %} {% endmacro %} {# ── Button-Basis ─────────────────────────────────────────────────────────── #} {# Alle Text-Buttons bauen auf btn() auf. #} {# Ausnahmen: Icon-Buttons (btn-icon), Sidebar-Nav, Pagination, Kontext-Menüs #} {# btn(label, variant, size, type, onclick, attrs) Basis-Baustein für alle Text-Buttons. Inhalt via label oder {% call %}. variant – ghost | primary | danger (default: ghost) size – sm | '' (leer = kein Modifier) (default: sm) attrs – rohe HTML-Attribute als String, z.B. 'hx-get="..." hx-target="..."' #} {# btn(label, variant, size, type, onclick, attrs, busy_label) busy_label: Text während einer laufenden htmx-Anfrage. htmx setzt dafür die Klasse .htmx-request auf das auslösende Element; die CSS-Regeln in app.css blenden dann Label gegen Spinner + busy_label aus und sperren den Button. #} {% macro btn(label='', variant='ghost', size='sm', type='button', onclick=None, attrs='', busy_label=None) %} {% endmacro %} {% macro btn_cancel(label='Abbrechen') %}{{ btn(label, onclick='closeModal(this)') }}{% endmacro %} {% macro btn_close(label='Schließen') %}{{ btn(label, onclick='closeModal(this)') }}{% endmacro %} {# btn_save(label, type, save_id, disabled) Primär-Button für Formular-Submit. #} {% macro btn_save(label='Speichern', type='submit', save_id=None, disabled=False) %} {% set _id = ('id="' ~ save_id ~ '" ') if save_id else '' %} {{ btn(label, variant='primary', type=type, attrs=_id ~ ('disabled' if disabled else '')) }} {% endmacro %} {# ── Form-Steuerelemente ──────────────────────────────────────────────────── #} {# Alle Formular-Controls bauen auf diesen Macros auf (G-013). #} {# Ausnahmen: hidden-Inputs, multiselect (badge-pill), list (Alpine.js), #} {# filter-selects im List-Header (header_control), borg-Browser #} {# form_group(label, required, help) Caller-Macro: Wrapper für ein Formularfeld (Label + Control + Fehler-Span). #} {% macro form_group(label='', required=False, help='') %}