Merge pull request 'Add empty state on table' (#17) from add-empty-state into main

Reviewed-on: #17
This commit is contained in:
loube 2026-01-30 18:41:42 +01:00
commit fc82ffc481
5 changed files with 102 additions and 79 deletions

View File

@ -11,6 +11,7 @@ common:
search: Search search: Search
reset: Reset reset: Reset
show: Show show: Show
no_result: No results
close: Close close: Close
confirmation: Confirmation confirmation: Confirmation
are_you_sure: Are you sure? are_you_sure: Are you sure?

View File

@ -11,6 +11,7 @@ common:
search: Filtrer search: Filtrer
reset: Réini. reset: Réini.
show: Voir show: Voir
no_result: Aucun résultat
close: Fermer close: Fermer
confirmation: Confirmation confirmation: Confirmation
are_you_sure: Êtes-vous sûr ? are_you_sure: Êtes-vous sûr ?

View File

@ -25,7 +25,7 @@ use crate::{
#[derive(Template, WebTemplate)] #[derive(Template, WebTemplate)]
#[template(path = "users/index.html")] #[template(path = "users/index.html")]
struct UsersIndexTemplate { struct UsersIndexTemplate {
user_with_books_number: Vec<UserWithBookNumber>, users_with_books_number: Vec<UserWithBookNumber>,
query: IndexQuery, query: IndexQuery,
} }
@ -84,7 +84,7 @@ pub async fn index(
} }
Ok(UsersIndexTemplate { Ok(UsersIndexTemplate {
user_with_books_number: result, users_with_books_number: result,
query, query,
}) })
} }

View File

@ -90,6 +90,15 @@
{% endcall %} {% endcall %}
{% call cards::card() %} {% call cards::card() %}
{% if books_with_user.is_empty() %}
<div class="d-flex flex-column align-items-center justify-content-center">
<h2>{{ t!("common.no_result") }}</h2>
<a class="btn btn-success text-white text-nowrap mt-3" href="/books/new">
{{ t!("book.new.button_short") }}
</a>
</div>
{% else %}
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
@ -147,5 +156,7 @@
</nav> </nav>
</div> </div>
{% endif %} {% endif %}
{% endif %}
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}

View File

@ -34,6 +34,15 @@
{% endcall %} {% endcall %}
{% call cards::card() %} {% call cards::card() %}
{% if users_with_books_number.is_empty() %}
<div class="d-flex flex-column align-items-center justify-content-center">
<h2>{{ t!("common.no_result") }}</h2>
<a class="btn btn-success text-white text-nowrap mt-3" href="//new">
{{ t!("user.index.button") }}
</a>
</div>
{% else %}
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
@ -45,7 +54,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for user_information in user_with_books_number %} {% for user_information in users_with_books_number %}
<tr class="align-middle"> <tr class="align-middle">
<th scope="row">{{ user_information.user.id }}</th> <th scope="row">{{ user_information.user.id }}</th>
<td>{{ user_information.user.name }}</td> <td>{{ user_information.user.name }}</td>
@ -58,5 +67,6 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% endif %}
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}