{% extends "admin/base.html" %} {% import "macros/ui.html" as ui %} {% block title %}{% if product %}{{ t(key="edit-product", lang=lang | default(value='sk')) }}{% else %}{{ t(key="new-product", lang=lang | default(value='sk')) }}{% endif %}{% endblock title %} {% block crumb %}{{ t(key="admin-products", lang=lang | default(value='sk')) }}{% endblock crumb %} {% block content %}

{% if product %}{{ t(key="edit-product", lang=lang | default(value='sk')) }}{% else %}{{ t(key="new-product", lang=lang | default(value='sk')) }}{% endif %}

{{ ui::button(variant="outline-secondary", label=t(key="cancel", lang=lang | default(value='sk')), href="/admin/catalog/products", size="px-3 py-2 text-sm") }}
{{ ui::csrf_field() }} {% if product %} {% set v_name = product.name %}{% set v_currency = product.currency %}{% set v_desc = product.description | default(value="") %}{% set v_pub = product.published %} {% else %} {% set v_name = "" %}{% set v_currency = "EUR" %}{% set v_desc = "" %}{% set v_pub = false %} {% endif %} {% set inp = "w-full rounded-radius border border-outline bg-surface-alt px-3 py-2 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark" %} {% set sublabel = "text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70" %}
{{ ui::input(name="name", id="name", required=true, value=v_name) }}
{{ ui::input(name="currency", id="currency", value=v_currency, attrs='maxlength="3"', extra="uppercase") }}
{# --- Variants / options editor ------------------------------------------- #} {# Each product is sold as one or more variants (a free-text label such as #} {# "10cm x 13cm" or "5ml" plus its own price). Price is required. Stock is #} {# optional — leave it blank ("∞") to mark the option simply available (not #} {# inventory-tracked). SKU and business price are optional too. Rows are #} {# managed client-side; names are indexed (variants[i][…]) and read back by #} {# the controller. #} {% set opt = " (" ~ t(key="optional", lang=lang | default(value='sk')) ~ ")" %}
{{ t(key="variants-options", lang=lang | default(value='sk')) }}
{{ ui::textarea(name="description", id="description", rows="5", value=v_desc) }}
{# --- Images gallery ------------------------------------------------------- #} {# Unified drag-orderable gallery: existing images (with id) and new uploads #} {# (placeholder blobs) live in a single list. The full order is submitted as #} {# repeated `image_order` fields — an integer id for kept images or `new` for #} {# each uploaded file. The DataTransfer backing the hidden `image` file input #} {# is rebuilt after every reorder / add / remove so the file-part order matches #} {# the relative order of `new` slots in `image_order`. #}
{{ t(key="images", lang=lang | default(value='sk')) }}

{{ t(key="gallery-hint", lang=lang | default(value='sk')) }}

{# Hidden input carries the accumulated files on submit; the visible picker #} {# only feeds addFiles() and is reset after each pick so selections stack. #}
{{ ui::checkbox(name="published", id="published", label=t(key="published", lang=lang | default(value='sk')), checked=v_pub) }}
{{ ui::button(label=t(key="save", lang=lang | default(value='sk')), type="submit") }} {{ ui::button(variant="outline-secondary", label=t(key="cancel", lang=lang | default(value='sk')), href="/admin/catalog/products") }}
{% endblock content %}