')
.appendTo(oRecentsElem);
- // - Add fields from zlist list
+ // - Search zlist list
var oZlistElem = $('')
.addClass('sf_list')
.addClass('sf_list_zlist')
@@ -368,7 +358,7 @@ $(function()
.appendTo(oZListItemsElem);
}
- // - Add fields remaining
+ // - Remaining fields list
if(this.options.search.fields.others !== undefined)
{
var oOthersElem = $('')
@@ -396,10 +386,10 @@ $(function()
}
// - Buttons
- var oButtons = $('')
+ var oButtonsElem = $('')
.addClass('sfm_buttons')
- .append('')
- .append('')
+ .append('')
+ .append('')
.appendTo(oContentElem);
// Bind events
@@ -443,12 +433,15 @@ $(function()
}
}
});
+
+ // - More criteria toggling
this.elements.more_criterion.find('.sfm_header').on('click', function(oEvent){
// Prevent anchor
oEvent.preventDefault();
me._toggleMoreCriterion();
});
+
// - Filter
// Note: "keyup" event is use instead of "keydown", otherwise, the inpu value would not be set yet.
oFilterElem.find('input').on('keyup focus', function(oEvent){
@@ -501,7 +494,8 @@ $(function()
.val('')
.trigger('focus');
});
- // - Add criteria
+
+ // - Add one criteria
this.elements.more_criterion.find('.sfm_field').on('click', function(oEvent){
// Prevent anchor
oEvent.preventDefault();
@@ -517,11 +511,47 @@ $(function()
// Add criteria but don't submit form as the user has not specified the value yet.
me._addCriteria(oData);
});
+
+ // - Add several criterion
this.elements.more_criterion.find('.sfm_field input[type="checkbox"]').on('click', function(oEvent){
+ // Prevent propagation to field and instant add of the criteria
oEvent.stopPropagation();
- // TODO: Show add button
- console.log($(this).val(), $(this).prop('checked'));
+ if(me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').length === 0)
+ {
+ oButtonsElem.hide();
+ }
+ else
+ {
+ oButtonsElem.show();
+ }
+
+ // Put focus back to filter to improve UX.
+ oFilterElem.find('input').trigger('focus');
+ });
+ oButtonsElem.find('button').on('click', function(){
+ // Add criterion on apply
+ if($(this).attr('name') === 'apply')
+ {
+ me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').each(function(iIdx, oElem){
+ var oData = {
+ 'ref': $(oElem).closest('.sfm_field').attr('data-field-ref'),
+ 'init_opened': false,
+ };
+ me._addCriteria(oData);
+ });
+ }
+
+ // Clear all
+ // - Checkboxes
+ me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').prop('checked', false);
+ // - Filter
+ oFilterElem.find('input')
+ .val('')
+ .trigger('focus');
+
+ // Hide buttons
+ oButtonsElem.hide();
});
},
// - Prepare results area
@@ -557,6 +587,7 @@ $(function()
// TODO: Translate sentence.
oResultAreaElem.html('
Add some criterion on the search box or click the search button to view the objects.
');
oResultAreaElem.find('button').on('click', function(){
+ // TODO: Bug: Open "Search for CI", change child classe in the dropdown, click the search button. It submit the search for the original child classe, not the current one; whereas a click on the upper right pictogram does. This might be due to the form reloading.
me._onSubmitClick();
});
}
diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php
index 7a69715fe..b27daf8b3 100644
--- a/sources/application/search/searchform.class.inc.php
+++ b/sources/application/search/searchform.class.inc.php
@@ -117,7 +117,7 @@ class SearchForm
$sAction = (isset($aExtraParams['action'])) ? $aExtraParams['action'] : utils::GetAbsoluteUrlAppRoot().'pages/UI.php';
$sStyle = (isset($aExtraParams['open']) && ($aExtraParams['open'] == 'true')) ? 'opened' : '';
$sHtml .= "\n";