Collapse optional article search on filament forms
This commit is contained in:
1 parent
b69e1d37bd
commit
0287643b97
3 files changed
+38
-18
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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, '<details class="article-search">')
|
||||
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, '<details class="article-search" open>')
|
||||
self.assertContains(response, "Bitte gib eine Artikelnummer ein.")
|
||||
|
||||
def test_article_lookup_prefills_both_forms_and_preserves_quantity(self):
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
{% extends "base.html" %}{% block title %}{{ title }} · Fil-A-Management{% endblock %}{% block content %}
|
||||
<a class="back-link" href="{% url back_name %}">← Zurück</a><div class="page-heading"><div><p class="eyebrow">AUS DEM GEMEINSAMEN KATALOG</p><h1>{{ title }}</h1><p class="muted">Wähle eine Variante für {{ destination }} oder suche nach ihrer Artikelnummer.</p></div></div>
|
||||
<section class="panel form-panel variant-panel"><form method="post" data-catalog-form>{% csrf_token %}{{ form.non_field_errors }}
|
||||
<div class="field">
|
||||
{{ lookup.article_number.label_tag }}
|
||||
<div class="article-lookup">
|
||||
{{ lookup.article_number }}
|
||||
<button class="button secondary" type="submit" name="action" value="lookup" formnovalidate data-article-lookup>Variante suchen</button>
|
||||
</div>
|
||||
{{ lookup.article_number.errors }}
|
||||
</div>
|
||||
{% if matches %}
|
||||
<details class="article-search"{% if lookup.is_bound %} open{% endif %}>
|
||||
<summary>Nach Artikelnummer suchen <span class="muted">(optional)</span></summary>
|
||||
<div class="field">
|
||||
<label for="article-variant">Mehrere Varianten gefunden</label>
|
||||
{{ lookup.article_number.label_tag }}
|
||||
<div class="article-lookup">
|
||||
<select id="article-variant" name="article_variant">
|
||||
<option value="">Variante auswählen</option>
|
||||
{% for variant in matches %}
|
||||
<option value="{{ variant.pk }}">{{ variant }}{% if variant.net_weight_g %} · {{ variant.net_weight_g }} g{% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button class="button secondary" type="submit" name="action" value="pick" formnovalidate>Auswahl übernehmen</button>
|
||||
{{ lookup.article_number }}
|
||||
<button class="button secondary" type="submit" name="action" value="lookup" formnovalidate data-article-lookup>Variante suchen</button>
|
||||
</div>
|
||||
{{ lookup.article_number.errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if matches %}
|
||||
<div class="field">
|
||||
<label for="article-variant">Mehrere Varianten gefunden</label>
|
||||
<div class="article-lookup">
|
||||
<select id="article-variant" name="article_variant">
|
||||
<option value="">Variante auswählen</option>
|
||||
{% for variant in matches %}
|
||||
<option value="{{ variant.pk }}">{{ variant }}{% if variant.net_weight_g %} · {{ variant.net_weight_g }} g{% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button class="button secondary" type="submit" name="action" value="pick" formnovalidate>Auswahl übernehmen</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</details>
|
||||
<div class="form-grid">{% for field in form %}<div class="field">{{ field.label_tag }}{{ field }}{{ field.errors }}{% if field.help_text %}<small>{{ field.help_text }}</small>{% endif %}</div>{% endfor %}</div>
|
||||
<p class="hint">{% 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 %}</p>
|
||||
<div class="form-actions">
|
||||
|
||||
Reference in new issue
Block a user