diff --git a/src/bundle/Resources/encore/ibexa.js.config.js b/src/bundle/Resources/encore/ibexa.js.config.js index 45a476e77d..fafed96f38 100644 --- a/src/bundle/Resources/encore/ibexa.js.config.js +++ b/src/bundle/Resources/encore/ibexa.js.config.js @@ -130,6 +130,7 @@ module.exports = (Encore) => { .addEntry('ibexa-admin-ui-search-js', [ path.resolve(__dirname, '../public/js/scripts/button.content.edit.js'), path.resolve(__dirname, '../public/js/scripts/admin.search.filters.js'), + path.resolve(__dirname, '../public/js/scripts/admin.search.sorting.js'), path.resolve(__dirname, '../public/js/scripts/admin.search.js'), path.resolve(__dirname, '../public/js/scripts/udw/select.location.js'), path.resolve(__dirname, '../public/js/scripts/button.translation.edit.js'), diff --git a/src/bundle/Resources/public/js/scripts/admin.search.sorting.js b/src/bundle/Resources/public/js/scripts/admin.search.sorting.js new file mode 100644 index 0000000000..cb8c618079 --- /dev/null +++ b/src/bundle/Resources/public/js/scripts/admin.search.sorting.js @@ -0,0 +1,14 @@ +(function (global, doc) { + const searchForm = doc.querySelector('.ibexa-search-form'); + const searchSortOrderSelect = doc.querySelector('.ibexa-search-form__sort-order-select'); + + if (searchSortOrderSelect) { + searchSortOrderSelect.addEventListener( + 'change', + () => { + searchForm.submit(); + }, + false, + ); + } +})(window, window.document); diff --git a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig index 12f3e29fca..2968a53d4c 100644 --- a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig @@ -30,6 +30,8 @@ {% endfor %} + + {{ form_widget(form.sort, { attr: { dropdown_hidden: true }}) }} {% else %}
{% set body_rows = [] %} @@ -165,6 +167,10 @@ { }, ] %} + {% set actions %} + {{ form_widget(form.sort, { attr: { class: 'ibexa-search-form__sort-order-select' }}) }} + {% endset %} + {% embed '@ibexadesign/ui/component/table/table.html.twig' with { headline: 'search.results_for'|trans({ '%total%': pager.nbResults, @@ -172,6 +178,7 @@ })|desc('Results for “%search_phrase%” (%total%)'), head_cols: head_cols, body_rows: body_rows, + actions, } %} {% trans_default_domain 'ibexa_search' %} {% block between_header_and_table %} @@ -205,4 +212,6 @@

{{ 'search.empty.title'|trans|desc('No search items') }}

{{ 'search.empty.subtitle'|trans|desc('Enter the phrase to find') }}
+ + {{ form_widget(form.sort, { attr: { dropdown_hidden: true }}) }} {% endif %}