Add edit and new for users

This commit is contained in:
gabatxo1312 2026-01-29 23:52:55 +01:00
commit cf9a7cf33f
No known key found for this signature in database
12 changed files with 229 additions and 88 deletions

22
templates/users/edit.html Normal file
View file

@ -0,0 +1,22 @@
{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/cards.html" as cards %}
o{% import "components/inputs.html" as form_helpers %}
{% block main %}
{{ typography::heading("New User") }}
{% call cards::card() %}
<form action="/users/{{ user.id }}" method="post">
<div class="row align-items-end">
<div class="col-md-10">
{{ form_helpers::input("name", "Name", value = user.name, is_required = true, placeholder = "Ex: Kropotkine", margin_bottom = false) }}
</div>
<div class="col-md-2">
<input type="submit" value="Create user" class="btn btn-success">
</div>
</div>
</form>
{% endcall %}
{% endblock %}

View file

@ -1,9 +1,13 @@
{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/dropdown.html" as dropdown %}
{% import "components/cards.html" as cards %}
{% import "components/inputs.html" as form_helpers %}
{% block main %}
{{ typography::heading("All users") }}
{% call typography::heading("All users") %}
<a class="btn-success btn" href="/users/new">Add User</a>
{% endcall %}
{% call cards::card() %}
<table class="table table-hover">
@ -17,30 +21,18 @@
</tr>
</thead>
<tbody>
{% for (user, book_size, borrowed_book) in user_with_books_number %}
{% for user_information in user_with_books_number %}
<tr>
<th scope="row">{{ user.id }}</th>
<td>{{ user.name }}</td>
<td>{{ book_size }}</td>
<td>{{ borrowed_book }}</td>
<th scope="row">{{ user_information.user.id }}</th>
<td>{{ user_information.user.name }}</td>
<td>{{ user_information.owner_book_number }}</td>
<td>{{ user_information.borrowed_book_number }}</td>
<td>
<form method="post" action="/users/{{ user.id }}">
<input value="Delete" type="submit" class="btn btn-danger btn-sm">
</form>
{{ dropdown::crud_dropdown_button(user_information.user, "Actions", "users", show = false) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</table>
{% endcall %}
{% call cards::card() %}
<form action="/users" method="post">
<label class="form-label">Name</label>
<input type="text" name="name" class="form-control">
<input type="submit" value="Create user" class="btn btn-success mt-3">
</form>
{% endcall %}
{% endblock %}

21
templates/users/new.html Normal file
View file

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/cards.html" as cards %}
o{% import "components/inputs.html" as form_helpers %}
{% block main %}
{{ typography::heading("New User") }}
{% call cards::card() %}
<form action="/users" method="post">
<div class="row align-items-end">
<div class="col-md-10">
{{ form_helpers::input("name", "Name", is_required = true, placeholder = "Ex: Kropotkine", margin_bottom = false) }}
</div>
<div class="col-md-2">
<input type="submit" value="Create user" class="btn btn-success">
</div>
</div>
</form>
{% endcall %}
{% endblock %}