From fa042c29f18a22678ed1fe57967e65004efbe64d Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 14 Jul 2021 13:59:00 +0200 Subject: [PATCH] Add list_action_button_content and logo_content options --- docs/reference/action_list.rst | 14 ++++++++++++++ docs/reference/configuration.rst | 3 ++- src/DependencyInjection/Configuration.php | 12 ++++++++++++ .../views/CRUD/list__action_delete.html.twig | 13 +++++++++++-- .../views/CRUD/list__action_edit.html.twig | 13 +++++++++++-- .../views/CRUD/list__action_history.html.twig | 13 +++++++++++-- .../views/CRUD/list__action_show.html.twig | 13 +++++++++++-- src/Resources/views/standard_layout.html.twig | 12 ++++++++++-- src/SonataConfiguration.php | 3 ++- 9 files changed, 84 insertions(+), 12 deletions(-) diff --git a/docs/reference/action_list.rst b/docs/reference/action_list.rst index 1623b87518..67f54881d4 100644 --- a/docs/reference/action_list.rst +++ b/docs/reference/action_list.rst @@ -698,6 +698,20 @@ You need to add option ``show_mosaic_button`` in your admin services: tags: - { name: sonata.admin, manager_type: orm, group: admin, label: News, show_mosaic_button: false } +Show Icons on Action Buttons +---------------------------- + +You can choose if the action buttons on the list-page show an icon, text or both. + +.. code-block:: yaml + + # config/packages/sonata_admin.yaml + + sonata_admin: + options: + # Choices are: text, icon or all (default) + list_action_button_content: icon + Checkbox range selection ------------------------ diff --git a/docs/reference/configuration.rst b/docs/reference/configuration.rst index 2c058059e6..c7c975be44 100644 --- a/docs/reference/configuration.rst +++ b/docs/reference/configuration.rst @@ -89,7 +89,8 @@ Full Configuration Options default_label_catalogue: SonataAdminBundle default_icon: 'fa fa-folder' dropdown_number_groups_per_colums: 2 - title_mode: ~ # One of "single_text"; "single_image"; "both" + logo_content: 'all' # One of "text"; "icon"; "all" + list_action_button_content: 'all' # One of "text"; "icon"; "all" # Enable locking when editing an object, if the corresponding object manager supports it. lock_protection: false diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index d164c7f655..2f8fa5c067 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -179,11 +179,23 @@ public function getConfigTreeBuilder() ->info('Icon used for admin services if one isn\'t provided.') ->end() ->integerNode('dropdown_number_groups_per_colums')->defaultValue(2)->end() + // NEXT_MAJOR: Remove this option. ->enumNode('title_mode') + ->setDeprecated('The "%node%" option is deprecated since sonata-project/admin-bundle 3.x. Use "logo_content" instead.') ->values(['single_text', 'single_image', 'both']) ->defaultValue('both') ->cannotBeEmpty() ->end() + ->enumNode('logo_content') + ->values(['text', 'icon', 'all']) + ->defaultValue('all') + ->cannotBeEmpty() + ->end() + ->enumNode('list_action_button_content') + ->values(['text', 'icon', 'all']) + ->defaultValue('all') + ->cannotBeEmpty() + ->end() ->booleanNode('lock_protection') ->defaultFalse() ->info('Enable locking when editing an object, if the corresponding object manager supports it.') diff --git a/src/Resources/views/CRUD/list__action_delete.html.twig b/src/Resources/views/CRUD/list__action_delete.html.twig index 1439dd072e..96d0e708b3 100644 --- a/src/Resources/views/CRUD/list__action_delete.html.twig +++ b/src/Resources/views/CRUD/list__action_delete.html.twig @@ -10,12 +10,21 @@ file that was distributed with this source code. #} {% if admin.hasAccess('delete', object) and admin.hasRoute('delete') %} + {% set button_content = sonata_config.getOption('list_action_button_content') %} - - {{ 'action_delete'|trans({}, 'SonataAdminBundle') }} + {% if button_content == 'icon' or button_content == 'all' %} + + {% endif %} + {% if button_content == 'text' or button_content == 'all' %} + {{ 'action_delete'|trans({}, 'SonataAdminBundle') }} + {% else %} + + {{ 'action_delete'|trans({}, 'SonataAdminBundle') }} + + {% endif %} {% endif %} diff --git a/src/Resources/views/CRUD/list__action_edit.html.twig b/src/Resources/views/CRUD/list__action_edit.html.twig index d130c9e576..ca12effe96 100644 --- a/src/Resources/views/CRUD/list__action_edit.html.twig +++ b/src/Resources/views/CRUD/list__action_edit.html.twig @@ -10,12 +10,21 @@ file that was distributed with this source code. #} {% if admin.hasAccess('edit', object) and admin.hasRoute('edit') %} + {% set button_content = sonata_config.getOption('list_action_button_content') %} - - {{ 'action_edit'|trans({}, 'SonataAdminBundle') }} + {% if button_content == 'icon' or button_content == 'all' %} + + {% endif %} + {% if button_content == 'text' or button_content == 'all' %} + {{ 'action_edit'|trans({}, 'SonataAdminBundle') }} + {% else %} + + {{ 'action_edit'|trans({}, 'SonataAdminBundle') }} + + {% endif %} {% endif %} diff --git a/src/Resources/views/CRUD/list__action_history.html.twig b/src/Resources/views/CRUD/list__action_history.html.twig index f4a2619ea1..15171695a4 100644 --- a/src/Resources/views/CRUD/list__action_history.html.twig +++ b/src/Resources/views/CRUD/list__action_history.html.twig @@ -10,12 +10,21 @@ file that was distributed with this source code. #} {% if admin.hasAccess('history', object) and admin.hasRoute('history') %} + {% set button_content = sonata_config.getOption('list_action_button_content') %} - - {{ 'link_action_history'|trans({}, 'SonataAdminBundle') }} + {% if button_content == 'icon' or button_content == 'all' %} + + {% endif %} + {% if button_content == 'text' or button_content == 'all' %} + {{ 'link_action_history'|trans({}, 'SonataAdminBundle') }} + {% else %} + + {{ 'link_action_history'|trans({}, 'SonataAdminBundle') }} + + {% endif %} {% endif %} diff --git a/src/Resources/views/CRUD/list__action_show.html.twig b/src/Resources/views/CRUD/list__action_show.html.twig index 8d407d50ba..bd5fa941f9 100644 --- a/src/Resources/views/CRUD/list__action_show.html.twig +++ b/src/Resources/views/CRUD/list__action_show.html.twig @@ -10,12 +10,21 @@ file that was distributed with this source code. #} {% if admin.hasAccess('show', object) and admin.hasRoute('show') %} + {% set button_content = sonata_config.getOption('list_action_button_content') %} - - {{ 'action_show'|trans({}, 'SonataAdminBundle') }} + {% if button_content == 'icon' or button_content == 'all' %} + + {% endif %} + {% if button_content == 'text' or button_content == 'all' %} + {{ 'action_show'|trans({}, 'SonataAdminBundle') }} + {% else %} + + {{ 'action_show'|trans({}, 'SonataAdminBundle') }} + + {% endif %} {% endif %} diff --git a/src/Resources/views/standard_layout.html.twig b/src/Resources/views/standard_layout.html.twig index 4c915adfbf..da0e50d205 100644 --- a/src/Resources/views/standard_layout.html.twig +++ b/src/Resources/views/standard_layout.html.twig @@ -125,10 +125,18 @@ file that was distributed with this source code. {% block logo %} {% apply spaceless %} diff --git a/src/SonataConfiguration.php b/src/SonataConfiguration.php index c750e15d90..eefe3102b8 100644 --- a/src/SonataConfiguration.php +++ b/src/SonataConfiguration.php @@ -25,7 +25,9 @@ * javascripts: list, * js_debug: bool, * legacy_twig_text_extension: bool, + * list_action_button_content: 'text'|'icon'|'all', * lock_protection: bool, + * logo_content: 'text'|'icon'|'all', * mosaic_background: string, * pager_links: ?int, * role_admin: string, @@ -34,7 +36,6 @@ * skin: string, * sort_admins: bool, * stylesheets: list, - * title_mode: 'single_text'|'single_image'|'both', * use_bootlint: bool, * use_icheck: bool, * use_select2: bool,