From b0db61541123d3dfae6a87d7e8757767dcdfe931 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 17 Mar 2014 23:03:24 +0000 Subject: [PATCH] - 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 --- .../class.etemplate_widget_taglist.inc.php | 9 ++++-- etemplate/js/et2_widget_taglist.js | 28 +++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_taglist.inc.php b/etemplate/inc/class.etemplate_widget_taglist.inc.php index cc7f125f4e..0312ac9474 100644 --- a/etemplate/inc/class.etemplate_widget_taglist.inc.php +++ b/etemplate/inc/class.etemplate_widget_taglist.inc.php @@ -43,10 +43,15 @@ class etemplate_widget_taglist extends etemplate_widget $type = $_REQUEST['type']; $query = $_REQUEST['query']; $options = array(); + $links = array(); if ($type == "account") { - $options['account_type'] = $_REQUEST['account_type']; - $links = accounts::link_query($query, $options); + // Only search if a query was provided - don't search for all accounts + if($query) + { + $options['account_type'] = $_REQUEST['account_type']; + $links = accounts::link_query($query, $options); + } } else { diff --git a/etemplate/js/et2_widget_taglist.js b/etemplate/js/et2_widget_taglist.js index 8c615abcfc..deb20d7868 100644 --- a/etemplate/js/et2_widget_taglist.js +++ b/etemplate/js/et2_widget_taglist.js @@ -254,11 +254,14 @@ var et2_taglist = et2_selectbox.extend( { 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! - if(this.taglist == null || !source) return; - this.taglist.setData(source); + // do NOT set an empty autocomplete_url, magicsuggest would use page url instead! + if(this.taglist == null || !source) return; + this.taglist.setData(source); + } }, /** @@ -303,14 +306,14 @@ var et2_taglist = et2_selectbox.extend( { // 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] = { id: v, label: v }; } - else + else(this.options.select_options) { if (typeof values[i].id == 'undefined') { @@ -362,6 +365,9 @@ var et2_taglist_account = et2_taglist.extend( init:function () { this._super.apply(this, arguments); + + // Counter to prevent infinite looping while fetching account names + this.deferred_loading = 0; this.options.autocomplete_params.type = "account"; }, @@ -410,15 +416,21 @@ var et2_taglist_account = et2_taglist.extend( 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.deferred_loading--; if (label) this.set_value(values); }, 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"]);