From 0287643b975feaef4c6402d7a386fff58c8edbdc Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:24:29 +0100 Subject: [PATCH] Collapse optional article search on filament forms --- filament/static/filament/app.css | 15 ++++++++++ filament/tests/test_catalog.py | 2 ++ templates/filament/select_variant.html | 39 ++++++++++++++------------ 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/filament/static/filament/app.css b/filament/static/filament/app.css index 300ff0c..13ee378 100644 --- a/filament/static/filament/app.css +++ b/filament/static/filament/app.css @@ -589,6 +589,21 @@ td.quantity { .variant-panel { overflow: visible; } +.article-search { + margin-bottom: 16px; + border-bottom: 1px solid var(--line); +} +.article-search summary { + padding: 0 0 12px; + color: var(--green); + cursor: pointer; + font-size: 13px; + font-weight: 650; +} +.article-search summary .muted { + font-size: inherit; + font-weight: 500; +} .article-lookup { display: flex; align-items: center; diff --git a/filament/tests/test_catalog.py b/filament/tests/test_catalog.py index 13263dc..c57fd47 100644 --- a/filament/tests/test_catalog.py +++ b/filament/tests/test_catalog.py @@ -144,6 +144,7 @@ class CatalogTests(CatalogTestCase): url = f"/{path}/hinzufuegen/" response = self.client.get(url) article_input = response.context["lookup"]["article_number"].as_widget() + self.assertContains(response, '
') self.assertIn('name="article_number"', article_input) self.assertNotIn("required", article_input) self.assertRedirects( @@ -151,6 +152,7 @@ class CatalogTests(CatalogTestCase): ) self.assertEqual(model.objects.get(variant=self.spool).quantity, 1) response = self.client.post(url, {"action": "lookup", "article_number": ""}) + self.assertContains(response, '
') self.assertContains(response, "Bitte gib eine Artikelnummer ein.") def test_article_lookup_prefills_both_forms_and_preserves_quantity(self): diff --git a/templates/filament/select_variant.html b/templates/filament/select_variant.html index 5f4043f..fba9829 100644 --- a/templates/filament/select_variant.html +++ b/templates/filament/select_variant.html @@ -1,28 +1,31 @@ {% extends "base.html" %}{% block title %}{{ title }} · Fil-A-Management{% endblock %}{% block content %} ← Zurück

AUS DEM GEMEINSAMEN KATALOG

{{ title }}

Wähle eine Variante für {{ destination }} oder suche nach ihrer Artikelnummer.

{% csrf_token %}{{ form.non_field_errors }} -
- {{ lookup.article_number.label_tag }} -
- {{ lookup.article_number }} - -
- {{ lookup.article_number.errors }} -
- {% if matches %} +
+ Nach Artikelnummer suchen (optional)
- + {{ lookup.article_number.label_tag }}
- - + {{ lookup.article_number }} +
+ {{ lookup.article_number.errors }}
- {% endif %} + {% if matches %} +
+ +
+ + +
+
+ {% endif %} +
{% for field in form %}
{{ field.label_tag }}{{ field }}{{ field.errors }}{% if field.help_text %}{{ field.help_text }}{% endif %}
{% endfor %}

{% if form.for_inventory %}Wähle bei der Spulenausführung, wie die Rolle bei dir vorliegt.{% else %}Jede Auswahl grenzt die folgenden Optionen ein. Nur aktive, angelegte Varianten sind wählbar.{% endif %}