create index action for CRUD

This commit is contained in:
2020-03-12 12:13:41 +01:00
parent 7a952d6f88
commit ba742dd7be
6 changed files with 109 additions and 77 deletions

View File

@@ -232,6 +232,7 @@ Impersonate: Mode fantôme
Impersonate mode: Mode fantôme
crud:
# general items
new:
button_action_form: Créer
link_edit: Modifier
@@ -248,4 +249,4 @@ crud:
default:
success: Les données ont été enregistrées
view:
link_duplicate: Dupliquer
link_duplicate: Dupliquer

View File

@@ -0,0 +1,48 @@
<div class="grid-10 centered">
{% block index_header %}
<h1>{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}</h1>
{% endblock index_header %}
{% if entities|length == 0 %}
{% block no_existing_entities %}
<p>{{ no_existing_entities_sentences|default('No entities')|trans }}</p>
{% endblock %}
{% else %}
{% block table_entities %}
<table>
<thead>
<tr>
{% block table_entities_thead_tr %}
<th>id</th>
{% endblock %}
</tr>
</thead>
<tbody>
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
</tr>
{% endfor %}
{% endblock %}
</tbody>
</table>
{% endblock %}
{% endif %}
<div class="crud_index__pagination">
{{ chill_pagination(paginator) }}
</div>
{% block list_actions %}
<ul class="record_actions sticky-form-buttons">
{% block add_new %}
<li>
<a href="{{ chill_path_add_return_path('chill_crud_' ~ crud_name ~ '_new') }}" class="sc-button bt-new">{{ ('crud.'~crud_name~'.index.add_new')|trans( {'%crud_name%': crud_name} ) }}</a>
</li>
{% endblock %}
</ul>
{% endblock list_actions %}
</div>

View File

@@ -1,6 +1,6 @@
<div class="{% block crud_content_main_div_class %}grid-10 centered{% endblock %}">
{% block crud_content_header %}
<h1>{{ 'crud.%crud_name%.title_new'|trans({'%crud_name%' : crud_name }) }}</h1>
<h1>{{ ('crud.' ~ crud_name ~ '.title_new')|trans({'%crud_name%' : crud_name }) }}</h1>
{% endblock crud_content_header %}
{% block crud_content_form %}

View File

@@ -1 +1 @@
{{ 'crud.%crud_name%.title_new'|trans({'%crud_name%' : crud_name }) }}
{{ ('crud.' ~ crud_name ~ '.title_new')|trans({'%crud_name%' : crud_name }) }}

View File

@@ -1,39 +1,8 @@
{% extends '@ChillMain/layout.html.twig' %}
{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %}
{% block content %}
<h1>{{ title|default('List of %class%')|trans({'%class%': class}) }}</h1>
{% if entities|length == 0 %}
<p>{{ no_existing_entities_sentences|default('No entities')|trans }}</p>
{% else %}
<table>
<thead>
<tr>
{% for c in columns %}
<th>{{ c|trans }}</th>
{% endfor %}
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
{% for c in columns %}
<td>{{ entity|chill_crud_display(c) }}</td>
{% endfor %}
<td>
<ul class="record-actions">
{% for action in actions %}
<li>{{ action }}</li>
{% endfor %}
</ul>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% endembed %}
{% endblock content %}