mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
search widget : widget datetime and numeric => fine tuning the UI
SVN:b1162[5546]
This commit is contained in:
@@ -69,7 +69,7 @@ $(function()
|
||||
|
||||
for (var i = 0; i < aInputsParamLength; i++) {
|
||||
var oInputParam = aInputsParam[i];
|
||||
var oOpContentElem = $('<span class="sfc_op_content_'+oInputParam.code+'_outer '+(oInputParam.show_on_advanced ? 'hide_on_less' : 'hide_on_advanced')+'"><label class="sfc_op_content_'+oInputParam.code+'_label" for=""> '+Dict.S('UI:Search:Criteria:DateTime:'+oInputParam.code_uc_first)+'</label><input type="text" name="'+oInputParam.code+'" placeholder="'+Dict.S('UI:Search:Criteria:DateTime:Placeholder'+oInputParam.code_uc_first)+'"/></span>');
|
||||
var oOpContentElem = $('<span class="sfc_op_content_'+oInputParam.code+'_outer '+(oInputParam.show_on_advanced ? 'hide_on_less' : 'hide_on_advanced')+'"><label class="sfc_op_content_'+oInputParam.code+'_label" for=""> '+Dict.S('UI:Search:Criteria:DateTime:'+oInputParam.code_uc_first)+' </label><input type="text" name="'+oInputParam.code+'" placeholder="'+Dict.S('UI:Search:Criteria:DateTime:Placeholder'+oInputParam.code_uc_first)+'"/></span>');
|
||||
var oInputElem = oOpContentElem
|
||||
.find('input')
|
||||
.uniqueId()
|
||||
@@ -119,11 +119,55 @@ $(function()
|
||||
|
||||
|
||||
// once the inputs are appended into the DOM we can safely use jQuery UI
|
||||
var fHandleSynchCallback = function(select, bSetDate) {
|
||||
var selectElem = $(select);
|
||||
var sSyncedWith = selectElem.data('synced_with');
|
||||
var oInputParam = selectElem.data('oInputParam');
|
||||
|
||||
if (bSetDate)
|
||||
{
|
||||
var sDate = selectElem.val().trim();
|
||||
if ('' == sDate)
|
||||
{
|
||||
selectElem[oInputParam.x_picker]('setDate', null);
|
||||
} else
|
||||
{
|
||||
selectElem[oInputParam.x_picker]('setDate', sDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (sSyncedWith != undefined)
|
||||
{
|
||||
var sCode = selectElem.data('code');
|
||||
var oInputParam = aInputsParam[oInputsParamIndexByCode[sCode]];
|
||||
var oSyncedInputParam = aInputsParam[oInputsParamIndexByCode[sSyncedWith]];
|
||||
var oSyncedInputElem = oOpElem.find('input[name="'+sSyncedWith+'"]');
|
||||
|
||||
var dSyncedDate = selectElem[oInputParam.x_picker]('getDate');
|
||||
|
||||
if (null == dSyncedDate)
|
||||
{
|
||||
// oSyncedInputElem.val('');
|
||||
oSyncedInputElem[oSyncedInputParam.x_picker]('setDate', null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof oSyncedInputParam.default_time_add != 'undefined' && oSyncedInputParam.default_time_add)
|
||||
{
|
||||
dSyncedDate.setSeconds(dSyncedDate.getSeconds() + oSyncedInputParam.default_time_add);
|
||||
}
|
||||
oSyncedInputElem[oSyncedInputParam.x_picker]('setDate', dSyncedDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var odatetimepickerOptionsDefault = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
timeFormat: 'HH:mm:ss',
|
||||
buttonImage: GetAbsoluteUrlAppRoot()+"/images/calendar.png",
|
||||
buttonImageOnly: true,
|
||||
// buttonImageOnly: true,
|
||||
buttonText: "",
|
||||
showOn:'button',
|
||||
changeMonth:true,
|
||||
@@ -132,107 +176,13 @@ $(function()
|
||||
for (var i = 0; i < aInputsParamLength; i++) {
|
||||
var oInputParam = aInputsParam[i];
|
||||
|
||||
var fHandleSynchCallback = function(select, bSetDate) {
|
||||
var selectElem = $(select);
|
||||
var sSyncedWith = selectElem.data('synced_with');
|
||||
var oInputParam = selectElem.data('oInputParam');
|
||||
|
||||
if (bSetDate)
|
||||
{
|
||||
var sDate = selectElem.val().trim();
|
||||
if ('' == sDate)
|
||||
{
|
||||
selectElem[oInputParam.x_picker]('setDate', null);
|
||||
} else
|
||||
{
|
||||
selectElem[oInputParam.x_picker]('setDate', sDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (sSyncedWith != undefined)
|
||||
{
|
||||
var sCode = selectElem.data('code');
|
||||
var oInputParam = aInputsParam[oInputsParamIndexByCode[sCode]];
|
||||
var oSyncedInputParam = aInputsParam[oInputsParamIndexByCode[sSyncedWith]];
|
||||
var oSyncedInputElem = oOpElem.find('input[name="'+sSyncedWith+'"]');
|
||||
|
||||
var dSyncedDate = selectElem[oInputParam.x_picker]('getDate');
|
||||
|
||||
if (null == dSyncedDate)
|
||||
{
|
||||
// oSyncedInputElem.val('');
|
||||
oSyncedInputElem[oSyncedInputParam.x_picker]('setDate', null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof oSyncedInputParam.default_time_add != 'undefined' && oSyncedInputParam.default_time_add)
|
||||
{
|
||||
dSyncedDate.setSeconds(dSyncedDate.getSeconds() + oSyncedInputParam.default_time_add);
|
||||
}
|
||||
oSyncedInputElem[oSyncedInputParam.x_picker]('setDate', dSyncedDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//me._apply();
|
||||
selectElem[oInputParam.x_picker]('hide');
|
||||
};
|
||||
|
||||
var odatetimepickerOptions = $.extend({}, odatetimepickerOptionsDefault, {
|
||||
onSelect: function() {
|
||||
fHandleSynchCallback(this, false);
|
||||
$(this).focus();
|
||||
}
|
||||
// onClose: function(dateText, inst) {
|
||||
// var selectElem = $(this);
|
||||
// var sOnCLoseShow = selectElem.data('onclose_show');
|
||||
//
|
||||
// // if (typeof oInputParam.onclose_show != 'undefined')
|
||||
// // {
|
||||
// // oOpElem.find('input[name="'+oInputParam.onclose_show+'"]')
|
||||
// // [oInputParam.x_picker]('show')
|
||||
// // ;
|
||||
// // }
|
||||
//
|
||||
// // if (sOnCLoseShow != undefined && selectElem.is(':visible'))
|
||||
// // {
|
||||
// // var oOnCLoseShowInputElem = oOpElem.find('input[name="'+sOnCLoseShow+'"]');
|
||||
// // oOnCLoseShowInputElem[oInputParam.x_picker]('show');
|
||||
// // }
|
||||
//
|
||||
// },
|
||||
// onSelect: function(sDateText, oXPicker) {
|
||||
// var selectElem = $(this);
|
||||
// var sSyncedWith = selectElem.data('synced_with');
|
||||
//
|
||||
//
|
||||
// if (sSyncedWith != undefined)
|
||||
// {
|
||||
// var sCode = selectElem.data('code');
|
||||
// var oInputParam = aInputsParam[oInputsParamIndexByCode[sCode]];
|
||||
// var oSyncedInputParam = aInputsParam[oInputsParamIndexByCode[sSyncedWith]];
|
||||
// var oSyncedInputElem = oOpElem.find('input[name="'+sSyncedWith+'"]');
|
||||
//
|
||||
// var dSyncedDate = selectElem[oInputParam.x_picker]('getDate');
|
||||
//
|
||||
// if (null == dSyncedDate)
|
||||
// {
|
||||
// oSyncedInputElem.val('');
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (typeof oSyncedInputParam.default_time_add != 'undefined' && oSyncedInputParam.default_time_add)
|
||||
// {
|
||||
// dSyncedDate.setSeconds(dSyncedDate.getSeconds() + oSyncedInputParam.default_time_add);
|
||||
// }
|
||||
// oSyncedInputElem[oSyncedInputParam.x_picker]('setDate', dSyncedDate);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //me._apply();
|
||||
// selectElem[oInputParam.x_picker]('hide');
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,14 @@ $(function()
|
||||
options:
|
||||
{
|
||||
// Overload default operator
|
||||
'operator': '=',
|
||||
'operator': 'between',
|
||||
// Available operators
|
||||
'available_operators': {
|
||||
'between': {
|
||||
'label': Dict.S('UI:Search:Criteria:Operator:Numeric:Between'),
|
||||
'code': 'between',
|
||||
'rank': 0,
|
||||
},
|
||||
'=': {
|
||||
'label': Dict.S('UI:Search:Criteria:Operator:Numeric:Equals'),//pre-existing, label changed
|
||||
// 'dropdown_group':1,
|
||||
@@ -47,11 +52,7 @@ $(function()
|
||||
'rank': 500,
|
||||
// 'dropdown_group':1,
|
||||
},
|
||||
'between': {
|
||||
'label': Dict.S('UI:Search:Criteria:Operator:Numeric:Between'),
|
||||
'code': 'between',
|
||||
'rank': 600,
|
||||
},
|
||||
|
||||
'empty': {
|
||||
'rank': 700,//pre-existing, reordered
|
||||
},
|
||||
@@ -103,14 +104,14 @@ $(function()
|
||||
aValues = me._getValues();//TODO : tenir compte du refactoring de la structure
|
||||
|
||||
// DOM elements
|
||||
var oOpContentOuterElemFrom = $('<span class="sfc_op_content_from_outer"><label class="sfc_op_content_from_label" for=""> '+Dict.S('UI:Search:Criteria:Numeric:From')+'</label><input type="number" step="any" name="from" placeholder="'+Dict.S('UI:Search:Criteria:Numeric:PlaceholderFrom')+'"/></span>');
|
||||
var oOpContentOuterElemFrom = $('<div class="sfc_op_content_from_outer"><label class="sfc_op_content_from_label" for=""> '+Dict.S('UI:Search:Criteria:Numeric:From')+' </label><input type="text" name="from" placeholder="'+Dict.S('UI:Search:Criteria:Numeric:PlaceholderFrom')+'"/></div>');
|
||||
var oOpContentElemFrom = oOpContentOuterElemFrom.find('input').uniqueId();
|
||||
oOpContentOuterElemFrom.find('label').attr('for', oOpContentElemFrom.attr('id'));
|
||||
if (typeof aValues[0] != 'undefined' && typeof aValues[0].value != 'undefined')
|
||||
{
|
||||
oOpContentElemFrom.val(aValues[0].value);
|
||||
}
|
||||
var oOpContentOuterElemUntil = $('<span class="sfc_op_content_until_outer"><label class="sfc_op_content_until_label" for=""> '+Dict.S('UI:Search:Criteria:Numeric:Until')+'</label><input type="number" step="any" name="until" placeholder="'+Dict.S('UI:Search:Criteria:Numeric:PlaceholderUntil')+'"/></span>');
|
||||
var oOpContentOuterElemUntil = $('<div class="sfc_op_content_until_outer"><label class="sfc_op_content_until_label" for=""> '+Dict.S('UI:Search:Criteria:Numeric:Until')+' </label><input type="text" name="until" placeholder="'+Dict.S('UI:Search:Criteria:Numeric:PlaceholderUntil')+'"/></div>');
|
||||
var oOpContentElemUntil = oOpContentOuterElemUntil.find('input').uniqueId();
|
||||
oOpContentOuterElemUntil.find('label').attr('for', oOpContentElemUntil.attr('id'));
|
||||
if (typeof aValues[1] != 'undefined' && typeof aValues[1].value != 'undefined')
|
||||
@@ -212,13 +213,13 @@ $(function()
|
||||
case (typeof aValues[1].label == 'undefined' ):
|
||||
var sDictEntrySuffix = ':From';
|
||||
break;
|
||||
case (aValues[0].label == '' && aValues[1].label == ''):
|
||||
case ((typeof aValues[0].label == 'string' && aValues[0].label.trim() == '') && (typeof aValues[1].label == 'string' && aValues[1].label.trim() == '')):
|
||||
var sDictEntrySuffix = ':All';
|
||||
break;
|
||||
case (aValues[0].label == '' ):
|
||||
case (typeof aValues[0].label == 'string' && aValues[0].label.trim() == ''):
|
||||
var sDictEntrySuffix = ':Until';
|
||||
break;
|
||||
case (aValues[1].label == ''):
|
||||
case (typeof aValues[1].label == 'string' && aValues[1].label.trim() == ''):
|
||||
var sDictEntrySuffix = ':From';
|
||||
break;
|
||||
default:
|
||||
@@ -256,11 +257,11 @@ $(function()
|
||||
if (me.options.operator == 'between')
|
||||
{
|
||||
aRawValues = aRawValues.slice(); //clone
|
||||
if (typeof aRawValues[1] == 'undefined' || typeof aRawValues[1].label == 'undefined' || aRawValues[1].label == '')
|
||||
if (typeof aRawValues[1] == 'undefined' || typeof aRawValues[1].label == 'undefined' || (typeof aRawValues[1].label == 'string' && aRawValues[1].label.trim() == ''))
|
||||
{
|
||||
aRawValues.splice(1, 1);
|
||||
}
|
||||
if (typeof aRawValues[0] == 'undefined' || typeof aRawValues[0].label == 'undefined' || aRawValues[0].label == '')
|
||||
if (typeof aRawValues[0] == 'undefined' || typeof aRawValues[0].label == 'undefined' || (typeof aRawValues[0].label == 'string' && aRawValues[0].label.trim() == ''))
|
||||
{
|
||||
aRawValues.splice(0, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user