mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Advanced search: UI/UX, form submit throttling.
SVN:b1162[5581]
This commit is contained in:
@@ -167,18 +167,20 @@ $(function()
|
||||
|
||||
oOpElem.find('.sfc_op_content').append(oOpContentElem);
|
||||
|
||||
this._prepareInOperatorWithoutAutocomplete(oOpElem, sOpIdx, oOp);
|
||||
this._prepareInOperatorWithAutocomplete(oOpElem, sOpIdx, oOp);
|
||||
if(this._hasAutocompleteAllowedValues())
|
||||
{
|
||||
this._prepareInOperatorWithAutocomplete(oOpElem, sOpIdx, oOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._prepareInOperatorWithoutAutocomplete(oOpElem, sOpIdx, oOp);
|
||||
}
|
||||
|
||||
},
|
||||
_prepareInOperatorWithoutAutocomplete: function(oOpElem, sOpIdx, oOp)
|
||||
{
|
||||
var me = this;
|
||||
|
||||
if(this._hasAutocompleteAllowedValues())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oOpContentElem = oOpElem.find('.sfc_opc_multichoices');
|
||||
var oDynamicListElem = oOpElem.find('.sfc_opc_mc_items_dynamic');
|
||||
var oFilterElem = oOpElem.find('.sf_filter');
|
||||
@@ -208,7 +210,6 @@ $(function()
|
||||
// Note: "keyup" event is use instead of "keydown", otherwise, the input value would not be set yet.
|
||||
oFilterElem.find('input').on('keyup focus', function(oEvent){
|
||||
// TODO: Move on values with up and down arrow keys; select with space or enter.
|
||||
|
||||
var sQuery = $(this).val();
|
||||
|
||||
if(sQuery === '')
|
||||
@@ -245,11 +246,6 @@ $(function()
|
||||
{
|
||||
var me = this;
|
||||
|
||||
if(!this._hasAutocompleteAllowedValues())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oOpContentElem = oOpElem.find('.sfc_opc_multichoices');
|
||||
var oDynamicListElem = oOpElem.find('.sfc_opc_mc_items_dynamic');
|
||||
var oFilterElem = oOpElem.find('.sf_filter');
|
||||
@@ -267,12 +263,11 @@ $(function()
|
||||
.appendTo(oOpContentElem);
|
||||
|
||||
// Events
|
||||
// Autocomplete
|
||||
// - Autocomplete
|
||||
var oACXHR = null;
|
||||
var oACTimeout = null;
|
||||
oFilterElem.find('input').on('keyup focus', function(oEvent){
|
||||
// TODO: Move on values with up and down arrow keys; select with space or enter.
|
||||
|
||||
var sQuery = $(this).val();
|
||||
|
||||
if(sQuery === '')
|
||||
@@ -313,7 +308,7 @@ $(function()
|
||||
}
|
||||
});
|
||||
//
|
||||
// // Open search dialog
|
||||
// // - Open search dialog
|
||||
// oFilterElem.find('.sff_search_dialog').on('click', function(){
|
||||
// // TODO: Open search dialog with right params
|
||||
// alert('Not implemented yet');
|
||||
|
||||
@@ -9,8 +9,6 @@ $(function()
|
||||
// default options
|
||||
options:
|
||||
{
|
||||
'endpoint': AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'),
|
||||
|
||||
// Null value
|
||||
'null_value': {
|
||||
'code': 0,
|
||||
|
||||
@@ -84,6 +84,11 @@ $(function()
|
||||
results_area: null,
|
||||
},
|
||||
|
||||
submit: {
|
||||
xhr: null,
|
||||
//timeout: null,
|
||||
},
|
||||
|
||||
// the constructor
|
||||
_create: function()
|
||||
{
|
||||
@@ -861,12 +866,16 @@ $(function()
|
||||
// TODO: Make a throttle mecanism or cancel previous call when a newer is made.
|
||||
|
||||
// Do submit
|
||||
$.post(
|
||||
if(this.submit.xhr !== null)
|
||||
{
|
||||
this.submit.xhr.abort();
|
||||
}
|
||||
this.submit.xhr = $.post(
|
||||
this.options.endpoint,
|
||||
oData
|
||||
)
|
||||
.done(function(oResponse, sStatus, oXHR){ me._onSubmitSuccess(oResponse); })
|
||||
.fail(function(oResponse, sStatus, oXHR){ me._onSubmitFailure(oResponse); })
|
||||
.fail(function(oResponse, sStatus, oXHR){ me._onSubmitFailure(oResponse, sStatus); })
|
||||
.always(function(oResponse, sStatus, oXHR){ me._onSubmitAlways(oResponse); });
|
||||
},
|
||||
// - Called on form submit successes
|
||||
@@ -875,8 +884,13 @@ $(function()
|
||||
this.elements.results_area.html(oData);
|
||||
},
|
||||
// - Called on form submit failures
|
||||
_onSubmitFailure: function(oData)
|
||||
_onSubmitFailure: function(oData, sStatus)
|
||||
{
|
||||
if(sStatus === 'abort')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fallback message in case the server send back only HTML markup.
|
||||
var oErrorElem = $(oData.responseText);
|
||||
var sErrorMessage = (oErrorElem.text() !== '') ? oErrorElem.text() : Dict.Format('Error:XHR:Fail', '');
|
||||
|
||||
Reference in New Issue
Block a user