- Fix taglist account infinite loop when looking for accounts (using link title system instead of data source)

- Don't search server side if there's no query string
This commit is contained in:
Nathan Gray 2014-03-17 23:03:24 +00:00
parent f337d45b29
commit b0db615411
2 changed files with 27 additions and 10 deletions

View File

@ -43,10 +43,15 @@ class etemplate_widget_taglist extends etemplate_widget
$type = $_REQUEST['type']; $type = $_REQUEST['type'];
$query = $_REQUEST['query']; $query = $_REQUEST['query'];
$options = array(); $options = array();
$links = array();
if ($type == "account") if ($type == "account")
{ {
$options['account_type'] = $_REQUEST['account_type']; // Only search if a query was provided - don't search for all accounts
$links = accounts::link_query($query, $options); if($query)
{
$options['account_type'] = $_REQUEST['account_type'];
$links = accounts::link_query($query, $options);
}
} }
else else
{ {

View File

@ -254,11 +254,14 @@ var et2_taglist = et2_selectbox.extend(
{ {
source = this.egw().ajaxUrl(source); source = this.egw().ajaxUrl(source);
} }
this.options.autocomplete_url = source; if(this.options.autocomplete_url != source)
{
this.options.autocomplete_url = source;
// do NOT set an empty autocomplete_url, magicsuggest would use page url instead! // do NOT set an empty autocomplete_url, magicsuggest would use page url instead!
if(this.taglist == null || !source) return; if(this.taglist == null || !source) return;
this.taglist.setData(source); this.taglist.setData(source);
}
}, },
/** /**
@ -303,14 +306,14 @@ var et2_taglist = et2_selectbox.extend(
{ {
// alread in correct format // alread in correct format
} }
else if (typeof this.options.select_options[v] == 'undefined') else if (this.options.select_options && typeof this.options.select_options[v] == 'undefined')
{ {
values[i] = { values[i] = {
id: v, id: v,
label: v label: v
}; };
} }
else else(this.options.select_options)
{ {
if (typeof values[i].id == 'undefined') if (typeof values[i].id == 'undefined')
{ {
@ -363,6 +366,9 @@ var et2_taglist_account = et2_taglist.extend(
{ {
this._super.apply(this, arguments); this._super.apply(this, arguments);
// Counter to prevent infinite looping while fetching account names
this.deferred_loading = 0;
this.options.autocomplete_params.type = "account"; this.options.autocomplete_params.type = "account";
}, },
@ -410,15 +416,21 @@ var et2_taglist_account = et2_taglist.extend(
label: label label: label
}; };
} }
else // call set_value again, after result has arrived from server else if (!this.deferred_loading) // call set_value again, after result has arrived from server
{ {
this.deferred_loading++;
this.egw().link_title('home-accounts', v, function(label) { this.egw().link_title('home-accounts', v, function(label) {
this.deferred_loading--;
if (label) this.set_value(values); if (label) this.set_value(values);
}, this); }, this);
} }
} }
} }
this._super.call(this, values); // Don't proceed if waiting for labels
if(this.deferred_loading <=0)
{
this._super.call(this, values);
}
} }
}); });
et2_register_widget(et2_taglist_account, ["taglist-account"]); et2_register_widget(et2_taglist_account, ["taglist-account"]);