feat: Move category field between name and description in product and kit forms

- Repositioned the category field to appear after the name field in both product and kit creation forms
- Added a quick-link button to create a new category that opens in a new tab
- Updated form field rendering logic to properly display categories in the correct position

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-22 16:35:20 +03:00
parent d60d20d92e
commit b910ae6a6b
2 changed files with 84 additions and 14 deletions

View File

@@ -45,6 +45,28 @@
{% endif %}
</div>
<!-- Категория -->
<div class="mb-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<label class="form-label fw-bold">Категория</label>
<a href="{% url 'products:category-create' %}"
target="_blank"
class="btn btn-sm btn-outline-primary"
title="Создать новую категорию">
<i class="bi bi-plus-circle"></i> Новая
</a>
</div>
<div class="p-3 bg-light rounded">
{{ form.categories }}
</div>
{% if form.categories.help_text %}
<small class="form-text text-muted">{{ form.categories.help_text }}</small>
{% endif %}
{% if form.categories.errors %}
<div class="text-danger">{{ form.categories.errors }}</div>
{% endif %}
</div>
<!-- Описание -->
<div class="mb-3">
{{ form.description.label_tag }}
@@ -221,20 +243,6 @@
<div class="mb-4">
<h5 class="mb-3">Классификация</h5>
<!-- Категории -->
<div class="mb-3">
{{ form.categories.label_tag }}
<div class="p-3 bg-light rounded">
{{ form.categories }}
</div>
{% if form.categories.help_text %}
<small class="form-text text-muted">{{ form.categories.help_text }}</small>
{% endif %}
{% if form.categories.errors %}
<div class="text-danger">{{ form.categories.errors }}</div>
{% endif %}
</div>
<!-- Теги -->
<div class="mb-3">
{{ form.tags.label_tag }}

View File

@@ -128,7 +128,54 @@
<!-- Основная информация о комплекте -->
<h5 class="mb-3">Основная информация</h5>
<!-- Название -->
<div class="mb-3">
{{ form.name.label_tag }}
{{ form.name }}
{% if form.name.help_text %}
<small class="form-text text-muted">{{ form.name.help_text }}</small>
{% endif %}
{% if form.name.errors %}
<div class="text-danger">{{ form.name.errors }}</div>
{% endif %}
</div>
<!-- Категория -->
<div class="mb-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<label class="form-label fw-bold">Категория</label>
<a href="{% url 'products:category-create' %}"
target="_blank"
class="btn btn-sm btn-outline-primary"
title="Создать новую категорию">
<i class="bi bi-plus-circle"></i> Новая
</a>
</div>
<div class="p-3 bg-light rounded">
{{ form.categories }}
</div>
{% if form.categories.help_text %}
<small class="form-text text-muted">{{ form.categories.help_text }}</small>
{% endif %}
{% if form.categories.errors %}
<div class="text-danger">{{ form.categories.errors }}</div>
{% endif %}
</div>
<!-- Описание -->
<div class="mb-3">
{{ form.description.label_tag }}
{{ form.description }}
{% if form.description.help_text %}
<small class="form-text text-muted">{{ form.description.help_text }}</small>
{% endif %}
{% if form.description.errors %}
<div class="text-danger">{{ form.description.errors }}</div>
{% endif %}
</div>
{% for field in form %}
{% if field.name not in 'name,categories,description,tags' %}
{% if field.name == 'fixed_price' %}
<!-- Alert для неактивного поля fixed_price -->
<div id="fixed-price-alert" class="alert alert-warning d-none mb-3" role="alert">
@@ -157,8 +204,23 @@
<div class="text-danger">{{ field.errors }}</div>
{% endif %}
</div>
{% endif %}
{% endfor %}
<!-- Теги -->
<div class="mb-3">
{{ form.tags.label_tag }}
<div class="form-control p-3 bg-light">
{{ form.tags }}
</div>
{% if form.tags.help_text %}
<small class="form-text text-muted">{{ form.tags.help_text }}</small>
{% endif %}
{% if form.tags.errors %}
<div class="text-danger">{{ form.tags.errors }}</div>
{% endif %}
</div>
<hr class="my-4">
<!-- Компоненты комплекта (формсет) -->