From 6dc3465084077c0b6351ac63cfb083b19c3ca74e Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 27 May 2021 21:34:01 +0200 Subject: [PATCH] update crud templates --- core/Resources/translations/messages.fr.yaml | 2 +- .../views/admin/crud/index.html.twig | 70 ++++++++++--------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/core/Resources/translations/messages.fr.yaml b/core/Resources/translations/messages.fr.yaml index ec47569..b152069 100644 --- a/core/Resources/translations/messages.fr.yaml +++ b/core/Resources/translations/messages.fr.yaml @@ -157,4 +157,4 @@ "Tasks": "Tâches" "Results": "Résultats" "Clean all cache": "Nettoyer tout le cache" -"You can sort items by drag & drop": "Vous pouvez trier les élements via un glisser/déposer" +"You can sort items with drag & drop": "Vous pouvez trier les élements via un glisser/déposer" diff --git a/core/Resources/views/admin/crud/index.html.twig b/core/Resources/views/admin/crud/index.html.twig index 85951f2..5148d33 100644 --- a/core/Resources/views/admin/crud/index.html.twig +++ b/core/Resources/views/admin/crud/index.html.twig @@ -84,48 +84,50 @@ {% for label, config in configuration.fields(context) %} - {% set attr = config.options.attr is defined ? config.options.attr : [] %} - {% set isSortable = config.options.sort ?? false %} + {% block list_header_item %} + {% set attr = config.options.attr is defined ? config.options.attr : [] %} + {% set isSortable = config.options.sort ?? false %} - - {% if isSortable %} - {% if sort %} - {% if sort.label == label %} - {% if sort.direction == 'asc' %} - {% set newDirection = 'desc' %} - {% set icon = 'fa fa-sort-amount-down-alt' %} + + {% if isSortable %} + {% if sort %} + {% if sort.label == label %} + {% if sort.direction == 'asc' %} + {% set newDirection = 'desc' %} + {% set icon = 'fa fa-sort-amount-down-alt' %} + {% else %} + {% set newDirection = 'asc' %} + {% set icon = 'fa fa-sort-amount-up-alt' %} + {% endif %} + + {% set url = path(configuration.getPageRoute(context), { + _sort: config.options.sort[0], + _sort_direction: newDirection, + }) %} {% else %} - {% set newDirection = 'asc' %} - {% set icon = 'fa fa-sort-amount-up-alt' %} + {% set url = path(configuration.getPageRoute(context), { + _sort: config.options.sort[0], + _sort_direction: 'asc', + }) %} + + {% set icon = null %} {% endif %} - {% set url = path(configuration.getPageRoute(context), { - _sort: config.options.sort[0], - _sort_direction: newDirection, - }) %} + + {% if icon is defined %} + + {% endif %} + + {{ label|trans }} + {% else %} - {% set url = path(configuration.getPageRoute(context), { - _sort: config.options.sort[0], - _sort_direction: 'asc', - }) %} - - {% set icon = null %} - {% endif %} - - - {% if icon is defined %} - - {% endif %} - {{ label|trans }} - + {% endif %} {% else %} {{ label|trans }} {% endif %} - {% else %} - {{ label|trans }} - {% endif %} - + + {% endblock %} {% endfor %} {{ 'Actions'|trans }} @@ -222,7 +224,7 @@ - {{ 'You can sort items by drag & drop'|trans }} + {{ 'You can sort items with drag & drop'|trans }} {% endif %}