Advanced search: WIP POC, integration with endpoint.

SVN:b1162[5423]
This commit is contained in:
Guillaume Lajarige
2018-03-14 11:03:32 +00:00
parent 9499799f80
commit 6a6c069896
3 changed files with 50 additions and 10 deletions

View File

@@ -849,10 +849,10 @@ div.HRDrawer {
margin: 0px;
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;
}
.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;
}
.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 {

View File

@@ -937,6 +937,7 @@ div.HRDrawer {
}
/* Common operators for most criteria types processing*/
&.sfc_fg_operator_equals,
&.sfc_fg_operator_contains,
&.sfc_fg_operator_starts_with,
&.sfc_fg_operator_ends_with{

View File

@@ -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()
{
this.element.remove();
@@ -166,8 +195,7 @@ $(function()
// - Internal events
_onButtonApply: function()
{
this._trace('TODO: Apply button (call selected operator callback)');
this.handler.triggerHandler('itop.search.criteria.value_changed');
this._apply();
},
_onButtonCancel: function()
{
@@ -318,7 +346,7 @@ $(function()
// - Return a HTML template for operators
_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
@@ -328,17 +356,15 @@ $(function()
// Set radio
oOpElem.find('.sfc_op_radio').val(sOpIdx);
oOpElem.find('.sfc_op_radio').attr('id', sInputId);
// Set label
oOpElem.find('.sfc_op_name').text(oOp.label);
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
oOpElem.addClass('sfc_fg_operator_' + oOp.code);
oOpElem.addClass('sfc_fg_operator_' + oOp.code)
.attr('data-operator-code', oOp.code);
// Bind events
// - Check radio button on click
@@ -369,6 +395,19 @@ $(function()
{
// 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
// - Convert values to a standard string