mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Fixed a problem with the autocomplete agent cache
This commit is contained in:
parent
3320bf1fb2
commit
1de746ab69
@ -484,6 +484,7 @@ $params['input_name'] = 'agent_alias_for_data';
|
|||||||
$params['value'] = '';
|
$params['value'] = '';
|
||||||
$params['javascript_function_action_after_select'] = 'toggleAddGroupBtn';
|
$params['javascript_function_action_after_select'] = 'toggleAddGroupBtn';
|
||||||
$params['selectbox_group'] = 'layer_group_id'; // Filter by group
|
$params['selectbox_group'] = 'layer_group_id'; // Filter by group
|
||||||
|
$params['disabled_javascript_on_blur_function'] = true;
|
||||||
$agent_for_group_input = ui_print_agent_autocomplete_input($params);
|
$agent_for_group_input = ui_print_agent_autocomplete_input($params);
|
||||||
$add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true);
|
$add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true);
|
||||||
|
|
||||||
@ -1066,7 +1067,7 @@ function onFormSubmit (event) {
|
|||||||
|
|
||||||
function onLayerGroupIdChange (event) {
|
function onLayerGroupIdChange (event) {
|
||||||
// Clear agent inputs
|
// Clear agent inputs
|
||||||
$("input#hidden-agent_id_for_data").val("");
|
$("input#hidden-agent_id_for_data").val(0);
|
||||||
$("input#text-agent_alias_for_data").val("");
|
$("input#text-agent_alias_for_data").val("");
|
||||||
toggleAddGroupBtn();
|
toggleAddGroupBtn();
|
||||||
}
|
}
|
||||||
|
@ -3316,6 +3316,13 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
minLength: 2,
|
minLength: 2,
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
var term = request.term; //Word to search
|
var term = request.term; //Word to search
|
||||||
|
' . $javascript_change_ajax_params_text . '
|
||||||
|
var groupId = data_params.id_group();
|
||||||
|
|
||||||
|
// Index cache by group Id
|
||||||
|
if (cache_' . $input_name . '[groupId] == null) {
|
||||||
|
cache_' . $input_name . '[groupId] = {};
|
||||||
|
}
|
||||||
|
|
||||||
//Set loading
|
//Set loading
|
||||||
$("#' . $input_id . '")
|
$("#' . $input_id . '")
|
||||||
@ -3329,8 +3336,8 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
//==== CACHE CODE ==================================
|
//==== CACHE CODE ==================================
|
||||||
//Check the cache
|
//Check the cache
|
||||||
var found = false;
|
var found = false;
|
||||||
if (term in cache_' . $input_name . ') {
|
if (term in cache_' . $input_name . '[groupId]) {
|
||||||
response(cache_' . $input_name . '[term]);
|
response(cache_' . $input_name . '[groupId][term]);
|
||||||
|
|
||||||
//Set icon
|
//Set icon
|
||||||
$("#' . $input_id . '")
|
$("#' . $input_id . '")
|
||||||
@ -3345,11 +3352,11 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
for (i = 1; i < term.length; i++) {
|
for (i = 1; i < term.length; i++) {
|
||||||
var term_match = term.substr(0, term.length - i);
|
var term_match = term.substr(0, term.length - i);
|
||||||
|
|
||||||
$.each(cache_' . $input_name . ', function (oldterm, olddata) {
|
$.each(cache_' . $input_name . '[groupId], function (oldterm, olddata) {
|
||||||
var pattern = new RegExp("^" + term_match + ".*","gi");
|
var pattern = new RegExp("^" + term_match + ".*","gi");
|
||||||
|
|
||||||
if (oldterm.match(pattern)) {
|
if (oldterm.match(pattern)) {
|
||||||
response(cache_' . $input_name . '[oldterm]);
|
response(cache_' . $input_name . '[groupId][oldterm]);
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
@ -3376,15 +3383,13 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
' . $javascript_change_ajax_params_text . '
|
|
||||||
|
|
||||||
jQuery.ajax ({
|
jQuery.ajax ({
|
||||||
data: data_params,
|
data: data_params,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: action="' . $javascript_ajax_page . '",
|
url: action="' . $javascript_ajax_page . '",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
cache_' . $input_name . '[term] = data; //Save the cache
|
cache_' . $input_name . '[groupId][term] = data; //Save the cache
|
||||||
|
|
||||||
response(data);
|
response(data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user