Skip to content
Snippets Groups Projects
Commit a42aff8d authored by Chris Hallberg's avatar Chris Hallberg
Browse files

EDS advanced search fix and standardization with default advanced search.

parent 939e81d8
No related merge requests found
......@@ -11,7 +11,7 @@ function addSearch(group, term, field)
// Build the new search
var inputIndex = $('#group'+group+' input').length;
var inputID = group+'_'+$('#group'+group+' input').length;
var newSearch = '<div class="search" id="search'+inputID+'"><div class="form-group row"><div class="col-md-7"><input id="search_lookfor'+inputID+'" class="form-control" type="text" name="lookfor'+group+'[]" value="'+term+'"/></div>'
var newSearch = '<div class="search" id="search'+inputID+'"><div class="row"><div class="col-md-7"><input id="search_lookfor'+inputID+'" class="form-control" type="text" name="lookfor'+group+'[]" value="'+term+'"/></div>'
+ '<div class="col-md-4"><select id="search_type'+inputID+'" name="type'+group+'[]" class="form-control">';
for (var key in searchFields) {
newSearch += '<option value="' + key + '"';
......@@ -53,7 +53,7 @@ function addGroup(firstTerm, firstField, join)
if (join == undefined) {join = '';}
var newGroup = '<div id="group'+nextGroup+'" class="group well clearfix">'
+ '<div class="col-md-9"><div class="row"><div class="col-md-3"><label>'+searchLabel+':</label></div>'
+ '<div class="col-md-9"><div class="row"><div class="col-md-3"><label class="help-block">'+searchLabel+':</label></div>'
+ '<div class="col-md-9"><i id="group'+nextGroup+'Holder" class="fa fa-plus-circle"></i> <a href="#" onClick="addSearch('+nextGroup+')">'+addSearchString+'</a></div></div></div>'
+ '<div class="col-md-3">'
+ '<label for="search_bool'+nextGroup+'">'+searchMatch+':&nbsp;</label>'
......
......@@ -14,12 +14,12 @@ function addSearch(group, term, field, op)
// Build the new search
var inputIndex = $('#group'+group+' input').length;
var inputID = group+'_'+$('#group'+group+' input').length;
var newSearch ='<div class="search" id="search'+inputID+'"><div class="col-sm-3">';
var newSearch ='<div class="search row" id="search'+inputID+'"><div class="col-sm-3">';
if (typeof groupSearches[group] == "undefined") {
groupSearches[group] = 0;
newSearch += '<input type="hidden" name="op' + group + '[]" value="AND"/><label for="search_lookfor' + group + '_' + groupSearches[group] + '"><span class="help-block">' + searchLabel + ':</span></label>';
newSearch += '<input type="hidden" name="op' + group + '[]" value="AND" class="form-control"/><label for="search_lookfor' + group + '_' + groupSearches[group] + '" class="help-block">' + searchLabel + ':</label>';
} else {
newSearch += '<select id="search_op' + group + '_' + groupSearches[group] + '" name="op' + group + '[]" class="span9">';
newSearch += '<select id="search_op' + group + '_' + groupSearches[group] + '" name="op' + group + '[]" class="col-sm-9 form-control">';
for(var i=0, len= booleanSearchOperators.length; i < len; i++) {
var searchOp = booleanSearchOperators[i];
var sel = '';
......@@ -30,9 +30,9 @@ function addSearch(group, term, field, op)
}
newSearch += '</select>';
}
newSearch += '</div><div class="col-sm-9"><input class="col-sm-7" id="search_lookfor'+inputID+'" type="text" name="lookfor'+group+'[]" value="'+term+'">'
+ '<span class="help-inline">'+searchFieldLabel+'</span> '
+ '<select class="col-sm-4" id="search_type'+inputID+'" name="type'+group+'[]">';
newSearch += '</div><div class="col-sm-9"><div class="col-sm-6"><input class="form-control"" id="search_lookfor'+inputID+'" type="text" name="lookfor'+group+'[]" value="'+term+'"></div>'
+ '<span class="col-sm-1 help-block">'+searchFieldLabel+'</span> '
+ '<div class="col-sm-4"><select class="form-control" id="search_type'+inputID+'" name="type'+group+'[]">';
for (var key in searchFields) {
newSearch += '<option value="' + key + '"';
if (key == field) {
......@@ -40,7 +40,7 @@ function addSearch(group, term, field, op)
}
newSearch += ">" + searchFields[key] + "</option>";
}
newSearch += '</select> <a href="#" onClick="deleteSearch('+group+','+inputIndex+')" class="help-block delete">&times;</a></div>';
newSearch += '</select></div> <a href="#" onClick="deleteSearch('+group+','+inputIndex+')" class="col-sm-1 help-block delete">&times;</a></div>';
// Insert it
$("#group" + group + "Holder").before(newSearch);
......@@ -76,8 +76,7 @@ function addGroup(firstTerm, firstField, join)
var newGroup = '<div id="group'+nextGroup+'" class="group well clearfix">'
+ '<input type="hidden" name="bool'+nextGroup+'[]" value="AND"/>'
+ '<div class="span11"><div id="group'+nextGroup+'Holder" class="span9 offset3"><i class="icon-plus-sign"></i> <a href="#" onClick="addSearch('+nextGroup+')">'+addSearchString+'</a></div></div>'
+ '<div class="span1"><a href="#" onClick="deleteGroup('+nextGroup+')" class="close hide" title="'+deleteSearchGroupString+'">&times;</a></div></div>';
+ '<div id="group'+nextGroup+'Holder"><i class="col-sm-offset-3 fa fa-plus-circle"></i> <a href="#" onClick="addSearch('+nextGroup+')">'+addSearchString+'</a></div>';
$('#groupPlaceHolder').before(newGroup);
addSearch(nextGroup, firstTerm, firstField);
......
<? if (!empty($this->expanderList)): ?>
<fieldset class="col-sm-4">
<legend><?=$this->transEsc('eds_modes_and_expanders')?></legend>
<? foreach ($this->expanderList as $field => $expander):
$value = $expander['Value'] ?>
<label class="checkbox" for="expand_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>">
<input id="expand_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>" type="checkbox" <?=(isset($expander['selected']) && $expander['selected'])?'checked="checked"':''?> name="filter[]" value="EXPAND:<?=$this->escapeHtmlAttr($value)?>">
<?=$this->transEsc('eds_expander_' . $value, array(), $expander['Label'])?>
</label>
<? endforeach; ?>
<label class="displayBlock" for="searchModes"><?=$this->transEsc('Search Mode')?></label>
<select id="searchMode_<?=$this->escapeHtmlAttr($field)?>" name="filter[]">
<? foreach ($this->searchModes as $field => $searchMode):
$value = $searchMode['Value'] ?>
<option <?=(isset($searchMode['selected']) && $searchMode['selected'])?'selected="selected"':''?> value="SEARCHMODE:<?=$this->escapeHtmlAttr($value)?>">
<?= /* 'Label' comes from API and is always in English; try to translate structured value before using it: */ $this->transEsc('eds_mode_' . $value, array(), $searchMode['Label']) ?>
</option>
<div class="row">
<? if (!empty($this->expanderList)): ?>
<fieldset class="col-sm-4">
<legend><?=$this->transEsc('eds_modes_and_expanders')?></legend>
<? foreach ($this->expanderList as $field => $expander):
$value = $expander['Value'] ?>
<label class="checkbox" for="expand_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>">
<input id="expand_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>" type="checkbox" <?=(isset($expander['selected']) && $expander['selected'])?'checked="checked"':''?> name="filter[]" value="EXPAND:<?=$this->escapeHtmlAttr($value)?>">
<?=$this->transEsc('eds_expander_' . $value, array(), $expander['Label'])?>
</label>
<? endforeach; ?>
</select>
</fieldset>
<? endif; ?>
<? if (!empty($this->limiterList)): ?>
<fieldset class="col-sm-4">
<legend><?=$this->transEsc('Limit To')?></legend>
<? foreach ($this->limiterList as $field => $facet): ?>
<? switch($facet['Type']){
case 'multiselectvalue': ?>
<label for="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>"><?=$this->transEsc($facet['Label'])?></label>
<select id="limit_<?=$this->escapeHtmlAttr($field)?>" name="filter[]" multiple="multiple" size="10">
<? foreach ($facet['LimiterValues'] as $id => $facetValue): ?>
<? $value = $facetValue['Value']; ?>
<option value="<?='LIMIT|'.$this->escapeHtmlAttr($field . ':' . $facetValue['Value'])?>"<?=(isset($facetValue['selected']) && $facetValue['selected'])?' selected="selected"':''?>><?=$this->escapeHtml($facetValue['Value'])?></option>
<? endforeach; ?>
</select>
<!-- <br/> -->
<? break;
case 'select':
$value = $facet['LimiterValues'][0]['Value'] ?>
<label class="checkbox" for="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>">
<input id="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>" type="checkbox" <?=(isset($facet['LimiterValues'][0]['selected']) && $facet['LimiterValues'][0]['selected'])?'checked="checked"':''?> name="filter[]" value="<?=$this->escapeHtmlAttr('LIMIT|'.$field . ':' . $value)?>">
<?=$this->transEsc('eds_limiter_' . $field, array(), $facet['Label'])?>
</label>
<? break;
case 'text': ?>
<!-- not implemented -->
<? break;
case 'numeric':?>
<!-- not implemented -->
<? break;
case 'numericrange':?>
<!-- not implemented -->
<? break;
case 'ymrange': ?>
<!-- not implemented -->
<? break;
case 'yrange': ?>
<!-- not implemented -->
<? break;
case 'historicalrange':?>
<!-- not implemented -->
<? break;
case 'singleselectvalue':?>
<!-- not implemented -->
<? break;
}; ?>
<? endforeach; ?>
</fieldset>
<? endif; ?>
\ No newline at end of file
<label class="displayBlock" for="searchModes"><?=$this->transEsc('Search Mode')?></label>
<select id="searchMode_<?=$this->escapeHtmlAttr($field)?>" name="filter[]">
<? foreach ($this->searchModes as $field => $searchMode):
$value = $searchMode['Value'] ?>
<option <?=(isset($searchMode['selected']) && $searchMode['selected'])?'selected="selected"':''?> value="SEARCHMODE:<?=$this->escapeHtmlAttr($value)?>">
<?= /* 'Label' comes from API and is always in English; try to translate structured value before using it: */ $this->transEsc('eds_mode_' . $value, array(), $searchMode['Label']) ?>
</option>
<? endforeach; ?>
</select>
</fieldset>
<? endif; ?>
<? if (!empty($this->limiterList)): ?>
<fieldset class="col-sm-4">
<legend><?=$this->transEsc('Limit To')?></legend>
<? foreach ($this->limiterList as $field => $facet): ?>
<? switch($facet['Type']){
case 'multiselectvalue': ?>
<label for="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>"><?=$this->transEsc($facet['Label'])?></label><br/>
<select id="limit_<?=$this->escapeHtmlAttr($field)?>" name="filter[]" multiple="multiple" size="10">
<? foreach ($facet['LimiterValues'] as $id => $facetValue): ?>
<? $value = $facetValue['Value']; ?>
<option value="<?='LIMIT|'.$this->escapeHtmlAttr($field . ':' . $facetValue['Value'])?>"<?=(isset($facetValue['selected']) && $facetValue['selected'])?' selected="selected"':''?>><?=$this->escapeHtml($facetValue['Value'])?></option>
<? endforeach; ?>
</select>
<!-- <br/> -->
<? break;
case 'select':
$value = $facet['LimiterValues'][0]['Value'] ?>
<label class="checkbox" for="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>">
<input id="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '+', $field))?>" type="checkbox" <?=(isset($facet['LimiterValues'][0]['selected']) && $facet['LimiterValues'][0]['selected'])?'checked="checked"':''?> name="filter[]" value="<?=$this->escapeHtmlAttr('LIMIT|'.$field . ':' . $value)?>">
<?=$this->transEsc('eds_limiter_' . $field, array(), $facet['Label'])?>
</label>
<? break;
case 'text': ?>
<!-- not implemented -->
<? break;
case 'numeric':?>
<!-- not implemented -->
<? break;
case 'numericrange':?>
<!-- not implemented -->
<? break;
case 'ymrange': ?>
<!-- not implemented -->
<? break;
case 'yrange': ?>
<!-- not implemented -->
<? break;
case 'historicalrange':?>
<!-- not implemented -->
<? break;
case 'singleselectvalue':?>
<!-- not implemented -->
<? break;
}; ?>
<? endforeach; ?>
</fieldset>
<? endif; ?>
</div>
\ No newline at end of file
......@@ -54,7 +54,9 @@
</select>
</div>
</div>
<i id="groupPlaceHolder" class="fa fa-plus-circle"></i> <a href="#" onClick="addGroup()"><?= $this->transEsc('add_search_group') ?></a>
<span id="groupPlaceHolder">
<i class="fa fa-plus-circle"></i> <a href="#" onClick="addGroup()"><?= $this->transEsc('add_search_group') ?></a>
</span>
<input class="btn btn-primary pull-right" type="submit" value="<?= $this->transEsc('Find')?>">
<? if (isset($this->extraAdvancedControls)): ?>
<?=$this->extraAdvancedControls ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment