mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
Advanced search: WIP POC, integration with endpoint.
SVN:b1162[5423]
This commit is contained in:
@@ -849,10 +849,10 @@ div.HRDrawer {
|
|||||||
margin: 0px;
|
margin: 0px;
|
||||||
margin-right: 7px;
|
margin-right: 7px;
|
||||||
}
|
}
|
||||||
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_contains .sfc_op_name, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_starts_with .sfc_op_name, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_ends_with .sfc_op_name {
|
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_equals .sfc_op_name, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_contains .sfc_op_name, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_starts_with .sfc_op_name, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_ends_with .sfc_op_name {
|
||||||
width: 90px;
|
width: 90px;
|
||||||
}
|
}
|
||||||
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_contains .sfc_op_content input, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_starts_with .sfc_op_content input, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_ends_with .sfc_op_content input {
|
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_equals .sfc_op_content input, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_contains .sfc_op_content input, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_starts_with .sfc_op_content input, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_operators .sfc_fg_operator.sfc_fg_operator_ends_with .sfc_op_content input {
|
||||||
width: 130px;
|
width: 130px;
|
||||||
}
|
}
|
||||||
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_apply, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_cancel {
|
.search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_apply, .search_form_handler .sf_criterion_area .search_form_criteria .sfc_form_group.opened .sfc_fg_cancel {
|
||||||
|
|||||||
@@ -937,6 +937,7 @@ div.HRDrawer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Common operators for most criteria types processing*/
|
/* Common operators for most criteria types processing*/
|
||||||
|
&.sfc_fg_operator_equals,
|
||||||
&.sfc_fg_operator_contains,
|
&.sfc_fg_operator_contains,
|
||||||
&.sfc_fg_operator_starts_with,
|
&.sfc_fg_operator_starts_with,
|
||||||
&.sfc_fg_operator_ends_with{
|
&.sfc_fg_operator_ends_with{
|
||||||
|
|||||||
@@ -155,6 +155,35 @@ $(function()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
_apply: function()
|
||||||
|
{
|
||||||
|
this._trace('TODO: Apply button (call selected operator callback)');
|
||||||
|
// Find active operator
|
||||||
|
var oActiveOpElem = this.element.find('.sfc_op_radio:checked').closest('.sfc_fg_operator');
|
||||||
|
if(oActiveOpElem.length === 0)
|
||||||
|
{
|
||||||
|
this._trace('Could not apply new value as there seems to be no active operator.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value from operator (polymorphic method)
|
||||||
|
var sCallback = '_get' + this._toCamelCase(oActiveOpElem.attr('data-operator-code')) + 'OperatorValues';
|
||||||
|
if(this[sCallback] === undefined)
|
||||||
|
{
|
||||||
|
this._trace('Callback ' + sCallback + ' is undefined, using _getOperatorValues instead.');
|
||||||
|
sCallback = '_getOperatorValues';
|
||||||
|
}
|
||||||
|
var aValues = this[sCallback](oActiveOpElem);
|
||||||
|
|
||||||
|
// Update widget
|
||||||
|
this.options.operator = oActiveOpElem.find('.sfc_op_radio').val();
|
||||||
|
this.options.values = aValues;
|
||||||
|
// TODO: Update title
|
||||||
|
this._setTitle();
|
||||||
|
|
||||||
|
// Trigger event to handler
|
||||||
|
this.handler.triggerHandler('itop.search.criteria.value_changed');
|
||||||
|
},
|
||||||
_remove: function()
|
_remove: function()
|
||||||
{
|
{
|
||||||
this.element.remove();
|
this.element.remove();
|
||||||
@@ -166,8 +195,7 @@ $(function()
|
|||||||
// - Internal events
|
// - Internal events
|
||||||
_onButtonApply: function()
|
_onButtonApply: function()
|
||||||
{
|
{
|
||||||
this._trace('TODO: Apply button (call selected operator callback)');
|
this._apply();
|
||||||
this.handler.triggerHandler('itop.search.criteria.value_changed');
|
|
||||||
},
|
},
|
||||||
_onButtonCancel: function()
|
_onButtonCancel: function()
|
||||||
{
|
{
|
||||||
@@ -318,7 +346,7 @@ $(function()
|
|||||||
// - Return a HTML template for operators
|
// - Return a HTML template for operators
|
||||||
_getOperatorTemplate: function()
|
_getOperatorTemplate: function()
|
||||||
{
|
{
|
||||||
return '<div class="sfc_fg_operator"><label><input type="radio" class="sfc_op_radio" name="operator" value="" /><span class="sfc_op_name"></span><span class="sfc_op_content"></span></label></div>';
|
return '<div class="sfc_fg_operator"><label><input type="radio" class="sfc_op_radio" name="operator" /><span class="sfc_op_name"></span><span class="sfc_op_content"></span></label></div>';
|
||||||
},
|
},
|
||||||
|
|
||||||
// Operators helpers
|
// Operators helpers
|
||||||
@@ -328,17 +356,15 @@ $(function()
|
|||||||
|
|
||||||
// Set radio
|
// Set radio
|
||||||
oOpElem.find('.sfc_op_radio').val(sOpIdx);
|
oOpElem.find('.sfc_op_radio').val(sOpIdx);
|
||||||
|
oOpElem.find('.sfc_op_radio').attr('id', sInputId);
|
||||||
|
|
||||||
// Set label
|
// Set label
|
||||||
oOpElem.find('.sfc_op_name').text(oOp.label);
|
oOpElem.find('.sfc_op_name').text(oOp.label);
|
||||||
oOpElem.find('> label').attr('for', sInputId);
|
oOpElem.find('> label').attr('for', sInputId);
|
||||||
|
|
||||||
// Set value
|
|
||||||
oOpElem.find('.sfc_op_radio').val(oOpElem.id);
|
|
||||||
oOpElem.find('.sfc_op_radio').attr('id', sInputId);
|
|
||||||
|
|
||||||
// Set helper classes
|
// Set helper classes
|
||||||
oOpElem.addClass('sfc_fg_operator_' + oOp.code);
|
oOpElem.addClass('sfc_fg_operator_' + oOp.code)
|
||||||
|
.attr('data-operator-code', oOp.code);
|
||||||
|
|
||||||
// Bind events
|
// Bind events
|
||||||
// - Check radio button on click
|
// - Check radio button on click
|
||||||
@@ -369,6 +395,19 @@ $(function()
|
|||||||
{
|
{
|
||||||
// Do nothing as only the label is necessary
|
// Do nothing as only the label is necessary
|
||||||
},
|
},
|
||||||
|
// - Fallback for operators without a specific callback
|
||||||
|
_getOperatorValues: function(oOpElem)
|
||||||
|
{
|
||||||
|
var aValues = [];
|
||||||
|
|
||||||
|
oOpElem.find('.sfc_op_content input').each(function(){
|
||||||
|
var sValue = $(this).val();
|
||||||
|
aValues.push({value: sValue, label: sValue});
|
||||||
|
});
|
||||||
|
|
||||||
|
return aValues;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// Values helpers
|
// Values helpers
|
||||||
// - Convert values to a standard string
|
// - Convert values to a standard string
|
||||||
|
|||||||
Reference in New Issue
Block a user