mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-05 13:39:23 +01:00
Fix multiple request problem
- actually pass delay to autocomplete, it works better that way - track previous request, and abort it if another one needs to be started
This commit is contained in:
parent
e7fd500006
commit
24fd900626
@ -72,9 +72,6 @@ var et2_link_to = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
search_timeout: 200, //ms after change to send query
|
|
||||||
minimum_characters: 2, // Don't send query unless there's at least this many chars
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -538,7 +535,7 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
legacyOptions: ["only_app", "application_list"],
|
legacyOptions: ["only_app", "application_list"],
|
||||||
search_timeout: 200, //ms after change to send query
|
search_timeout: 500, //ms after change to send query
|
||||||
minimum_characters: 2, // Don't send query unless there's at least this many chars
|
minimum_characters: 2, // Don't send query unless there's at least this many chars
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -561,6 +558,7 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
this.options.value = {};
|
this.options.value = {};
|
||||||
}
|
}
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
|
this.request = null;
|
||||||
|
|
||||||
this.createInputWidget();
|
this.createInputWidget();
|
||||||
},
|
},
|
||||||
@ -575,6 +573,7 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
this.search = null;
|
this.search = null;
|
||||||
this.app_select = null;
|
this.app_select = null;
|
||||||
|
this.request = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
createInputWidget: function() {
|
createInputWidget: function() {
|
||||||
@ -622,7 +621,9 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
|
|
||||||
// Autocomplete
|
// Autocomplete
|
||||||
this.search.autocomplete({
|
this.search.autocomplete({
|
||||||
source: function(request, response) { return self.query(request, response);},
|
source: function(request, response) {
|
||||||
|
return self.query(request, response);
|
||||||
|
},
|
||||||
select: function(event, item) {
|
select: function(event, item) {
|
||||||
event.data = self;
|
event.data = self;
|
||||||
// Correct changed value from server
|
// Correct changed value from server
|
||||||
@ -636,6 +637,7 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
minLength: self.minimum_characters,
|
minLength: self.minimum_characters,
|
||||||
|
delay: self.search_timeout,
|
||||||
disabled: self.options.disabled,
|
disabled: self.options.disabled,
|
||||||
appendTo: self.div
|
appendTo: self.div
|
||||||
});
|
});
|
||||||
@ -868,6 +870,13 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
* Ask server for entries matching selected app/type and filtered by search string
|
* Ask server for entries matching selected app/type and filtered by search string
|
||||||
*/
|
*/
|
||||||
query: function(request, response) {
|
query: function(request, response) {
|
||||||
|
// If there is a pending request, abort it
|
||||||
|
if(this.request)
|
||||||
|
{
|
||||||
|
this.request.abort();
|
||||||
|
this.request = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Remember last search
|
// Remember last search
|
||||||
this.last_search = this.search.val();
|
this.last_search = this.search.val();
|
||||||
|
|
||||||
@ -881,17 +890,18 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
return response(this.cache[request.term]);
|
return response(this.cache[request.term]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remember callback
|
||||||
|
this.response = response;
|
||||||
|
|
||||||
this.search.addClass("loading");
|
this.search.addClass("loading");
|
||||||
// Remove specific display and revert to CSS file
|
// Remove specific display and revert to CSS file
|
||||||
// show() would use inline, should be inline-block
|
// show() would use inline, should be inline-block
|
||||||
this.clear.css('display','');
|
this.clear.css('display','');
|
||||||
var request = egw.json(this.egw().getAppName() + ".etemplate_widget_link.ajax_link_search.etemplate",
|
this.request = egw.json(this.egw().getAppName() + ".etemplate_widget_link.ajax_link_search.etemplate",
|
||||||
[this.app_select.val(), '', request.term, request.options],
|
[this.app_select.val(), '', request.term, request.options],
|
||||||
this._results,
|
this._results,
|
||||||
this,true,this
|
this,true,this
|
||||||
);
|
).sendRequest();
|
||||||
this.response = response;
|
|
||||||
request.sendRequest();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -932,6 +942,10 @@ var et2_link_entry = et2_inputWidget.extend(
|
|||||||
* Server found some results
|
* Server found some results
|
||||||
*/
|
*/
|
||||||
_results: function(data) {
|
_results: function(data) {
|
||||||
|
if(this.request)
|
||||||
|
{
|
||||||
|
this.request = null;
|
||||||
|
}
|
||||||
this.search.removeClass("loading");
|
this.search.removeClass("loading");
|
||||||
var result = [];
|
var result = [];
|
||||||
for(var id in data) {
|
for(var id in data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user