diff --git a/core/Resources/maker/crud-controller/CrudController.tpl.php b/core/Resources/maker/crud-controller/CrudController.tpl.php index e4cab02..eaa6b71 100644 --- a/core/Resources/maker/crud-controller/CrudController.tpl.php +++ b/core/Resources/maker/crud-controller/CrudController.tpl.php @@ -86,6 +86,7 @@ class extends CrudController ->setPageRoute('new', 'admin__new') ->setPageRoute('edit', 'admin__edit') ->setPageRoute('show', 'admin__show') + ->setPageRoute('sort', 'admin__sort') ->setPageRoute('delete', 'admin__delete') ->setPageRoute('filter', 'admin__filter') @@ -95,6 +96,9 @@ class extends CrudController // ->setMaxPerPage('index', 20) + // ->setIsSortableCollection('index', false) + // ->setSortableCollectionProperty('sortOrder') + // ->setAction('index', 'new', true) // ->setAction('index', 'show', true) // ->setAction('index', 'edit', true) @@ -105,7 +109,7 @@ class extends CrudController // ->setAction('edit', 'delete', true) // ->setField('index', 'Label', Field\TextField::class, [ - // 'property' => 'label', + // 'property' => 'label', // ]) ; } 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/edit.html.twig b/core/Resources/views/admin/crud/edit.html.twig index 276462d..fd5885e 100644 --- a/core/Resources/views/admin/crud/edit.html.twig +++ b/core/Resources/views/admin/crud/edit.html.twig @@ -1,45 +1,47 @@ {% extends '@Core/admin/layout.html.twig' %} -{% block title %}{{ configuration.pageTitle('edit')|trans|build_string(entity) }} - {{ parent() }}{% endblock %} +{% set context = context ?? 'edit' %} + +{% block title %}{{ configuration.pageTitle(context)|trans|build_string(entity) }} - {{ parent() }}{% endblock %} {% block body %} {% block header %}
{% block header_title %} -

{{ configuration.pageTitle('edit')|trans|build_string(entity) }}

+

{{ configuration.pageTitle(context)|trans|build_string(entity) }}

{% endblock %} {% block header_actions %}
- {% if configuration.action('edit', 'back', true) %} + {% if configuration.action(context, 'back', true) %} - {{ configuration.actionTitle('edit', 'back', 'Back to the list')|trans }} + {{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }} {% endif %} - {% if configuration.action('edit', 'show', true) %} + {% if configuration.action(context, 'show', true) %} - {{ configuration.actionTitle('edit', 'show', 'Show')|trans|build_string(entity) }} + {{ configuration.actionTitle(context, 'show', 'Show')|trans|build_string(entity) }} {% endif %} {% if header_actions_dropdown_menu is not defined %} {% set header_actions_dropdown_menu = '' %} {% endif %} - {% if configuration.action('edit', 'delete', true) %} + {% if configuration.action(context, 'delete', true) %} {% set item %} {% endset %} @@ -82,7 +84,7 @@ {% endblock %} - {% if configuration.action('edit', 'delete', true) %} + {% if configuration.action(context, 'delete', true) %}
diff --git a/core/Resources/views/admin/crud/index.html.twig b/core/Resources/views/admin/crud/index.html.twig index 4674200..5148d33 100644 --- a/core/Resources/views/admin/crud/index.html.twig +++ b/core/Resources/views/admin/crud/index.html.twig @@ -1,22 +1,36 @@ {% extends '@Core/admin/layout.html.twig' %} -{% block title %}{{ configuration.pageTitle('index')|trans }} - {{ parent() }}{% endblock %} +{% set context = context ?? 'index' %} + +{% block title %}{{ configuration.pageTitle(context)|trans }} - {{ parent() }}{% endblock %} {% block body %} {% block header %} -
+ {%- set pb -%} + {% if pager.paginationData.pageCount < 2 %} + {% if filters.show %} + pb-3 + {% else %} + pb-5 + {% endif %} + {% else %} + pb-3 + {% endif %} + {%- endset -%} + +
{% block header_title %} -

{{ configuration.pageTitle('index')|trans }}

+

{{ configuration.pageTitle(context)|trans }}

