Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
feat(admin): datatable with order
Browse files Browse the repository at this point in the history
  • Loading branch information
koromerzhin committed Oct 22, 2021
1 parent 679c882 commit 406f0f8
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 151 deletions.
40 changes: 29 additions & 11 deletions apps/templates/admin/attachment/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'attachment.name'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.mimetype'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.size'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.dimensions'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.download'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.state'|trans({}, 'admin.messages') }}</th>
<th>{{ 'attachment.workflow'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.name',
'name': 'attachment.name'|trans({}, 'admin.messages')
},
{
'field': 'a.mimeType',
'name': 'attachment.mimetype'|trans({}, 'admin.messages')
},
{
'field': 'a.size',
'name': 'attachment.size'|trans({}, 'admin.messages')
},
{
'name': 'attachment.dimensions'|trans({}, 'admin.messages')
},
{
'name': 'attachment.download'|trans({}, 'admin.messages')
},
{
'field': 'a.state',
'name': 'attachment.state'|trans({}, 'admin.messages')
},
{
'name': 'attachment.workflow'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand All @@ -21,7 +39,7 @@
<td>{{ entity.mimeType }}</td>
<td>{{ entity.size }}</td>
<td>{{ entity.dimensions|json_encode }}</td>
<td><a href="{{ asset(entity.name) }}" target="_blank">{{ 'attachment.seefile'|trans({}, 'admin.messages') }}</a></td>
<td>{% if entity.name != '' %}<a href="{{ asset(entity.name) }}" target="_blank">{{ 'attachment.seefile'|trans({}, 'admin.messages') }}</a>{% endif %}</td>
<td>
{% for state in workflow_marked_places(entity) %}
{{ state }}
Expand Down
28 changes: 20 additions & 8 deletions apps/templates/admin/bookmark/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'bookmark.name'|trans({}, 'admin.messages') }}</th>
<th>{{ 'bookmark.user'|trans({}, 'admin.messages') }}</th>
<th>{{ 'bookmark.category'|trans({}, 'admin.messages') }}</th>
<th>{{ 'workflow.state'|trans({}, 'admin.messages') }}</th>
<th>{{ 'bookmark.workflow'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.name',
'name': 'bookmark.name'|trans({}, 'admin.messages')
},
{
'name': 'bookmark.user'|trans({}, 'admin.messages')
},
{
'name': 'bookmark.category'|trans({}, 'admin.messages')
},
{
'field': 'a.state',
'name': 'workflow.state'|trans({}, 'admin.messages')
},
{
'name': 'bookmark.workflow'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand Down
15 changes: 10 additions & 5 deletions apps/templates/admin/category/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
{% extends 'admin/category/layout.html.twig' %}
{% block body %}
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% import "admin/category/macro.html.twig" as macro_post %}
{% block thead %}
<tr>
<th>{{ 'post.category.name'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.category.slug'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'name': 'post.category.name'|trans({}, 'admin.messages')
},
{
'name': 'post.category.slug'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{{ macro_post.show(pagination, 0, actions) }}
Expand Down
29 changes: 21 additions & 8 deletions apps/templates/admin/edito/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'edito.title'|trans({}, 'admin.messages') }}</th>
<th>{{ 'edito.user'|trans({}, 'admin.messages') }}</th>
<th>{{ 'edito.published'|trans({}, 'admin.messages') }}</th>
<th>{{ 'edito.state'|trans({}, 'admin.messages') }}</th>
<th>{{ 'edito.workflow'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.title',
'name': 'edito.title'|trans({}, 'admin.messages')
},
{
'name': 'edito.user'|trans({}, 'admin.messages')
},
{
'field': 'a.published',
'name': 'edito.published'|trans({}, 'admin.messages')
},
{
'field': 'a.state',
'name': 'edito.state'|trans({}, 'admin.messages')
},
{
'name': 'edito.workflow'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand Down
103 changes: 65 additions & 38 deletions apps/templates/admin/geocode/index.html.twig
Original file line number Diff line number Diff line change
@@ -1,41 +1,68 @@
{% extends 'admin/geocode/layout.html.twig' %}
{% block body %}
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'geocode.countrycode'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.postalcode'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.placename'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.statename'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.provincename'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.communityname'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.latitude'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.longitude'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.accuracy'|trans({}, 'admin.messages') }}</th>
<th>{{ 'geocode.actions'|trans({}, 'admin.messages') }}</th>
</tr>
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
<tr data-id="{{ entity.id }}">
<td>
<span class="flag-icon flag-icon-{{ entity.countryCode|lower }}"></span>
{{ entity.countryCode|country_name('fr') }}
</td>
<td>{{ entity.postalCode }}</td>
<td>{{ entity.placeName }}</td>
<td>{{ entity.stateName }}</td>
<td>{{ entity.provinceName }}</td>
<td>{{ entity.communityName }}</td>
<td>{{ entity.latitude }}</td>
<td>{{ entity.longitude }}</td>
<td>{{ entity.accuracy }}</td>
<td>
{{ macro_admin.actions(entity, actions) }}
</td>
</tr>
{% endfor %}
{% endblock %}
{% endembed %}
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
{% set theads = [
{
'field': 'a.countryCode',
'name': 'geocode.countrycode'|trans({}, 'admin.messages')
},
{
'field': 'a.postalCode',
'name': 'geocode.postalcode'|trans({}, 'admin.messages')
},
{
'field': 'a.placeName',
'name': 'geocode.placename'|trans({}, 'admin.messages')
},
{
'field': 'a.stateName',
'name': 'geocode.statename'|trans({}, 'admin.messages')
},
{
'field': 'a.provinceName',
'name': 'geocode.provincename'|trans({}, 'admin.messages')
},
{
'field': 'a.communityName',
'name': 'geocode.communityname'|trans({}, 'admin.messages')
},
{
'field': 'a.latitude',
'name': 'geocode.latitude'|trans({}, 'admin.messages')
},
{
'field': 'a.longitude',
'name': 'geocode.longitude'|trans({}, 'admin.messages')
},
{
'field': 'a.accuracy',
'name': 'geocode.accuracy'|trans({}, 'admin.messages')
},
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
<tr data-id="{{ entity.id }}">
<td>
<span class="flag-icon flag-icon-{{ entity.countryCode|lower }}"></span>
{{ entity.countryCode|country_name('fr') }}
</td>
<td>{{ entity.postalCode }}</td>
<td>{{ entity.placeName }}</td>
<td>{{ entity.stateName }}</td>
<td>{{ entity.provinceName }}</td>
<td>{{ entity.communityName }}</td>
<td>{{ entity.latitude }}</td>
<td>{{ entity.longitude }}</td>
<td>{{ entity.accuracy }}</td>
<td>
{{ macro_admin.actions(entity, actions) }}
</td>
</tr>
{% endfor %}
{% endblock %}
{% endembed %}
{% endblock %}
16 changes: 11 additions & 5 deletions apps/templates/admin/libelle/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'post.libelle.name'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.libelle.slug'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.name',
'name': 'post.libelle.name'|trans({}, 'admin.messages')
},
{
'field': 'a.slug',
'name': 'post.libelle.slug'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand Down
17 changes: 17 additions & 0 deletions apps/templates/admin/macro.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{% macro thead(theads, pagination, actions) %}
<tr>
{% for thead in theads %}
<th{% if thead.field is defined and pagination.isSorted(thead.field) %} class="sorted"{% endif %}>
{% if thead.field is defined %}
{{ knp_pagination_sortable(pagination, thead.name, thead.field) }}
{% elseif thead.name is defined %}
{{ thead.name }}
{% endif %}
</th>
{% endfor %}
{% if actions == true %}
<th></th>
{% endif %}
<tr>
{% endmacro %}

{% macro form_img(entity, field, name, url) %}
{% set file = attachment(field) %}
{% set state = guard_route(url) %}
Expand Down
34 changes: 25 additions & 9 deletions apps/templates/admin/note_interne/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'noteinterne.title'|trans({}, 'admin.messages') }}</th>
<th>{{ 'noteinterne.date_debut'|trans({}, 'admin.messages') }}</th>
<th>{{ 'noteinterne.date_fin'|trans({}, 'admin.messages') }}</th>
<th>{{ 'noteinterne.user'|trans({}, 'admin.messages') }}</th>
<th>{{ 'workflow.state'|trans({}, 'admin.messages') }}</th>
<th>{{ 'noteinterne.workflow'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.title',
'name': 'noteinterne.title'|trans({}, 'admin.messages')
},
{
'field': 'a.dateDebut',
'name': 'noteinterne.date_debut'|trans({}, 'admin.messages')
},
{
'field': 'a.dateFin',
'name': 'noteinterne.date_fin'|trans({}, 'admin.messages')
},
{
'name': 'noteinterne.user'|trans({}, 'admin.messages')
},
{
'field': 'a.state',
'name': 'workflow.state'|trans({}, 'admin.messages')
},
{
'name': 'noteinterne.workflow'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand Down
33 changes: 24 additions & 9 deletions apps/templates/admin/post/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
{% embed "admin/table.html.twig" %}
{% import "admin/macro.html.twig" as macro_admin %}
{% block thead %}
<tr>
<th>{{ 'post.title'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.user'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.category'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.published'|trans({}, 'admin.messages') }}</th>
<th>{{ 'workflow.state'|trans({}, 'admin.messages') }}</th>
<th>{{ 'post.workflow'|trans({}, 'admin.messages') }}</th>
<th></th>
</tr>
{% set theads = [
{
'field': 'a.title',
'name': 'post.title'|trans({}, 'admin.messages')
},
{
'name': 'post.user'|trans({}, 'admin.messages')
},
{
'name': 'post.category'|trans({}, 'admin.messages')
},
{
'field': 'a.published',
'name': 'post.published'|trans({}, 'admin.messages')
},
{
'field': 'a.state',
'name': 'workflow.state'|trans({}, 'admin.messages')
},
{
'name': 'post.workflow'|trans({}, 'admin.messages')
}
] %}
{{ macro_admin.thead(theads, pagination, true) }}
{% endblock %}
{% block tbody %}
{% for entity in pagination %}
Expand Down
Loading

0 comments on commit 406f0f8

Please sign in to comment.