mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
#PHRAS-610 #time 2d
WIP
This commit is contained in:
@@ -131,7 +131,6 @@ class RootController extends Controller
|
||||
'thesau_languages' => $this->app['locales.available'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DisplaySettingService
|
||||
*/
|
||||
|
||||
@@ -53,19 +53,17 @@ class Prod extends Helper
|
||||
$data = array('sbas' => array($sbasId), 'fieldname' => $name, 'type' => $type, 'id' => $id);
|
||||
|
||||
if ($fieldMeta->get_type() === \databox_field::TYPE_DATE) {
|
||||
if (isset($dates[$id])) {
|
||||
$dates[$id]['sbas'][] = $sbasId;
|
||||
} else {
|
||||
$dates[$id] = $data;
|
||||
if (!array_key_exists($name, $dates)) {
|
||||
$dates[$name] = array('sbas' => array());
|
||||
}
|
||||
$dates[$name]['sbas'][] = $sbasId;
|
||||
}
|
||||
|
||||
if ($fieldMeta->get_type() == \databox_field::TYPE_NUMBER || $fieldMeta->get_type() === \databox_field::TYPE_DATE) {
|
||||
if (isset($sort[$id])) {
|
||||
$sort[$id]['sbas'][] = $sbasId;
|
||||
} else {
|
||||
$sort[$id] = $data;
|
||||
if (!array_key_exists($name, $sort)) {
|
||||
$sort[$name] = array('sbas' => array());
|
||||
}
|
||||
$sort[$name]['sbas'][] = $sbasId;
|
||||
}
|
||||
|
||||
if (isset($fields[$name])) {
|
||||
|
||||
@@ -253,7 +253,9 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$context = $this->createQueryContext($options);
|
||||
/** @var QueryCompiler $query_compiler */
|
||||
$query_compiler = $this->app['query_compiler'];
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($string, true)), FILE_APPEND);
|
||||
$recordQuery = $query_compiler->compile($string, $context);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($recordQuery, true)), FILE_APPEND);
|
||||
|
||||
$params = $this->createRecordQueryParams($recordQuery, $options, null);
|
||||
|
||||
@@ -272,8 +274,10 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
if ($aggs = $this->getAggregationQueryParams($options)) {
|
||||
$params['body']['aggs'] = $aggs;
|
||||
}
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($params, true)), FILE_APPEND);
|
||||
|
||||
$res = $this->client->search($params);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($res, true)), FILE_APPEND);
|
||||
|
||||
$results = new ArrayCollection();
|
||||
|
||||
@@ -289,7 +293,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$query['query_main'] = $recordQuery;
|
||||
$query['query'] = $params['body'];
|
||||
$query['query_string'] = json_encode($params['body']);
|
||||
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($query['query_string'], true)), FILE_APPEND);
|
||||
return new SearchEngineResult(
|
||||
$results, // ArrayCollection of results
|
||||
json_encode($query),
|
||||
|
||||
@@ -728,11 +728,11 @@ class ACL implements cache_cacheableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of sbas_id which are granted, with
|
||||
* Return an array of databox (key=sbas_id) which are granted, with
|
||||
* optionnal filter by rights
|
||||
*
|
||||
* @param Array $rights
|
||||
* @return Array
|
||||
* @return \databox[]
|
||||
*/
|
||||
public function get_granted_sbas($rights = [])
|
||||
{
|
||||
|
||||
@@ -21,25 +21,34 @@ class databox_status
|
||||
{
|
||||
public static function getSearchStatus(Application $app)
|
||||
{
|
||||
$see_all = $structures = $stats = [];
|
||||
$structures = $stats = [];
|
||||
foreach ($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas() as $databox) {
|
||||
$see_all[$databox->get_sbas_id()] = false;
|
||||
$see_all = false;
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($collection->get_base_id(), 'chgstatus')) {
|
||||
$see_all[$databox->get_sbas_id()] = true;
|
||||
$see_all = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$structures[$databox->get_sbas_id()] = $databox->getStatusStructure();
|
||||
}
|
||||
|
||||
foreach ($structures as $databox_id => $structure) {
|
||||
if (false === $see_all[$databox_id]) {
|
||||
$structure = array_filter($structure->toArray(), function ($status) {
|
||||
return (bool) $status['searchable'];
|
||||
$status = $databox->getStatusStructure()->toArray();
|
||||
if (!$see_all) {
|
||||
$status = array_filter($status, function ($statusbit) {
|
||||
return (bool)$statusbit['searchable'];
|
||||
});
|
||||
}
|
||||
ksort($status);
|
||||
|
||||
$structures[$databox->get_sbas_id()] = array(
|
||||
'name' => $databox->get_label($app['locale']),
|
||||
'status'=>$status
|
||||
);
|
||||
}
|
||||
ksort($structures);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($structures, true)), FILE_APPEND);
|
||||
|
||||
return $structures;
|
||||
|
||||
foreach ($structures as $databox_id => $structure) {
|
||||
foreach($structure as $bit => $status) {
|
||||
$key = RecordHelper::normalizeFlagKey($status['labelon']);
|
||||
|
||||
@@ -53,6 +62,96 @@ class databox_status
|
||||
$stats[$key] = $status;
|
||||
}
|
||||
}
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
|
||||
return $stats;
|
||||
}
|
||||
|
||||
public static function no_getSearchStatus(Application $app)
|
||||
{
|
||||
$see_all = $structures = $stats = [];
|
||||
foreach ($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas() as $databox) {
|
||||
$see_all[$databox->get_sbas_id()] = false;
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($collection->get_base_id(), 'chgstatus')) {
|
||||
$see_all[$databox->get_sbas_id()] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$structures[$databox->get_sbas_id()] = $databox->getStatusStructure();
|
||||
}
|
||||
|
||||
// order the result by bit number, ...
|
||||
$tbits = [];
|
||||
foreach ($structures as $databox_id => $structure) {
|
||||
if (false === $see_all[$databox_id]) {
|
||||
$structure = array_filter($structure->toArray(), function ($status) {
|
||||
return (bool)$status['searchable'];
|
||||
});
|
||||
}
|
||||
foreach($structure as $bit => $status) {
|
||||
if(!array_key_exists($bit, $tbits)) {
|
||||
$tbits[$bit] = [];
|
||||
}
|
||||
$tbits[$bit][$databox_id] = $status;
|
||||
}
|
||||
}
|
||||
ksort($tbits);
|
||||
// file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($tbits, true)), FILE_APPEND);
|
||||
|
||||
// ... but group the status with same name
|
||||
foreach($tbits as $bit=>$tbas) {
|
||||
foreach($tbas as $sbas_id=>$status) {
|
||||
// the group-key is the "labelon"
|
||||
$key = RecordHelper::normalizeFlagKey($status['labelon']);
|
||||
if(!array_key_exists($key, $stats)) {
|
||||
$stats[$key] = $status;
|
||||
$stats[$key]['sbas'] = [];
|
||||
// $stats[$key]['tbas'] = [];
|
||||
}
|
||||
else {
|
||||
/*
|
||||
if($stats[$key]['bit'] != $bit) {
|
||||
// error : in es, 2 sb with same name MUST be at the same position
|
||||
throw new UnexpectedValueException(
|
||||
sprintf("statusbit '%s' found at position %d and position %d"
|
||||
, $key, $stats[$key]['bit'], $bit
|
||||
)
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
$stats[$key]['sbas'][] = $sbas_id;
|
||||
// $stats[$key]['tbas'][$sbas_id] = $status;
|
||||
}
|
||||
}
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
|
||||
return $stats;
|
||||
|
||||
|
||||
|
||||
foreach ($structures as $databox_id => $structure) {
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n%s\n", __FILE__, __LINE__, var_export($databox_id, true), var_export($structure->toArray(), true)), FILE_APPEND);
|
||||
if (false === $see_all[$databox_id]) {
|
||||
$structure = array_filter($structure->toArray(), function ($status) {
|
||||
return (bool) $status['searchable'];
|
||||
});
|
||||
}
|
||||
|
||||
foreach($structure as $bit => $status) {
|
||||
$key = RecordHelper::normalizeFlagKey($status['labelon']);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %d:%s\n", __FILE__, __LINE__, $bit, $key), FILE_APPEND);
|
||||
|
||||
if (isset($stats[$key])) {
|
||||
$status = $stats[$key];
|
||||
}
|
||||
|
||||
$status['sbas'][] = $databox_id;
|
||||
$status['bit'] = $bit;
|
||||
|
||||
$stats[$key] = $status;
|
||||
}
|
||||
}
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
|
||||
return $stats;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
{% for base in search_datas['bases'] %}
|
||||
{% set sbas_id = base['sbas_id'] %}
|
||||
<div class="sbas_list sbas_{{sbas_id}}" style="margin-bottom: 10px;">
|
||||
<input type="hidden" name="reference" value="{{sbas_id}}"/>
|
||||
<div class="clksbas" style="text-align: center;">
|
||||
<label class="checkbox" for="sbasChkr_{{sbas_id}}_{{unique_id}}" onclick="clksbas({{sbas_id}}, $('#sbasChkr_{{sbas_id}}_{{unique_id}}')); return false;">
|
||||
<input type="checkbox" name="reference" value="{{sbas_id}}"/>
|
||||
<div class="clksbas">
|
||||
<span onclick="deploy(this, '.sbascont_{{sbas_id}}' );return false;" class="deployer_opened" ></span>
|
||||
<label style="display: inline" class="checkbox" for="sbasChkr_{{sbas_id}}_{{unique_id}}" onclick="clksbas({{sbas_id}}, $('#sbasChkr_{{sbas_id}}_{{unique_id}}')); return false;">
|
||||
<span>{{sbas_id|sbas_labels(app)}}</span>
|
||||
<span class="infos_sbas_{{sbas_id}}">
|
||||
{{base["collections"]|length}}/{{base['collections']|length}}
|
||||
@@ -25,7 +26,7 @@
|
||||
onclick="cancelEvent(event);return false;"
|
||||
onmousedown="infoSbas(this, {{sbas_id}}, false, event); return false;"
|
||||
id="ck_{{collection["base_id"]}}_{{unique_id}}" type="checkbox"
|
||||
name="bases[{{ collection["base_id"] }}]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} />
|
||||
name="bases[]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} />
|
||||
</td>
|
||||
<td>
|
||||
<label style="line-height: 18px;" onclick="infoSbas($('#ck_{{base_id}}_{{unique_id}}'),{{sbas_id}}, false, event); return false;"
|
||||
@@ -74,6 +75,15 @@
|
||||
.disable {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.deployer_opened::before {
|
||||
content: "\25BC";
|
||||
}
|
||||
|
||||
.deployer_closed::before {
|
||||
content: "\25B6";
|
||||
}
|
||||
|
||||
</style>
|
||||
<style type="text/css">
|
||||
/* Vertical Tabs */
|
||||
@@ -285,11 +295,12 @@
|
||||
<input type="hidden" name="pag" id="formAnswerPage" value="">
|
||||
<input type="hidden" name="sel" value="">
|
||||
|
||||
|
||||
<div class="adv_options" style="display:none;">
|
||||
<table style="width:100%; table-layout:fixed;">
|
||||
<tr>
|
||||
<td style="width:50%; vertical-align:top;">
|
||||
<div class="sbasglob">
|
||||
<div id="ADVSRCH_SBAS_ZONE" class="sbasglob">
|
||||
<div class="btn-toolbar">
|
||||
<input class="btn btn-inverse" type="button"
|
||||
value="{{ 'boutton:: selectionner toutes les bases' | trans }}" onclick="checkBases(true);" />
|
||||
@@ -304,99 +315,102 @@
|
||||
<div class="btn-toolbar">
|
||||
<input class="btn btn-inverse" type="button" value="{{ 'Re-initialiser' | trans }}" onclick="reset_adv_search();" />
|
||||
</div>
|
||||
<div id="ADVSRCH_OPTIONS_ZONE">
|
||||
<div class="ADVSRCH_SORT_ZONE">
|
||||
<span>{{ 'Trier par' | trans }}</span>
|
||||
<select name="sort" class="input-medium">
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
||||
<optgroup label="{{ 'By field'|trans }}">
|
||||
{% for fieldname, sort in search_datas['sort'] %}
|
||||
<option value="{{ fieldname }}"
|
||||
{% if fieldname == app['phraseanet.SE'].getDefaultSort() %}selected="selected"{% endif %}
|
||||
class="{% if fieldname == app['phraseanet.SE'].getDefaultSort() %}default-selection {% endif %}dbx db_{{sort['sbas']|join(' db_')}}"
|
||||
>{{ fieldname }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
</select>
|
||||
<select name="ord" class="input-medium">
|
||||
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
||||
<option value="{{ ord }}">{{ ord_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<span>{{ 'Trier par' | trans }}</span>
|
||||
<select name="sort" class="input-medium">
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
||||
<optgroup label="{{ 'By field'|trans }}">
|
||||
{% for sort in search_datas['sort'] %}
|
||||
<option value="{{ sort.fieldname }}" {% if sort.fieldname == app['phraseanet.SE'].getDefaultSort() %}selected="selected" class="default-selection"{% endif %}>{{ sort.fieldname }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
</select>
|
||||
<select name="ord" class="input-medium">
|
||||
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
||||
<option value="{{ ord }}">{{ ord_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if app['phraseanet.SE'].hasStemming() and app['phraseanet.SE'].isStemmingEnabled() %}
|
||||
<div>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" checked="checked" name="stemme" /> {{ 'rechercher par stemme' | trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="field_filter">
|
||||
<span>{{ 'Les termes apparaissent dans le(s) champs' | trans }}</span>
|
||||
<select size="8" multiple onchange="checkFilters(true);" name="fields[]" style="vertical-align:middle; width:99%;">
|
||||
<option value="phraseanet--all--fields">{{ 'rechercher dans tous les champs' | trans }}</option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] != 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|join(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div id="ADVSRCH_FIELDS_ZONE" class="danger_indicator">
|
||||
<span>{{ 'Les termes apparaissent dans le(s) champs' | trans }}</span>
|
||||
<select size="8" multiple onchange="checkFilters(true);" name="fields[]" style="vertical-align:middle; width:99%;">
|
||||
<option value="phraseanet--all--fields">{{ 'rechercher dans tous les champs' | trans }}</option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] != 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|join(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% set status_length = search_status|length %}
|
||||
{% if status_length > 0 %}
|
||||
<hr />
|
||||
<div class="status_filter">
|
||||
<div id="ADVSRCH_SB_ZONE">
|
||||
{% set status_length = search_status|length %}
|
||||
{% if status_length > 0 %}
|
||||
<hr />
|
||||
<span>{{ 'Status des documents a rechercher' | trans }}</span>
|
||||
<table style="width: 100%;">
|
||||
{% for status_key, flag in search_status %}
|
||||
{% for databox_id in flag.sbas %}
|
||||
{% for databox_id, databox in search_status %}
|
||||
<table style="width: 100%;" id="ADVSRCH_SB_ZONE_{{databox_id}}" class="field_{{databox_id}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<span onclick="deploy(this, '#ADVSRCH_SB_{{databox_id}}' );return false;" class="deployer_opened" ></span>
|
||||
<span class="danger_indicator">{{ databox['name'] }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ADVSRCH_SB_{{databox_id}}">
|
||||
{% for status_bit, status in databox.status %}
|
||||
<tr>
|
||||
<td>
|
||||
<label class="checkbox inline">
|
||||
{% if flag['img_off'] %}
|
||||
<img src="{{flag['img_off']}}" title="{{flag['labels_off_i18n'][app['locale']]}}" />
|
||||
{% if status['img_off'] %}
|
||||
<img src="{{status['img_off']}}" title="{{status['labels_off_i18n'][app['locale']]}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{databox_id}}"
|
||||
type="checkbox" value="0"
|
||||
n="{{flag['bit']}}" name="status[{{databox_id}}][{{flag['bit']}}]" />
|
||||
{{flag['labels_off_i18n'][app['locale']]}}
|
||||
n="{{status_bit}}" name="status[{{databox_id}}][{{status_bit}}]" />
|
||||
{{status['labels_off_i18n'][app['locale']]}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label class="checkbox inline">
|
||||
{% if flag['img_on'] %}
|
||||
<img src="{{flag['img_on']}}" title="{{flag['labels_on_i18n'][app['locale']]}}" />
|
||||
{% if status['img_on'] %}
|
||||
<img src="{{status['img_on']}}" title="{{status['labels_on_i18n'][app['locale']]}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{databox_id}}"
|
||||
type="checkbox" value="1"
|
||||
n="{{flag['bit']}}" name="status[{{databox_id}}][{{flag['bit']}}]"/>
|
||||
{{flag['labels_on_i18n'][app['locale']]}}
|
||||
n="{{status_bit}}" name="status[{{databox_id}}][{{status_bit}}]"/>
|
||||
{{status['labels_on_i18n'][app['locale']]}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app['phraseanet.SE'].getAvailableDateFields() | length > 0 %}
|
||||
<hr />
|
||||
<div class="date_filter">
|
||||
<div id="ADVSRCH_DATE_ZONE">
|
||||
{% if app['phraseanet.SE'].getAvailableDateFields() | length > 0 %}
|
||||
<hr />
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">{{ 'Rechercher dans un champ date' | trans }}</td>
|
||||
<td colspan="2">
|
||||
<select name="date_field" class="input-medium">
|
||||
{% for date in search_datas['dates'] %}
|
||||
<option onchange="checkFilters(true);" selected="selected"
|
||||
value="">{{ 'Rechercher dans un champ date' | trans }}</option>
|
||||
{% for fieldname, date in search_datas['dates'] %}
|
||||
<option onchange="checkFilters(true);"
|
||||
class="" value="{{ date.fieldname }}">{{ date.fieldname }}</option>
|
||||
class="db_{{date['sbas']|join(' db_')}}" value="{{ fieldname }}">{{ fieldname }}</option>
|
||||
{% endfor %}
|
||||
|
||||
{% set date_field_names = [] %}
|
||||
{% for field in search_datas['dates'] %}
|
||||
{% set date_field_names = date_field_names|merge([field.fieldname]) %}
|
||||
{% endfor %}
|
||||
<option value="{{ date_field_names|join('|') }}" selected="selected">
|
||||
{{ 'rechercher dans tous les champs'| trans }}
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -417,8 +431,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1557,18 +1557,13 @@ form.phrasea_query input.query {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.phrasea_query input.danger,
|
||||
.phrasea_query .date_filter.danger,
|
||||
.phrasea_query .field_filter.danger,
|
||||
.phrasea_query .status_filter.danger {
|
||||
#searchForm .danger .danger_indicator,
|
||||
#searchForm .danger.danger_indicator {
|
||||
border-color: #c9c900;
|
||||
background-color: #FCEC98;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#searchForm .danger label {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#adv_search table.colllist {
|
||||
width: 290px;
|
||||
|
||||
@@ -177,34 +177,49 @@ function checkFilters(save) {
|
||||
var danger = false;
|
||||
var search = {
|
||||
bases: {},
|
||||
fields: {},
|
||||
fields: [],
|
||||
dates: {},
|
||||
status: {}
|
||||
status: []
|
||||
};
|
||||
|
||||
var adv_box = $('form.phrasea_query .adv_options');
|
||||
var container = $("#sbasfiltercont");
|
||||
var fieldsSelect = $('.field_filter select', container);
|
||||
var filters = $('.field_filter, .status_filter, .date_filter', adv_box);
|
||||
var container = $("#ADVSRCH_OPTIONS_ZONE");
|
||||
var fieldsSort = $('#ADVSRCH_SORT_ZONE select[name=sort]', container);
|
||||
var fieldsSelect = $('#ADVSRCH_FIELDS_ZONE select', container);
|
||||
var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
|
||||
var scroll = fieldsSelect.scrollTop();
|
||||
var switches = $('.field_switch', container);
|
||||
|
||||
/*
|
||||
switches.filter('.was').removeClass('was');
|
||||
switches.filter('option:selected, input:checked').addClass('was');
|
||||
|
||||
$('select option.field_switch', container).addClass("hidden");
|
||||
$('input.field_switch:checked', container).removeAttr('checked');
|
||||
$('input.field_switch:checkbox', container).parent().hide();
|
||||
// $('select option.field_switch', container).addClass("hidden");
|
||||
// $('input.field_switch:checked', container).removeAttr('checked');
|
||||
// $('input.field_switch:checkbox', container).parent().hide();
|
||||
|
||||
filters.removeClass('danger');
|
||||
// filters.removeClass('danger');
|
||||
|
||||
|
||||
// mark the selected options in the "fields" select
|
||||
*/
|
||||
// hide all the fields in the "fields" select, so only the relevant ones will be shown again
|
||||
$("option:gt(0)", fieldsSelect).prop("disabled", true); // option[0] is "all fields"
|
||||
$("option:gt(0)", fieldsSelect).hide(); // option[0] is "all fields"
|
||||
|
||||
// hide all the fields in the "sort by" select, so only the relevant ones will be shown again
|
||||
$("option.dbx", fieldsSort).prop("disabled", true); // dbx is for "field of databases"
|
||||
$("option.dbx", fieldsSort).hide();
|
||||
|
||||
// hide all the fields in the "date field" select, so only the relevant ones will be shown again
|
||||
$("option.dbx", dateFilterSelect).prop("disabled", true); // dbx = all "field" entries in the select = all except the firstt
|
||||
$("option.dbx", dateFilterSelect).hide();
|
||||
|
||||
var nbSelectedColls = 0;
|
||||
|
||||
$.each($('.sbascont', adv_box), function () {
|
||||
var $this = $(this);
|
||||
|
||||
var sbas_id = $this.parent().find('input[name="reference"]').val();
|
||||
search.bases[sbas_id] = new Array();
|
||||
search.bases[sbas_id] = [];
|
||||
|
||||
var bas_ckbox = $this.find('.checkbas');
|
||||
if (bas_ckbox.filter(':not(:checked)').length > 0) {
|
||||
@@ -212,59 +227,141 @@ function checkFilters(save) {
|
||||
}
|
||||
|
||||
var checked = bas_ckbox.filter(':checked');
|
||||
|
||||
/*
|
||||
if (checked.length > 0) {
|
||||
var sbas_fields = $('.field_' + sbas_id, container).removeClass("hidden");
|
||||
sbas_fields.filter('option').show().filter('.was').removeClass('was').attr('selected', 'selected').selected(true);
|
||||
sbas_fields.filter(':checkbox').parent().show().find('.was').attr('checked', 'checked').removeClass('was');
|
||||
}
|
||||
|
||||
*/
|
||||
var nbSelectedCollsForSBas = 0;
|
||||
checked.each(function () {
|
||||
nbSelectedCollsForSBas++;
|
||||
nbSelectedColls++;
|
||||
search.bases[sbas_id].push($(this).val());
|
||||
});
|
||||
|
||||
if(nbSelectedCollsForSBas == 0) {
|
||||
// no collections checked for this databox
|
||||
// hide the status bits
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id, container).hide();
|
||||
// uncheck
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id+" input:checkbox", container).prop("checked", false);
|
||||
}
|
||||
else {
|
||||
// at least one coll checked for this databox
|
||||
// show again the relevant fields in "sort by" select
|
||||
$(".db_"+sbas_id, fieldsSort).prop("disabled", false);
|
||||
$(".db_"+sbas_id, fieldsSort).show();
|
||||
// show again the relevant fields in "from fields" select
|
||||
$(".field_"+sbas_id, fieldsSelect).prop("disabled", false);
|
||||
$(".field_"+sbas_id, fieldsSelect).show();
|
||||
// show the sb
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id, container).show();
|
||||
// show again the relevant fields in "date field" select
|
||||
$(".db_"+sbas_id, dateFilterSelect).prop("disabled", false);
|
||||
$(".db_"+sbas_id, dateFilterSelect).show();
|
||||
}
|
||||
});
|
||||
|
||||
if (nbSelectedColls === 0) {
|
||||
filters.addClass("danger");
|
||||
// no collections checked at all
|
||||
// filters.addClass("danger");
|
||||
// hide irrelevant filters
|
||||
$("#ADVSRCH_OPTIONS_ZONE").hide();
|
||||
}
|
||||
else {
|
||||
// at least one collection checked
|
||||
// show relevant filters
|
||||
$("#ADVSRCH_OPTIONS_ZONE").show();
|
||||
}
|
||||
|
||||
search.fields = (search.fields = fieldsSelect.val()) !== null ? search.fields : new Array;
|
||||
// --------- sort --------
|
||||
|
||||
var reset_field = false;
|
||||
|
||||
$.each(search.fields, function (i, n) {
|
||||
if (n === 'phraseanet--all--fields')
|
||||
reset_field = true;
|
||||
});
|
||||
|
||||
if (reset_field) {
|
||||
$('select[name="fields[]"] option:selected', container).removeAttr('selected').selected(false);
|
||||
search.fields = new Array;
|
||||
// if no field is selected for sort, select the first option
|
||||
if($("option.dbx:selected:visible:enabled", fieldsSort).length == 0) {
|
||||
$("option:eq(0)", fieldsSort).prop("selected", true);
|
||||
}
|
||||
|
||||
if (!reset_field && search.fields.length > 0) {
|
||||
danger = true;
|
||||
$('.field_filter', adv_box).addClass('danger');
|
||||
//--------- from fields filter ---------
|
||||
|
||||
// unselect the unavailable fields (or all fields if "all" is selected)
|
||||
var optAllSelected = false;
|
||||
$("option", fieldsSelect).each(
|
||||
function(idx, opt) {
|
||||
if(idx == 0) {
|
||||
// nb: unselect the "all" field, so it acts as a button
|
||||
optAllSelected = $(opt).is(":selected");
|
||||
}
|
||||
if(idx == 0 || optAllSelected || $(opt).is(":disabled") || !$(opt).is(":visible") ) {
|
||||
$(opt).prop("selected", false);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// here only the relevant fields are selected
|
||||
search.fields = fieldsSelect.val();
|
||||
if(search.fields == null || search.fields.length == 0) {
|
||||
$('#ADVSRCH_FIELDS_ZONE', container).removeClass('danger');
|
||||
search.fields = [];
|
||||
}
|
||||
else {
|
||||
$('#ADVSRCH_FIELDS_ZONE', container).addClass('danger');
|
||||
}
|
||||
|
||||
$('.status_filter :checkbox[checked]').each(function () {
|
||||
//--------- status bits filter ---------
|
||||
|
||||
// here only the relevant sb are checked
|
||||
for(sbas_id in search.bases) {
|
||||
var nchecked = 0;
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id+" :checkbox[checked]", container).each(function () {
|
||||
var n = $(this).attr('n');
|
||||
search.status[n] = $(this).val().split('_');
|
||||
nchecked++;
|
||||
});
|
||||
if(nchecked == 0) {
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id, container).removeClass('danger');
|
||||
}
|
||||
else {
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id, container).addClass('danger');
|
||||
}
|
||||
}
|
||||
/*
|
||||
$('#ADVSRCH_SB_ZONE :checkbox[checked]').each(function () {
|
||||
var n = $(this).attr('n');
|
||||
search.status[n] = $(this).val().split('_');
|
||||
danger = true;
|
||||
$('.status_filter', adv_box).addClass('danger');
|
||||
});
|
||||
if(search.status.length == 0) {
|
||||
$('#ADVSRCH_SB_ZONE', container).removeClass('danger');
|
||||
}
|
||||
else {
|
||||
$('#ADVSRCH_SB_ZONE', container).addClass('danger');
|
||||
}
|
||||
*/
|
||||
//--------- dates filter ---------
|
||||
|
||||
search.dates.minbound = $('.date_filter input[name=date_min]', adv_box).val();
|
||||
search.dates.maxbound = $('.date_filter input[name=date_max]', adv_box).val();
|
||||
search.dates.field = $('.date_filter select[name=date_field]', adv_box).val();
|
||||
// if no date field is selected for filter, select the first option
|
||||
if($("option.dbx:selected:visible:enabled", dateFilterSelect).length == 0) {
|
||||
$("option:eq(0)", dateFilterSelect).prop("selected", true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
search.dates.minbound = $('#ADVSRCH_DATE_ZONE input[name=date_min]', adv_box).val();
|
||||
search.dates.maxbound = $('#ADVSRCH_DATE_ZONE input[name=date_max]', adv_box).val();
|
||||
search.dates.field = $('#ADVSRCH_DATE_ZONE select[name=date_field]', adv_box).val();
|
||||
|
||||
if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) {
|
||||
danger = true;
|
||||
$('.date_filter', adv_box).addClass('danger');
|
||||
$('#ADVSRCH_DATE_ZONE', adv_box).addClass('danger');
|
||||
}
|
||||
|
||||
|
||||
|
||||
fieldsSelect.scrollTop(scroll);
|
||||
|
||||
if (save === true)
|
||||
@@ -275,13 +372,14 @@ function checkFilters(save) {
|
||||
else
|
||||
$('#EDIT_query').removeClass('danger');
|
||||
}
|
||||
|
||||
function toggleFilter(filter, ele) {
|
||||
var el = $('#' + filter);
|
||||
if (el.is(':hidden'))
|
||||
$(ele).parent().addClass('open');
|
||||
else
|
||||
$(ele).parent().removeClass('open');
|
||||
$('#' + filter).slideToggle('fast');
|
||||
el.slideToggle('fast');
|
||||
}
|
||||
|
||||
|
||||
@@ -290,11 +388,11 @@ function setVisible(el) {
|
||||
}
|
||||
|
||||
function resize() {
|
||||
bodySize.y = $('#mainContainer').height();
|
||||
bodySize.x = $('#mainContainer').width();
|
||||
var body = $('#mainContainer');
|
||||
bodySize.y = body.height();
|
||||
bodySize.x = body.width();
|
||||
|
||||
if (false)
|
||||
$('.overlay').height(bodySize.y).width(bodySize.x);
|
||||
$('.overlay').height(bodySize.y).width(bodySize.x);
|
||||
|
||||
var headBlockH = $('#headBlock').outerHeight();
|
||||
var bodyY = bodySize.y - headBlockH - 2;
|
||||
@@ -323,9 +421,9 @@ function clearAnswers() {
|
||||
}
|
||||
|
||||
function reset_adv_search() {
|
||||
$('#sbasfiltercont select[name="sort"]').val($('#sbasfiltercont select[name="sort"] option.default-selection').attr('value'));
|
||||
$('#sbasfiltercont input:checkbox.field_switch').removeAttr('checked');
|
||||
$('#sbasfiltercont .datepicker').val('');
|
||||
$('#ADVSRCH_OPTIONS_ZONE select[name="sort"]').val($('#ADVSRCH_OPTIONS_ZONE select[name="sort"] option.default-selection').attr('value'));
|
||||
$('#ADVSRCH_OPTIONS_ZONE input:checkbox.field_switch').removeAttr('checked');
|
||||
$('#ADVSRCH_OPTIONS_ZONE .datepicker').val('');
|
||||
$('form.adv_search_bind input:text').val('');
|
||||
checkBases(true);
|
||||
}
|
||||
@@ -640,6 +738,8 @@ function facetCombinedSearch() {
|
||||
$(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
function answerSizer() {
|
||||
var el = $('#idFrameC').outerWidth();
|
||||
if (!$.support.cssFloat) {
|
||||
@@ -2638,6 +2738,18 @@ function deleteBasket(item) {
|
||||
});
|
||||
}
|
||||
|
||||
function deploy(deployer, todeploy_selector)
|
||||
{
|
||||
if($(deployer).hasClass("deployer_opened")) {
|
||||
$(deployer).removeClass("deployer_opened").addClass("deployer_closed");
|
||||
$(todeploy_selector).hide();
|
||||
}
|
||||
else {
|
||||
$(deployer).removeClass("deployer_closed").addClass("deployer_opened");
|
||||
$(todeploy_selector).show();
|
||||
}
|
||||
}
|
||||
|
||||
function clksbas(num, el) {
|
||||
var bool = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user