Add edit and new for users

This commit is contained in:
gabatxo1312
2026-01-29 23:52:55 +01:00
parent 57af399ace
commit cf9a7cf33f
12 changed files with 229 additions and 88 deletions
+4 -4
View File
@@ -11,18 +11,18 @@
</div>
{% endmacro %}
{% macro book_dropdown_button(book, show = true) %}
{% macro crud_dropdown_button(book, label, sub_path, show = true) %}
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Actions
</button>
<ul class="dropdown-menu">
{% if show %}
<li><a class="dropdown-item" href="/books/{{ book.id }}">Voir</a></li>
<li><a class="dropdown-item" href="/{{ sub_path }}/{{ book.id }}">Show</a></li>
{% endif %}
<li><a class="dropdown-item" href="/books/{{ book.id }}/edit">Edit</a></li>
<li><a class="dropdown-item" href="/{{ sub_path }}/{{ book.id }}/edit">Edit</a></li>
<li>
<form method="post" action="/books/{{ book.id }}/delete">
<form method="post" action="/{{ sub_path }}/{{ book.id }}/delete" class="mb-0">
<input class="dropdown-item" type="submit" value="Delete">
</form>
</li>
+43
View File
@@ -0,0 +1,43 @@
{% macro input(name, label, value = "", type = "text", is_required = false, placeholder = "", margin_bottom = true) %}
<div {% if margin_bottom %}class="mb-3"{% endif %}>
<label for="{{ name }}" class="form-label">
{{ label }}
{% if is_required %}
<span class="text-danger">*</span>
{% endif %}
</label>
<input type="{{ type }}" value="{{ value }}" name="{{ name }}" class="form-control" placeholder="{{ placeholder }}" {% if is_required %}required{% endif %}>
</div>
{% endmacro %}
{% macro select(name, label, options, selected_value = "", is_required = false, margin_bottom = true) -%}
<div {% if margin_bottom %}class="mb-3"{% endif %}>
<label for="{{ name }}" class="form-label">
{{ label }}
{% if is_required %}
<span class="text-danger">*</span>
{% endif %}
</label>
<select name="{{ name }}" class="form-select" {% if is_required %}required{% endif %}>
{% if !is_required %}
<option></option>
{% endif %}
{% for option in options %}
{{ caller(option) }}
{% endfor %}
</select>
</div>
{%- endmacro %}
{% macro textarea(name, label, value = "", rows = 2, is_required = false, placeholder = "", margin_bottom = true) %}
<div {% if margin_bottom %}class="mb-3"{% endif %}>
<label for="{{ name }}" class="form-label">
{{ label }}
{% if is_required %}
<span class="text-danger">*</span>
{% endif %}
</label>
<textarea value="{{ value }}" name="{{ name }}" rows="{{ rows }}" class="form-control" placeholder="{{ placeholder }}" {% if is_required %}required{% endif %}></textarea>
</div>
{% endmacro %}
+1 -1
View File
@@ -21,7 +21,7 @@
</h1>
<div>
{{ dropdown::book_dropdown_button(book, show) }}
{{ dropdown::crud_dropdown_button(book, "Actions", "books", show) }}
</div>
</div>
{% endmacro %}