mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00
New Adv Search
This commit is contained in:
@@ -602,177 +602,141 @@
|
||||
<input onclick="reset_adv_search();" type="button" value="{% trans 'Re-initialiser' %}" class="input-button"/>
|
||||
</div>
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
{% trans 'Chercher tous les mots' %}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width:150px;" name="query_all" type="text" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
{% trans 'Cette expression exacte' %}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width:150px;" name="query_exact" type="text" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
{% trans 'Au moins un des mots suivants' %}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width:150px;" name="query_or" type="text" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
{% trans 'Aucun des mots suivants' %}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width:150px;" name="query_none" type="text" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<div class="sbasglob ui-corner-all">
|
||||
<div style="text-align:center;margin:0 10px;">
|
||||
<input class="input-button" type="button"
|
||||
value="{% trans 'boutton:: selectionner toutes les bases' %}" onclick="checkBases(true);"/>
|
||||
<input class="input-button" type="button"
|
||||
value="{% trans 'boutton:: selectionner aucune base' %}" onclick="checkBases(false);"/>
|
||||
</div>
|
||||
{{_self.bas_list(module_prod, search_datas)}}
|
||||
</div>
|
||||
<div id="sbasfiltercont" class="ui-corner-all">
|
||||
<div>
|
||||
{% if registry.get('GV_sphinx') %}
|
||||
{% trans 'Trier par ' %}
|
||||
<select name="sort">
|
||||
<option value="relevance">{% trans 'pertinence'%}</option>
|
||||
<option value="created_on">{% trans 'date dajout'%}</option>
|
||||
<option value="random">{% trans 'aleatoire'%}</option>
|
||||
</select>
|
||||
<select name="ord">
|
||||
<option value="desc">{% trans 'descendant'%}</option>
|
||||
<option value="asc">{% trans 'ascendant'%}</option>
|
||||
</select>
|
||||
<input type="checkbox" checked="checked" name="stemme" /> {% trans 'rechercher par stemme' %}
|
||||
{% else %}
|
||||
{% trans 'Trier par ' %}
|
||||
<select name="sort">
|
||||
<option value=""></option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] == 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="ord">
|
||||
<option value="desc">{% trans 'descendant'%}</option>
|
||||
<option value="asc">{% trans 'ascendant'%}</option>
|
||||
</select>
|
||||
<input type="hidden" name="ord" id="searchOrd" value="PHRASEA_ORDER_DESC" />
|
||||
{% endif %}
|
||||
<div class="field_filter">
|
||||
<div>
|
||||
{% trans 'Les termes apparaissent dans le(s) champs' %}
|
||||
<table style="widtg:100%;table-layout:fixed;">
|
||||
<tr>
|
||||
<td style="width:50%;vertical-align:top;">
|
||||
<div class="sbasglob ui-corner-all">
|
||||
<div style="text-align:center;margin:0 10px;">
|
||||
<input class="input-button" type="button"
|
||||
value="{% trans 'boutton:: selectionner toutes les bases' %}" onclick="checkBases(true);"/>
|
||||
<input class="input-button" type="button"
|
||||
value="{% trans 'boutton:: selectionner aucune base' %}" onclick="checkBases(false);"/>
|
||||
</div>
|
||||
{{_self.bas_list(module_prod, search_datas)}}
|
||||
</div>
|
||||
<select size="8" multiple onchange="checkFilters(true);" name="fields[]" style="vertical-align:middle;width:100%;">
|
||||
<option value="phraseanet--all--fields">{% trans 'rechercher dans tous les champs' %}</option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] != 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% set status_length = search_status|length %}
|
||||
{% if status_length > 0 %}
|
||||
|
||||
<div style="margin:5px 0;">
|
||||
<hr/>
|
||||
</div>
|
||||
<div class="status_filter">
|
||||
|
||||
<div>
|
||||
{% trans 'Status des documents a rechercher' %}
|
||||
</div>
|
||||
<table>
|
||||
{% for n, stat in search_status %}
|
||||
{% for s in stat %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if s['imgoff'] %}
|
||||
<img src="{{s['imgoff']}}" title="{{s['labeloff']}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{s['sbas']|implode('field_')}}"
|
||||
type="checkbox" value="{{s['sbas']|implode(' field_')}}"
|
||||
n="{{n}}" name="status[{{n}}][off][]"/><label>{{s['labeloff']}}</label>
|
||||
</td>
|
||||
<td>
|
||||
{% if s['imgoff'] %}
|
||||
<img src="{{s['imgon']}}" title="{{s['labelon']}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{s['sbas']|implode('field_')}}"
|
||||
type="checkbox" value="{{s['sbas']|implode(' field_')}}"
|
||||
n="{{n}}" name="status[{{n}}][on][]"/><label>{{s['labelon']}}</label>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set dates_length = search_datas['dates']|length %}
|
||||
{% if dates_length > 0 %}
|
||||
<div style="margin:5px 0;">
|
||||
<hr/>
|
||||
</div>
|
||||
<div class="date_filter">
|
||||
<div>{% trans 'Rechercher dans un champ date' %}</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<select name="datefield">
|
||||
{% for field_id, field in search_datas['dates'] %}
|
||||
<option onchange="checkFilters(true);"
|
||||
class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endfor %}
|
||||
<option value="{{search_datas['dates']|array_keys|implode('|')}}" selected="selected">
|
||||
{% trans 'rechercher dans tous les champs' %}
|
||||
</option>
|
||||
</td>
|
||||
<td style="width:50%;vertical-align:top;">
|
||||
<div id="sbasfiltercont" class="ui-corner-all">
|
||||
<div>
|
||||
{% if registry.get('GV_sphinx') %}
|
||||
{% trans 'Trier par ' %}
|
||||
<select name="sort">
|
||||
<option value="relevance">{% trans 'pertinence'%}</option>
|
||||
<option value="created_on">{% trans 'date dajout'%}</option>
|
||||
<option value="random">{% trans 'aleatoire'%}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{% trans 'phraseanet::time:: de' %}
|
||||
<input onchange="checkFilters(true);" class="datepicker" type="text" name="datemin">
|
||||
</td>
|
||||
<td>
|
||||
{% trans 'phraseanet::time:: a' %}
|
||||
<input onchange="checkFilters(true);" class="datepicker" type="text" name="datemax">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<select name="ord">
|
||||
<option value="desc">{% trans 'descendant'%}</option>
|
||||
<option value="asc">{% trans 'ascendant'%}</option>
|
||||
</select>
|
||||
<input type="checkbox" checked="checked" name="stemme" /> {% trans 'rechercher par stemme' %}
|
||||
{% else %}
|
||||
{% trans 'Trier par ' %}
|
||||
<select name="sort">
|
||||
<option value=""></option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] == 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="ord">
|
||||
<option value="desc">{% trans 'descendant'%}</option>
|
||||
<option value="asc">{% trans 'ascendant'%}</option>
|
||||
</select>
|
||||
<input type="hidden" name="ord" id="searchOrd" value="PHRASEA_ORDER_DESC" />
|
||||
{% endif %}
|
||||
<div class="field_filter">
|
||||
<div>
|
||||
{% trans 'Les termes apparaissent dans le(s) champs' %}
|
||||
</div>
|
||||
<select size="8" multiple onchange="checkFilters(true);" name="fields[]" style="vertical-align:middle;width:100%;">
|
||||
<option value="phraseanet--all--fields">{% trans 'rechercher dans tous les champs' %}</option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] != 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% set status_length = search_status|length %}
|
||||
{% if status_length > 0 %}
|
||||
|
||||
<div style="margin:5px 0;">
|
||||
<hr/>
|
||||
</div>
|
||||
<div class="status_filter">
|
||||
|
||||
<div>
|
||||
{% trans 'Status des documents a rechercher' %}
|
||||
</div>
|
||||
<table>
|
||||
{% for n, stat in search_status %}
|
||||
{% for s in stat %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if s['imgoff'] %}
|
||||
<img src="{{s['imgoff']}}" title="{{s['labeloff']}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{s['sbas']|implode('field_')}}"
|
||||
type="checkbox" value="{{s['sbas']|implode(' field_')}}"
|
||||
n="{{n}}" name="status[{{n}}][off][]"/><label>{{s['labeloff']}}</label>
|
||||
</td>
|
||||
<td>
|
||||
{% if s['imgoff'] %}
|
||||
<img src="{{s['imgon']}}" title="{{s['labelon']}}" />
|
||||
{% endif %}
|
||||
<input onchange="checkFilters(true);" class="field_switch field_{{s['sbas']|implode('field_')}}"
|
||||
type="checkbox" value="{{s['sbas']|implode(' field_')}}"
|
||||
n="{{n}}" name="status[{{n}}][on][]"/><label>{{s['labelon']}}</label>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set dates_length = search_datas['dates']|length %}
|
||||
{% if dates_length > 0 %}
|
||||
<div style="margin:5px 0;">
|
||||
<hr/>
|
||||
</div>
|
||||
<div class="date_filter">
|
||||
<div>{% trans 'Rechercher dans un champ date' %}</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<select name="datefield">
|
||||
{% for field_id, field in search_datas['dates'] %}
|
||||
<option onchange="checkFilters(true);"
|
||||
class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endfor %}
|
||||
<option value="{{search_datas['dates']|array_keys|implode('|')}}" selected="selected">
|
||||
{% trans 'rechercher dans tous les champs' %}
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{% trans 'phraseanet::time:: de' %}
|
||||
<input onchange="checkFilters(true);" class="datepicker" type="text" name="datemin">
|
||||
</td>
|
||||
<td>
|
||||
{% trans 'phraseanet::time:: a' %}
|
||||
<input onchange="checkFilters(true);" class="datepicker" type="text" name="datemax">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@@ -55,6 +55,8 @@ var p4 = p4 || {};
|
||||
$dialog,
|
||||
$this = this;
|
||||
|
||||
this.closing = false;
|
||||
|
||||
this.options = $.extend(defaults, options);
|
||||
|
||||
this.level = getLevel(level);
|
||||
@@ -101,7 +103,17 @@ var p4 = p4 || {};
|
||||
{
|
||||
$this.options.closeCallback($this.$dialog);
|
||||
}
|
||||
$this.Close();
|
||||
|
||||
if($this.closing === false)
|
||||
{
|
||||
console.log('not already closing');
|
||||
$this.closing = true;
|
||||
$this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('already closing');
|
||||
}
|
||||
};
|
||||
|
||||
this.$dialog.dialog('destroy').attr('title', this.options.title)
|
||||
@@ -141,7 +153,9 @@ var p4 = p4 || {};
|
||||
|
||||
phraseaDialog.prototype = {
|
||||
Close : function() {
|
||||
console.log('dialog close inside bef');
|
||||
p4.Dialog.Close(this.level);
|
||||
console.log('dialog close inside aft');
|
||||
},
|
||||
setContent : function (content) {
|
||||
this.$dialog.removeClass('loading').empty().append(content);
|
||||
@@ -194,7 +208,8 @@ var p4 = p4 || {};
|
||||
|
||||
$(window).unbind('resize.DIALOG' + getLevel(level));
|
||||
|
||||
this.get(level).getDomElement().dialog('destroy').remove();
|
||||
this.get(level).closing = true;
|
||||
this.get(level).getDomElement().dialog('close').dialog('destroy').remove();
|
||||
|
||||
var id = this.get(level).getId();
|
||||
|
||||
|
@@ -178,6 +178,7 @@ function checkFilters(save)
|
||||
{
|
||||
var danger = false;
|
||||
var search = {};
|
||||
var adv_box = $('form.phrasea_query .adv_options');
|
||||
search.bases = {};
|
||||
search.fields = {};
|
||||
search.dates = {};
|
||||
@@ -189,10 +190,12 @@ function checkFilters(save)
|
||||
switches.filter('option').hide().filter('option[selected]').removeAttr('selected').addClass('was');
|
||||
switches.filter(':checkbox').parent().hide().find(':checkbox[checked]').removeAttr('checked').addClass('was');
|
||||
|
||||
$('form[name="phrasea_query"] .field_filter,form[name="phrasea_query"] .status_filter,form[name="phrasea_query"] .date_filter').removeClass('danger');
|
||||
|
||||
$.each($('form[name="phrasea_query"] .sbascont'),
|
||||
function(){
|
||||
$('.field_filter, .status_filter, .date_filter', adv_box).removeClass('danger');
|
||||
|
||||
var adv_box = $('form.phrasea_query .adv_options');
|
||||
console.log('loopin on , ', $('.sbascont', adv_box));
|
||||
$.each($('.sbascont', adv_box), function(){
|
||||
|
||||
var id = $(this).parent().find('input[name=reference]').val();
|
||||
search.bases[id] = [];
|
||||
@@ -205,6 +208,7 @@ function checkFilters(save)
|
||||
}
|
||||
|
||||
var cbck = chuckbass.filter(':checked');
|
||||
console.log(cbck.length);
|
||||
if(cbck.length>0)
|
||||
{
|
||||
var zfield = $('#sbasfiltercont .field_'+id).show();
|
||||
@@ -230,7 +234,7 @@ function checkFilters(save)
|
||||
if(!reset_field && search.fields.length>0)
|
||||
{
|
||||
danger = true;
|
||||
$('form[name="phrasea_query"] .field_filter').addClass('danger');
|
||||
$('.field_filter', adv_box).addClass('danger');
|
||||
}
|
||||
|
||||
$('.status_filter :checkbox[checked]').each(function(){
|
||||
@@ -238,17 +242,17 @@ function checkFilters(save)
|
||||
var n = $(this).attr('n');
|
||||
search.status[n] = $(this).val().split('_');
|
||||
danger = true;
|
||||
$('form[name="phrasea_query"] .status_filter') .addClass('danger');
|
||||
$('.status_filter', adv_box) .addClass('danger');
|
||||
});
|
||||
|
||||
search.dates.minbound = $('.date_filter input[name=datemin]').val();
|
||||
search.dates.maxbound = $('.date_filter input[name=datemax]').val();
|
||||
search.dates.field = $('.date_filter select[name=datefield]').val();
|
||||
search.dates.minbound = $('.date_filter input[name=datemin]', adv_box).val();
|
||||
search.dates.maxbound = $('.date_filter input[name=datemax]', adv_box).val();
|
||||
search.dates.field = $('.date_filter select[name=datefield]', adv_box).val();
|
||||
|
||||
if($.trim(search.dates.minbound) || $.trim(search.dates.maxbound))
|
||||
{
|
||||
danger = true;
|
||||
$('form[name="phrasea_query"] .date_filter').addClass('danger');
|
||||
$(' .date_filter', adv_box).addClass('danger');
|
||||
}
|
||||
|
||||
$('.field_filter select').scrollTop(scroll);
|
||||
@@ -389,35 +393,6 @@ function newSearch()
|
||||
|
||||
function newAdvSearch()
|
||||
{
|
||||
var cont = $('form[name="phrasea_query"]');
|
||||
var val_all = $.trim($('input[name=query_all]',cont).val()).split(' ').join(' AND ');
|
||||
var val_or = $.trim($('input[name=query_or]',cont).val()).split(' ').join(' OR ');
|
||||
var val_exact = $.trim($('input[name=query_exact]',cont).val());
|
||||
var val_none = $.trim($('input[name=query_none]',cont).val()).split(' ').join(' EXCEPT ');
|
||||
|
||||
var val = val_all != '' ? '('+val_all+')' : '';
|
||||
|
||||
if(val_or!='')
|
||||
val = val + (val != '' ? ' AND ' : '') + '('+val_or+')';
|
||||
if(val_exact!='')
|
||||
val = val + (val != '' ? ' AND ' : '') + '"'+val_exact+'"';
|
||||
if(val_none!='')
|
||||
val = val + (val != '' ? ' ' : 'all ') +'EXCEPT '+ val_none;
|
||||
|
||||
|
||||
val = $.trim(val);
|
||||
if(val == '')
|
||||
{
|
||||
var current = $('#EDIT_query').val();
|
||||
if($.trim(current) == '')
|
||||
{
|
||||
val = 'all';
|
||||
}
|
||||
else
|
||||
val = current;
|
||||
}
|
||||
$('#EDIT_query').val(val);
|
||||
|
||||
newSearch();
|
||||
}
|
||||
|
||||
@@ -498,8 +473,8 @@ function afterSearch()
|
||||
}
|
||||
|
||||
function initAnswerForm(){
|
||||
$('form[name="phrasea_query"] button').button();
|
||||
$('#searchForm').bind('submit',function(){
|
||||
$('form.phrasea_query button').button();
|
||||
$('#searchForm').unbind('submit').bind('submit',function(){
|
||||
answAjax = $.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/answer.php",
|
||||
@@ -848,7 +823,8 @@ $(document).ready(function(){
|
||||
|
||||
var options = {
|
||||
closeCallback: function(dialog){
|
||||
$('form[name=phrasea_query]').html(dialog.html());
|
||||
dialog.find('form.phrasea_query button').button('destroy');
|
||||
$('form[name=phrasea_query]').html(dialog.find('form.phrasea_query').html());
|
||||
$('form[name=phrasea_query]').find('.adv_options').hide();
|
||||
$('form[name=phrasea_query]').find('.adv_trigger').show();
|
||||
initAnswerForm();
|
||||
@@ -857,12 +833,22 @@ $(document).ready(function(){
|
||||
|
||||
$dialog = p4.Dialog.Create(options);
|
||||
|
||||
$('form[name=phrasea_query] button').button('destroy');
|
||||
var html = $('<form class="phrasea_query"></form>').append($('form[name=phrasea_query]').html());
|
||||
$('form[name=phrasea_query]').empty();
|
||||
|
||||
$dialog.setContent(html);
|
||||
$dialog.getDomElement().find('.adv_options').show();
|
||||
$dialog.getDomElement().find('.adv_trigger').hide();
|
||||
$dialog.getDomElement().find('button').button();
|
||||
$dialog.getDomElement().find('form').bind('submit', function(){
|
||||
console.log('before dialog close');
|
||||
$dialog.Close();
|
||||
console.log('after dialog close');
|
||||
newSearch();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
Reference in New Issue
Block a user