diff --git a/css/light-grey.css b/css/light-grey.css index 5404a4ed6..db5c95928 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -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 */ diff --git a/css/light-grey.scss b/css/light-grey.scss index ea48cd67f..e16c189b4 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -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 */ diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index 955cb8e89..534f5e6aa 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -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 diff --git a/js/search/search_form_criteria.js b/js/search/search_form_criteria.js index ca22d3ac9..697d90913 100644 --- a/js/search/search_form_criteria.js +++ b/js/search/search_form_criteria.js @@ -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() diff --git a/js/search/search_form_criteria_numeric.js b/js/search/search_form_criteria_numeric.js index 8b4802581..c310c29df 100644 --- a/js/search/search_form_criteria_numeric.js +++ b/js/search/search_form_criteria_numeric.js @@ -95,39 +95,82 @@ $(function() }, - // // Prepare operator's DOM element - // _prepareBetweenOperator: function(oOpElem, sOpIdx, oOp) - // { - // var me = this; - // - // // DOM element - // var oOpContentElem = $(''); - // 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 = $('').uniqueId(); + if (0 in aValues) + { + oOpContentElemFrom.val(aValues[0]); + } + + var oOpContentElemUntil = $('').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')) ;