Proposition V1

This commit is contained in:
MarrhieuHR authored and MatthieuHR committed 2026-11-09 09:19:41 +01:00
1 parent bfa5fa45b8
commit fc961f6511
36 files changed
+1984

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
{% extends "core/base.jinja" %}
{% macro field_row(field) %}
<div
{% if field.name == "item" %}
x-data="{ existingQuantity: null }"
x-init="existingQuantity = $el.querySelector('select')?.selectedOptions[0]?.dataset.quantity ?? null"
@change="existingQuantity = $event.target.selectedOptions[0]?.dataset.quantity ?? null"
{% endif %}
{% if field.field.widget.attrs.get("x-show") %} x-show="{{ field.field.widget.attrs.get("x-show") }}"{% endif %}
>
{{ field.label_tag() }} {{ field }} {{ field.errors }}
{% if field.name == "item" %}
<div x-show="existingQuantity !== null">
Quantité actuelle :
<span x-text="existingQuantity"></span>
</div>
{% endif %}
</div>
{% 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 %}
{% 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 %}
</div>
{% endmacro %}
{% block script %}
<script>
document.addEventListener("alpine:init", () => {
Alpine.data("rows", (prefix, base) => ({
prefix, base, added: [],
get total() { return this.base + this.added.length },
add() { this.added.push(this.base + this.added.length) },
html(i) {
return this.$refs.tpl.innerHTML.replaceAll(
`${this.prefix}-__prefix__`, `${this.prefix}-${i}`)
},
}))
})
</script>
{% endblock %}
{% block content %}
{% set action_value = form["action"].value() %}
<form method="post" enctype="multipart/form-data"
x-data="{ action: '{{ action_value if action_value is not none else '' }}' }">
{% csrf_token %}
{{ form.non_field_errors() }}
{% for field in form.visible_fields() %}
{{ field_row(field) }}
{% endfor %}
<div x-data="rows('{{ formset.prefix }}', {{ formset.total_form_count() }})">
<input type="hidden" name="{{ formset.prefix }}-TOTAL_FORMS" :value="total">
{{ formset.management_form["INITIAL_FORMS"] }}
{{ formset.management_form["MIN_NUM_FORMS"] }}
{{ formset.management_form["MAX_NUM_FORMS"] }}
{{ formset.non_form_errors() }}
{% for f in formset %}
{{ action_row(f) }}
{% endfor %}
<template x-for="i in added" :key="i">
<div x-html="html(i)"></div>
</template>
<template x-ref="tpl">
{{ action_row(empty_form) }}
</template>
<button type="button" @click="add()">{% trans %}Ajouter{% endtrans %}</button>
</div>
<button type="submit">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+12
View File
@@ -0,0 +1,12 @@
{% extends "core/base.jinja" %}
{% block title %}{% trans %}Create stock{% endtrans %}{% endblock %}
{% block content %}
<h2>{% trans %}Create stock{% endtrans %}</h2>
<form method="post" action="">
{% csrf_token %}
{{ form.as_p() }}
<button type="submit">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+12
View File
@@ -0,0 +1,12 @@
{% extends "core/base.jinja" %}
{% block title %}{% trans %}Edit stock{% endtrans %}{% endblock %}
{% block content %}
<h2>{% trans %}Edit stock{% endtrans %}</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p() }}
<button type="submit">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+38
View File
@@ -0,0 +1,38 @@
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Stock{% endtrans %}
{% endblock %}
{% block content %}
<h2>{% trans %}Stock{% endtrans %}</h2>
{% if is_editor %}
<p>
<a href="{{ url('stock:create', club_id=club.id) }}">
{% trans %}Create a stock{% endtrans %}
</a>
</p>
{% endif %}
{% if stocks %}
<ul>
{% for stock in stocks %}
{% if stock.can_be_view_by_board or is_editor %}
<li>
<a href="{{ url('stock:items_list', club_id=club.id, stock_id=stock.id) }}">
{{ stock.name }}
</a>
{% if is_editor %}
<a href="{{ url('stock:edit', club_id=club.id, stock_id=stock.id) }}">
{% trans %}Edit{% endtrans %}
</a>
{% endif %}
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<p>{% trans %}No stock has been created yet.{% endtrans %}</p>
{% endif %}
{% endblock %}
+12
View File
@@ -0,0 +1,12 @@
{% extends "core/base.jinja" %}
{% block title %}{% trans %}Edit stock item{% endtrans %}{% endblock %}
{% block content %}
<h2>{% trans %}Edit stock item{% endtrans %}</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p() }}
<button type="submit">{% trans %}Save{% endtrans %}</button>
</form>
{% endblock %}
+33
View File
@@ -0,0 +1,33 @@
{% extends "core/base.jinja" %}
{% block additional_js %}
<script type="module" src="{{ static("bundled/core/dynamic-formset-index.ts") }}"></script>
{% endblock %}
{% block title %}{% trans %}Create stock item{% endtrans %}{% endblock %}
{% block content %}
<h2>{% trans %}Create stock item{% endtrans %}</h2>
<form method="post" x-data="dynamicFormSet({ prefix: '{{ formset.prefix }}' })">
{% csrf_token %}
{{ formset.management_form }}
<div x-ref="formContainer">
{% for item_form in formset.forms %}
<fieldset>
<legend>{% trans %}Item{% endtrans %}</legend>
{{ item_form.as_p() }}
</fieldset>
{% endfor %}
</div>
<template x-ref="formTemplate">
<fieldset>
<legend>{% trans %}Item{% endtrans %}</legend>
{{ formset.empty_form.as_p() }}
</fieldset>
</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>
</form>
{% endblock %}
+34
View File
@@ -0,0 +1,34 @@
{% extends "core/base.jinja" %}
{% block title %}{% trans %}Stock items{% endtrans %}{% endblock %}
{% 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>
{% endif %}
{% if items %}
{% for item in items %}
<div>
<div>
<p>{{ item.name }}</p>
<p>{% trans %}Last known quantity: {% endtrans %}{{ item.last_known_quantity }}</p>
</div>
<div>
{% if is_editor %}
<a href="{{ url('stock:item_edit', club_id=club.id, stock_id=stock.id, item_id=item.id) }}">
{% trans %}Edit{% endtrans %}
</a>
{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<p>{% trans %}No item has been created yet.{% endtrans %}</p>
{% endif %}
{% endblock %}