mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-681 - fix default value of advanced search options: sort value and sort order
This commit is contained in:
@@ -21,7 +21,7 @@ class Prod extends Helper
|
|||||||
|
|
||||||
public function get_search_datas()
|
public function get_search_datas()
|
||||||
{
|
{
|
||||||
$searchData = array('bases' => array(), 'dates' => array(), 'fields' => array(), 'sort' => array(),);
|
$searchData = array('bases' => array(), 'dates' => array(), 'fields' => array(), 'sort' => array(), 'elasticSort' => array());
|
||||||
|
|
||||||
$bases = $fields = $dates = $sort = array();
|
$bases = $fields = $dates = $sort = array();
|
||||||
|
|
||||||
@@ -102,10 +102,15 @@ class Prod extends Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('elasticSort', $searchSet)){
|
||||||
|
$elasticSort = $searchSet['elasticSort'];
|
||||||
|
}
|
||||||
|
|
||||||
$searchData['fields'] = $fields;
|
$searchData['fields'] = $fields;
|
||||||
$searchData['dates'] = $dates;
|
$searchData['dates'] = $dates;
|
||||||
$searchData['bases'] = $bases;
|
$searchData['bases'] = $bases;
|
||||||
$searchData['sort'] = $sort;
|
$searchData['sort'] = $sort;
|
||||||
|
$searchData['elasticSort'] = $elasticSort;
|
||||||
|
|
||||||
return $searchData;
|
return $searchData;
|
||||||
}
|
}
|
||||||
|
@@ -133,7 +133,8 @@ function checkFilters(save) {
|
|||||||
fields: [],
|
fields: [],
|
||||||
dates: {},
|
dates: {},
|
||||||
status: [],
|
status: [],
|
||||||
sort: {}
|
elasticSort: {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var adv_box = $('form.phrasea_query .adv_options');
|
var adv_box = $('form.phrasea_query .adv_options');
|
||||||
@@ -221,8 +222,9 @@ function checkFilters(save) {
|
|||||||
$("option.default-selection", fieldsSort).prop("selected", true);
|
$("option.default-selection", fieldsSort).prop("selected", true);
|
||||||
$("option.default-selection", fieldsSortOrd).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();
|
search.elasticSort.by = $("option:selected:enabled", fieldsSort).val();
|
||||||
|
search.elasticSort.order = $("option:selected:enabled", fieldsSortOrd).val();
|
||||||
|
|
||||||
//--------- from fields filter ---------
|
//--------- from fields filter ---------
|
||||||
|
|
||||||
|
@@ -240,21 +240,23 @@
|
|||||||
{% set sortByDefault = app['phraseanet.SE'].getDefaultSort()%}
|
{% set sortByDefault = app['phraseanet.SE'].getDefaultSort()%}
|
||||||
{% set sortOrderDefault = app['phraseanet.SE'].getDefaultSortDirection()%}
|
{% set sortOrderDefault = app['phraseanet.SE'].getDefaultSortDirection()%}
|
||||||
|
|
||||||
{#{% set sortByPreference = constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') %}#}
|
|
||||||
{% if sortByPreference is not defined %}
|
|
||||||
{% set sortByPreference = sortByDefault %}
|
{% set sortByPreference = sortByDefault %}
|
||||||
|
{% if search_datas.elasticSort.by is defined %}
|
||||||
|
{% set sortByPreference = search_datas.elasticSort.by %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if sortOrderPreference is not defined %}
|
|
||||||
{% set sortOrderPreference = sortOrderDefault %}
|
{% set sortOrderPreference = sortOrderDefault %}
|
||||||
|
{% if search_datas.elasticSort.order is defined %}
|
||||||
|
{% set sortOrderPreference = search_datas.elasticSort.order %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<span>{{ 'Trier par' | trans }}</span>
|
<span>{{ 'Trier par' | trans }}</span>
|
||||||
<select name="sort" class="input-medium" onchange="checkFilters(true);">
|
<select name="sort" class="input-medium" onchange="checkFilters(true);">
|
||||||
{% set b = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
|
{% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
|
||||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
{% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
|
||||||
{% set b = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
|
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
{% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
|
||||||
|
{% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
|
||||||
|
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
||||||
<optgroup label="{{ 'By field'|trans }}">
|
<optgroup label="{{ 'By field'|trans }}">
|
||||||
{% for fieldname, sort in search_datas['sort'] %}
|
{% for fieldname, sort in search_datas['sort'] %}
|
||||||
{% set b = (sortOrderPreference == fieldname) %}
|
{% set b = (sortOrderPreference == fieldname) %}
|
||||||
@@ -267,8 +269,9 @@
|
|||||||
</select>
|
</select>
|
||||||
<select name="ord" class="input-medium" onchange="checkFilters(true);">
|
<select name="ord" class="input-medium" onchange="checkFilters(true);">
|
||||||
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
||||||
{% set b = (app['phraseanet.SE'].getDefaultSortDirection() == ord) %}
|
{% set isSelected = (sortOrderPreference == ord) %}
|
||||||
<option value="{{ ord }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ ord_name }}</option>
|
{% set isDefault = (sortOrderDefault == ord) %}
|
||||||
|
<option value="{{ ord }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ ord_name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user