N°1556 - Search: Fix removing last criterion on a 'or' line resulted in 'OR 1'.

The empty OR condition is now removed completely from the screen and the criterion list.

SVN:trunk[5951]
This commit is contained in:
Eric Espié
2018-07-18 14:08:56 +00:00
parent df20f1b5ab
commit 60b980fbff

View File

@@ -238,15 +238,30 @@ $(function()
this.elements.criterion_area.find('.sf_criterion_row').each(function(iIdx){
var oCriterionRowElem = $(this);
oCriterion['or'][iIdx] = {'and': []};
oCriterionRowElem.find('.search_form_criteria').each(function(){
var oCriteriaData = $(this).triggerHandler('itop.search.criteria.get_data');
if (null != oCriteriaData)
if (oCriterionRowElem.find('.search_form_criteria').length == 0 && iIdx > 0)
{
$(this).remove();
}
else
{
oCriterionRowElem.find('.search_form_criteria').each(function ()
{
oCriterion['or'][iIdx]['and'].push(oCriteriaData);
}
});
var oCriteriaData = $(this).triggerHandler('itop.search.criteria.get_data');
if (null != oCriteriaData)
{
if (!oCriterion['or'][iIdx])
{
oCriterion['or'][iIdx] = {'and': []};
}
oCriterion['or'][iIdx]['and'].push(oCriteriaData);
}
else
{
$(this).remove();
}
});
}
});
// - Update search
this.options.search.criterion = oCriterion;