search widget : numeric widget between operator

SVN:b1162[5481]
This commit is contained in:
Bruno Da Silva
2018-03-20 16:10:53 +00:00
parent fd8c7c99bd
commit d1ef987dca
5 changed files with 111 additions and 39 deletions

View File

@@ -1002,6 +1002,12 @@ input.dp-applied {
.search_form_handler .sf_criterion_area .search_form_criteria.search_form_criteria_enum .sfc_fg_operator_in > label .sfc_op_content {
width: 100%;
}
.search_form_handler .sf_criterion_area .search_form_criteria.search_form_criteria_numeric .sfc_fg_operator_dropdown_group select {
width: 88px;
}
.search_form_handler .sf_criterion_area .search_form_criteria.search_form_criteria_numeric .sfc_fg_operator_between input {
width: 88px;
}
.search_form_handler .sf_criterion_area .sf_more_criterion.opened {
z-index: 2;
/* To be over criterion */

View File

@@ -1154,6 +1154,18 @@ input.dp-applied {
}
}
}
&.search_form_criteria_numeric {
.sfc_fg_operator_dropdown_group {
select {
width: 88px;
}
}
.sfc_fg_operator_between {
input {
width: 88px;
}
}
}
}
/* More criterion */

View File

@@ -1401,7 +1401,7 @@ When associated with a trigger, each action is given an "order" number, specifyi
'UI:Search:Criteria:Operator:Numeric:GreaterThanOrEquals' => '>=',
'UI:Search:Criteria:Operator:Numeric:LessThan' => '<',
'UI:Search:Criteria:Operator:Numeric:LessThanOrEquals' => '<=',
'UI:Search:Criteria:Operator:Numeric:DifferentThan' => 'Different than:',
'UI:Search:Criteria:Operator:Numeric:DifferentThan' => 'Not',
'UI:Search:Criteria:Operator:Numeric:Between' => 'Between:',
// - Criteria titles

View File

@@ -511,7 +511,10 @@ $(function()
// Events
// - Focus input on click (radio, label, ...)
oOpElem.on('click', ':not(input[type="text"])', function(){
oOpElem.on('click', ':not(input[type="text"], select)', function(oEvent) {
if ($(oEvent.target).is('input[type="text"], select')) {
return;
}
oOpContentElem.focus();
});
// - Apply on "enter" key hit
@@ -579,7 +582,7 @@ $(function()
// Values helpers
// - Convert values to a standard string
_getValuesAsText: function()
_getValues: function()
{
var aValues = [];
for(var iValueIdx in this.options.values)
@@ -587,7 +590,14 @@ $(function()
aValues.push(this.options.values[iValueIdx].label);
}
return aValues.join(', ');
return aValues;
},
// - Convert values to a standard string
_getValuesAsText: function()
{
return this._getValues().join(', ');
},
// - Make an OQL expression from the criteria values and operator
_makeOQLExpression: function()

View File

@@ -95,39 +95,82 @@ $(function()
},
// // Prepare operator's DOM element
// _prepareBetweenOperator: function(oOpElem, sOpIdx, oOp)
// {
// var me = this;
//
// // DOM element
// var oOpContentElem = $('<input type="text" />');
// oOpContentElem.val(this._getValuesAsText());
//
// // Events
// // - Focus input on click (radio, label, ...)
// oOpElem.on('click', ':not(input[type="text"])', function(){
// oOpContentElem.focus();
// });
// // - Apply on "enter" key hit
// oOpContentElem.on('keyup', function(oEvent){
// // Check operator's radio if not already (typically when focusing in input via "tab" key)
// if(oOpElem.find('.sfc_op_radio').prop('checked') === false)
// {
// oOpElem.find('.sfc_op_radio').prop('checked', true)
// }
//
// me._markAsDraft();
//
// // Apply if enter key
// if(oEvent.key === 'Enter')
// {
// me._apply();
// }
// });
//
// oOpElem.find('.sfc_op_content').append(oOpContentElem);
// },
// Prepare operator's DOM element
_prepareBetweenOperator: function(oOpElem, sOpIdx, oOp)
{
var me = this;
aValues = me._getValues();
// DOM elements
var oOpContentElemFrom = $('<input type="text" name="from" />').uniqueId();
if (0 in aValues)
{
oOpContentElemFrom.val(aValues[0]);
}
var oOpContentElemUntil = $('<input type="text" name="until" />').uniqueId();
if (1 in aValues)
{
oOpContentElemUntil.val(aValues[1]);
}
oOpContentElemFrom.data('focusNext', '#'+oOpContentElemUntil.attr('id'));
// oOpContentElemUntil.data('focusNext', '#'+oOpContentElemFrom.attr('id'));
oOpContentElem = $().add(oOpContentElemFrom).add(oOpContentElemUntil);
// Events
// - Focus input on click (radio, label, ...)
oOpElem.on('click', function(oEvent){
if ($(oEvent.target).is('input[type="text"], select')) {
return;
}
oOpContentElemFrom.focus();
});
// - Apply on "enter" key hit
oOpContentElem.on('keyup', function(oEvent){
// Check operator's radio if not already (typically when focusing in input via "tab" key)
if(oOpElem.find('.sfc_op_radio').prop('checked') === false)
{
oOpElem.find('.sfc_op_radio').prop('checked', true)
}
me._markAsDraft();
// Apply if enter key
if(oEvent.key === 'Enter')
{
if (focusNext = $(this).data('focusNext'))
{
$(focusNext).focus();
}
else
{
me._apply();
}
}
});
oOpElem.find('.sfc_op_content').append(oOpContentElem);
},
_getBetweenOperatorValues: function(oOpElem)
{
var aValues = [];
var sValueFrom = oOpElem.find('.sfc_op_content input[name="from"]').val();
var sValueUntil = oOpElem.find('.sfc_op_content input[name="until"]').val();
aValues.push({value: sValueFrom, label: sValueFrom});
aValues.push({value: sValueUntil, label: sValueUntil});
return aValues;
},
//------------------
// Inherited methods
@@ -155,7 +198,7 @@ $(function()
oDropdown.on('change', function(){
$option = $(this);
me.element.find('.sfc_op_radio').val($option.val());
me.element.find('.sfc_fg_operator_dropdown_group .sfc_op_radio').val($option.val());
oOptionOp = $option.data('oOp');
$option.attr('data-operator-code', oOptionOp.code);
@@ -174,7 +217,7 @@ $(function()
.find('.sfc_op_radio')
.val(sOpIdx)
.end()
.on('click', function(){
.on('click', function(oEvent){
var bIsChecked = oOpElemDropdown.find('.sfc_op_radio').prop('checked');
if(bIsChecked === false)
@@ -182,6 +225,7 @@ $(function()
oOpElemDropdown.find('.sfc_op_radio').prop('checked', true);
me._markAsDraft();
}
oOpElemDropdown.find('input[type="text"]:first').focus();
})
.appendTo(this.element.find('.sfc_fg_operators'))
;