This commit is contained in:
MatthieuHR committed 2026-11-09 09:27:53 +00:00
1 parent fc961f6511
commit fb25e4586e
6 files changed
+99 -47

No files matched your search

+49 -26
View File
@@ -20,26 +20,35 @@
{% endmacro %}
{% macro action_row(f) %}
<div class="action-row">
{% for h in f.hidden_fields() %}{{ h }}{% endfor %}
{{ f.non_field_errors() }}
{% for field in f.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
{% macro action_row(f, removable=true) %}
<div>
<div class="action-row">
{% for h in f.hidden_fields() %}{{ h }}{% endfor %}
{{ f.non_field_errors() }}
{% for field in f.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
{% for b in f.blocks %}
<fieldset x-cloak
x-show="action === '{{ b.action }}'"
:disabled="action !== '{{ b.action }}'">
<legend>{{ b.label }}</legend>
{{ b.form.non_field_errors() }}
{% for h in b.form.hidden_fields() %}{{ h }}{% endfor %}
{% for field in b.form.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
</fieldset>
{% endfor %}
{% for b in f.blocks %}
<fieldset x-cloak
x-show="action === '{{ b.action }}'"
:disabled="action !== '{{ b.action }}'">
{{ b.form.non_field_errors() }}
{% for h in b.form.hidden_fields() %}{{ h }}{% endfor %}
{% for field in b.form.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
</fieldset>
{% endfor %}
{% if removable %}
<button class="btn btn-grey" type="button"
@click.prevent="$el.closest('.action-row').parentElement.remove()">
<i class="fa fa-minus"></i>
{% trans %}Remove{% endtrans %}
</button>
{% endif %}
</div>
<hr class="margin-bottom">
</div>
{% endmacro %}
@@ -59,9 +68,14 @@
</script>
{% endblock %}
{% block title %}
{% trans %}New stock action{% endtrans %}
{% endblock %}
{% block content %}
<h2>{% trans %}New stock action in {% endtrans %}{{ stock.name }}</h2>
{% set action_value = form["action"].value() %}
@@ -70,9 +84,12 @@
{% csrf_token %}
{{ form.non_field_errors() }}
{% for field in form.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
<div class="margin-bottom">
{% for field in form.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
<hr>
</div>
<div x-data="rows('{{ formset.prefix }}', {{ formset.total_form_count() }})">
<input type="hidden" name="{{ formset.prefix }}-TOTAL_FORMS" :value="total">
@@ -82,8 +99,10 @@
{{ formset.non_form_errors() }}
<h3 class="margin-bottom">{% trans %}Items{% endtrans %}</h3>
{% for f in formset %}
{{ action_row(f) }}
{{ action_row(f, not loop.first) }}
{% endfor %}
<template x-for="i in added" :key="i">
@@ -94,9 +113,13 @@
{{ action_row(empty_form) }}
</template>
<button type="button" @click="add()">{% trans %}Ajouter{% endtrans %}</button>
<div>
<button class="btn btn-grey" type="button" @click="add()">
<i class="fa fa-plus"></i>
{% trans %}Add{% endtrans %}
</button>
<button class="btn btn-blue" type="submit">{% trans %}Save{% endtrans %}</button>
</div>
</div>
<button type="submit">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+28 -12
View File
@@ -7,27 +7,43 @@
{% block title %}{% trans %}Create stock item{% endtrans %}{% endblock %}
{% block content %}
<h2>{% trans %}Create stock item{% endtrans %}</h2>
<h2>{% trans %}Create stock items in{% endtrans %}{{ stock.name }}</h2>
<form method="post" x-data="dynamicFormSet({ prefix: '{{ formset.prefix }}' })">
{% csrf_token %}
{{ formset.management_form }}
<div x-ref="formContainer">
<div x-ref="formContainer" class="margin-bottom">
{% for item_form in formset.forms %}
<fieldset>
<legend>{% trans %}Item{% endtrans %}</legend>
{{ item_form.as_p() }}
</fieldset>
<div>
<fieldset>
{{ item_form.as_p() }}
{% if not loop.first %}
<button type="button" class="btn btn-grey"
@click.prevent="removeForm($event.target.closest('div'))">
<i class="fa fa-minus"></i> {% trans %}Remove{% endtrans %}
</button>
{% endif %}
</fieldset>
<hr>
</div>
{% endfor %}
</div>
<template x-ref="formTemplate">
<fieldset>
<legend>{% trans %}Item{% endtrans %}</legend>
{{ formset.empty_form.as_p() }}
</fieldset>
<template x-ref="formTemplate" class="margin-bottom">
<div class="margin-bottom">
<fieldset>
<div class="margin-bottom">
{{ formset.empty_form.as_p() }}
</div>
<button type="button" class="btn btn-grey"
@click.prevent="removeForm($event.target.closest('div'))">
<i class="fa fa-minus"></i> {% trans %}Remove{% endtrans %}
</button>
</fieldset>
<hr>
</div>
</template>
<button type="button" class="btn btn-grey" @click.prevent="addForm()">
<i class="fa fa-plus"></i> {% trans %}Add an item{% endtrans %}
</button>
<button type="submit">{% trans %}Save{% endtrans %}</button>
<button type="submit" class="btn btn-blue">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+9 -7
View File
@@ -5,16 +5,18 @@
{% block content %}
<h3>{% trans %}Items in {% endtrans %}{{ stock.name }}</h3>
{% if is_editor %}
<a href="{{ url('stock:items_create', club_id=club.id, stock_id=stock.id) }}">
{% trans %}Create items{% endtrans %}
</a>
<a href="{{ url('stock:action_create', club_id=club.id, stock_id=stock.id) }}">
{% trans %}Create action{% endtrans %}
</a>
<div>
<a href="{{ url('stock:items_create', club_id=club.id, stock_id=stock.id) }}" class="btn btn-blue">
{% trans %}Create items{% endtrans %}
</a>
<a href="{{ url('stock:action_create', club_id=club.id, stock_id=stock.id) }}" class="btn btn-blue">
{% trans %}Create action{% endtrans %}
</a>
</div>
{% endif %}
{% if items %}
{% for item in items %}
<div>
<div class="card card-row shadow">
<div>
<p>{{ item.name }}</p>
<p>{% trans %}Last known quantity: {% endtrans %}{{ item.last_known_quantity }}</p>