{% endblock %} {% block header_actions %}
- {% if configuration.action('index', 'new', true) %} + {% if configuration.action(context, 'new', true) %} - {{ configuration.actionTitle('index', 'new', 'New')|trans }} + {{ configuration.actionTitle(context, 'new', 'New')|trans }} {% endif %} @@ -62,56 +76,58 @@ {% endblock %} {% block list %} - {% set isSortable = configuration.isSortableCollection('index') %} + {% set isSortable = configuration.isSortableCollection(context) %}
{% block list_header %} - {% for label, config in configuration.fields('index') %} - {% set attr = config.options.attr is defined ? config.options.attr : [] %} - {% set isSortable = config.options.sort ?? false %} + {% for label, config in configuration.fields(context) %} + {% block list_header_item %} + {% set attr = config.options.attr is defined ? config.options.attr : [] %} + {% set isSortable = config.options.sort ?? false %} - + + {% endblock %} {% endfor %} - {% for config in configuration.fields('index') %} + {% for config in configuration.fields(context) %} {% set attr = config.options.attr is defined ? config.options.attr : [] %} {% set action = config.options.action is defined ? config.options.action : null %} @@ -176,19 +192,19 @@ - {% endif %} {% else %} -
- {% 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('index'), { - _sort: config.options.sort[0], - _sort_direction: newDirection, - }) %} + + {% if icon is defined %} + + {% endif %} + + {{ label|trans }} + {% else %} - {% set url = path(configuration.getPageRoute('index'), { - _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 %} - {{ 'Actions'|trans }} @@ -128,7 +144,7 @@ { _token: csrf_token('sort'), page: pager.currentPageNumber, - context: 'index', + context: context, } ) ~ '"' %} {% else %} @@ -146,15 +162,15 @@ {% block list_item %} {%- set dbClick %} - {% if configuration.action('index', 'show', true) %} + {% if configuration.action(context, 'show', true) %} {{ path(configuration.pageRoute('show'), {entity: item.id}) }} - {% elseif configuration.action('index', 'edit', true) %} + {% elseif configuration.action(context, 'edit', true) %} {{ path(configuration.pageRoute('edit'), {entity: item.id}) }} {% endif %} {% endset -%}
{% block list_item_actions_before %}{% endblock %} - {% if configuration.action('index', 'show', true) %} + {% if configuration.action(context, 'show', true) %} {% endif %} - {% if configuration.action('index', 'edit', true) %} + {% if configuration.action(context, 'edit', true) %} {% endif %} - {% if configuration.action('index', 'delete', true) %} + {% if configuration.action(context, 'delete', true) %} @@ -206,15 +222,15 @@ {% if loop.last and isSortable %}
+ - {{ 'You can sort items by drag & drop'|trans }} + {{ 'You can sort items with drag & drop'|trans }}
+
diff --git a/core/Resources/views/admin/crud/new.html.twig b/core/Resources/views/admin/crud/new.html.twig index a49648c..86c2f19 100644 --- a/core/Resources/views/admin/crud/new.html.twig +++ b/core/Resources/views/admin/crud/new.html.twig @@ -1,28 +1,30 @@ {% extends '@Core/admin/layout.html.twig' %} -{% block title %}{{ configuration.pageTitle('new')|trans|build_string(entity) }} - {{ parent() }}{% endblock %} +{% set context = context ?? 'new' %} + +{% block title %}{{ configuration.pageTitle(context)|trans|build_string(entity) }} - {{ parent() }}{% endblock %} {% block body %} {% block header %}
{% block header_title %} -

{{ configuration.pageTitle('new')|trans|build_string(entity) }}

+

{{ configuration.pageTitle(context)|trans|build_string(entity) }}

{% endblock %} {% block header_actions %}
- {% if configuration.action('new', 'back', true) %} + {% if configuration.action(context, 'back', true) %} - {{ configuration.actionTitle('new', 'back', 'Back to the list')|trans }} + {{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }} {% endif %} {% if header_actions_dropdown_menu is not defined %} diff --git a/core/Resources/views/admin/crud/show.html.twig b/core/Resources/views/admin/crud/show.html.twig index f58df04..cadb3ed 100644 --- a/core/Resources/views/admin/crud/show.html.twig +++ b/core/Resources/views/admin/crud/show.html.twig @@ -1,30 +1,32 @@ {% extends '@Core/admin/layout.html.twig' %} -{% block title %}{{ configuration.pageTitle('show')|trans|build_string(entity) }} - {{ parent() }}{% endblock %} +{% set context = context ?? 'show' %} + +{% block title %}{{ configuration.pageTitle(context)|trans|build_string(entity) }} - {{ parent() }}{% endblock %} {% block body %} {% block header %}
{% block header_title %} -

{{ configuration.pageTitle('show')|trans|build_string(entity) }}

+

{{ configuration.pageTitle(context)|trans|build_string(entity) }}

{% endblock %} {% block header_actions %}
- {% if configuration.action('show', 'back', true) %} + {% if configuration.action(context, 'back', true) %} - {{ configuration.actionTitle('show', 'back', 'Back to the list')|trans }} + {{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }} {% endif %} - {% if configuration.action('show', 'edit', true) %} + {% if configuration.action(context, 'edit', true) %} - {{ configuration.actionTitle('show', 'edit', 'Edit')|trans|build_string(entity) }} + {{ configuration.actionTitle(context, 'edit', 'Edit')|trans|build_string(entity) }} {% endif %}