From cfac4d7ecdde224233eda5d58431944b8d24f972 Mon Sep 17 00:00:00 2001 From: Florian BLOUET Date: Tue, 16 Feb 2016 18:50:24 +0100 Subject: [PATCH] wip PHRAS-681 --- .../Elastic/ElasticSearchEngine.php | 2 +- resources/www/prod/js/jquery.main-prod.js | 5 ++++- templates/web/prod/index.html.twig | 22 ++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php index efd4a6aa49..dea000f4ce 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php @@ -133,7 +133,7 @@ class ElasticSearchEngine implements SearchEngineInterface */ public function getDefaultSort() { - return SearchEngineOptions::SORT_RELEVANCE; + return SearchEngineOptions::SORT_CREATED_ON; } /** diff --git a/resources/www/prod/js/jquery.main-prod.js b/resources/www/prod/js/jquery.main-prod.js index 6cc493ae01..07cb3cf984 100644 --- a/resources/www/prod/js/jquery.main-prod.js +++ b/resources/www/prod/js/jquery.main-prod.js @@ -132,7 +132,8 @@ function checkFilters(save) { bases: {}, fields: [], dates: {}, - status: [] + status: [], + sort: {} }; var adv_box = $('form.phrasea_query .adv_options'); @@ -220,6 +221,8 @@ function checkFilters(save) { $("option.default-selection", fieldsSort).prop("selected", true); $("option.default-selection", fieldsSortOrd).prop("selected", true); } + search.sort.by = $("option:selected:enabled", fieldsSort).val(); + search.sort.order = $("option:selected:enabled", fieldsSortOrd).val(); //--------- from fields filter --------- diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index e4aa0507f0..881f509526 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -237,15 +237,27 @@
+ {% set sortByDefault = app['phraseanet.SE'].getDefaultSort()%} + {% set sortOrderDefault = app['phraseanet.SE'].getDefaultSortDirection()%} + + {#{% set sortByPreference = constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') %}#} + {% if sortByPreference is not defined %} + {% set sortByPreference = sortByDefault %} + {% endif %} + + {% if sortOrderPreference is not defined %} + {% set sortOrderPreference = sortOrderDefault %} + {% endif %} + {{ 'Trier par' | trans }} - + {% set b = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %} - {% set b = (app['phraseanet.SE'].getDefaultSort() == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %} + {% set b = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %} {% for fieldname, sort in search_datas['sort'] %} - {% set b = (app['phraseanet.SE'].getDefaultSort() == fieldname) %} + {% set b = (sortOrderPreference == fieldname) %}