mirror of
https://github.com/ae-utbm/sith.git
synced 2026-11-20 16:09:54 +00:00
Random UI
This commit is contained in:
1 parent
04b200cdc5
commit
f6b75b3023
10 files changed
+337
-103
No files matched your search
@@ -1,18 +1,22 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("stock/css/forms.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
<div class="form-group"
|
||||
{% 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 :
|
||||
{% trans %}Current quantity:{% endtrans %}
|
||||
<span x-text="existingQuantity"></span>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -79,7 +83,7 @@
|
||||
|
||||
{% set action_value = form["action"].value() %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data"
|
||||
<form method="post" class="stock-form" enctype="multipart/form-data"
|
||||
x-data="{ action: '{{ action_value if action_value is not none else '' }}' }">
|
||||
{% csrf_token %}
|
||||
{{ form.non_field_errors() }}
|
||||
@@ -113,7 +117,7 @@
|
||||
{{ action_row(empty_form) }}
|
||||
</template>
|
||||
|
||||
<div>
|
||||
<div class="row gap margin-bottom">
|
||||
<button class="btn btn-grey" type="button" @click="add()">
|
||||
<i class="fa fa-plus"></i>
|
||||
{% trans %}Add{% endtrans %}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("stock/css/forms.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{% trans %}Create stock{% endtrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Create stock{% endtrans %}</h2>
|
||||
<form method="post" action="">
|
||||
<form method="post" action="" class="stock-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
<p><button class="btn btn-blue" type="submit">{% trans %}Save{% endtrans %}</button></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -1,12 +1,16 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("stock/css/forms.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{% trans %}Edit stock{% endtrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Edit stock{% endtrans %}</h2>
|
||||
<form method="post">
|
||||
<form method="post" class="stock-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
<p><button class="btn btn-blue" type="submit">{% trans %}Save{% endtrans %}</button></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -5,12 +5,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Stock{% endtrans %}</h2>
|
||||
<h2 class="margin-bottom">{% trans %}Stock{% endtrans %}</h2>
|
||||
|
||||
{% if is_editor %}
|
||||
<p>
|
||||
<a href="{{ url('stock:create', club_id=club.id) }}">
|
||||
<p class="margin-bottom">
|
||||
<a class="btn btn-blue" href="{{ url('stock:create', club_id=club.id) }}">
|
||||
{% trans %}Create a stock{% endtrans %}
|
||||
<i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
@@ -24,12 +25,13 @@
|
||||
{{ stock.name }}
|
||||
</a>
|
||||
{% if is_editor %}
|
||||
-
|
||||
<a href="{{ url('stock:edit', club_id=club.id, stock_id=stock.id) }}">
|
||||
{% trans %}Edit{% endtrans %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("stock/css/forms.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{% trans %}Edit stock item{% endtrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Edit stock item{% endtrans %}</h2>
|
||||
<form method="post">
|
||||
<form method="post" class="stock-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||
<p><button class="btn btn-blue" type="submit">{% trans %}Save{% endtrans %}</button></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -1,5 +1,9 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("stock/css/forms.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block additional_js %}
|
||||
<script type="module" src="{{ static("bundled/core/dynamic-formset-index.ts") }}"></script>
|
||||
{% endblock %}
|
||||
@@ -8,7 +12,8 @@
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Create stock items in{% endtrans %}{{ stock.name }}</h2>
|
||||
<form method="post" x-data="dynamicFormSet({ prefix: '{{ formset.prefix }}' })">
|
||||
<form method="post" class="stock-form"
|
||||
x-data="dynamicFormSet({ prefix: '{{ formset.prefix }}' })">
|
||||
{% csrf_token %}
|
||||
{{ formset.management_form }}
|
||||
<div x-ref="formContainer" class="margin-bottom">
|
||||
@@ -18,7 +23,7 @@
|
||||
{{ item_form.as_p() }}
|
||||
{% if not loop.first %}
|
||||
<button type="button" class="btn btn-grey"
|
||||
@click.prevent="removeForm($event.target.closest('div'))">
|
||||
@click.prevent="removeForm($event.target.closest('div'))">
|
||||
<i class="fa fa-minus"></i> {% trans %}Remove{% endtrans %}
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -34,16 +39,18 @@
|
||||
{{ formset.empty_form.as_p() }}
|
||||
</div>
|
||||
<button type="button" class="btn btn-grey"
|
||||
@click.prevent="removeForm($event.target.closest('div'))">
|
||||
@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" class="btn btn-blue">{% trans %}Save{% endtrans %}</button>
|
||||
<div class="row gap margin-bottom">
|
||||
<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" class="btn btn-blue">{% trans %}Save{% endtrans %}</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -1,35 +1,39 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ static("core/components/card.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{% trans %}Stock items{% endtrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{% trans %}Items in {% endtrans %}{{ stock.name }}</h3>
|
||||
<h2 class="margin-bottom">{% trans %}Items in {% endtrans %}{{ stock.name }}</h2>
|
||||
{% if is_editor %}
|
||||
<div>
|
||||
<div class="row gap margin-bottom">
|
||||
<a href="{{ url('stock:items_create', club_id=club.id, stock_id=stock.id) }}" class="btn btn-blue">
|
||||
{% trans %}Create items{% endtrans %}
|
||||
{% trans %}Create items{% endtrans %} <i class="fa fa-plus"></i>
|
||||
</a>
|
||||
<a href="{{ url('stock:action_create', club_id=club.id, stock_id=stock.id) }}" class="btn btn-blue">
|
||||
{% trans %}Create action{% endtrans %}
|
||||
{% trans %}Create action{% endtrans %} <i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if items %}
|
||||
{% for item in items %}
|
||||
<div class="card card-row shadow">
|
||||
<div>
|
||||
<p>{{ item.name }}</p>
|
||||
<p>{% trans %}Last known quantity: {% endtrans %}{{ item.last_known_quantity }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
{% for item in items %}
|
||||
<div class="card card-row shadow margin-bottom">
|
||||
<div class="card-content">
|
||||
<strong class="card-title">{{ item.item.name }}</strong>
|
||||
<p>{% trans %}Last known quantity:{% endtrans %} {{ item.last_known_quantity }}</p>
|
||||
</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 class="btn btn-grey" href="{{ url('stock:item_edit', club_id=club.id, stock_id=stock.id, item_id=item.id) }}">
|
||||
<i class="fa fa-pen"></i> {% trans %}Edit{% endtrans %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>{% trans %}No item has been created yet.{% endtrans %}</p>
|
||||
{% endif %}
|
||||
|
||||
Reference in new issue
Block a user