From aa07a243c1f789030885094f17a6447c087cc5a9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 8 Feb 2013 10:38:09 +0000 Subject: [PATCH] Fix widget not allowed / DOM error in nextmatch-accountfilter --- etemplate/js/et2_extension_nextmatch.js | 4 ++-- etemplate/js/et2_widget_link.js | 3 +-- etemplate/js/et2_widget_selectAccount.js | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 11e508f47d..ddc81bb1f9 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1386,7 +1386,7 @@ var et2_nextmatch_customfields = et2_customfields_list.extend(et2_INextmatchHead { widget = et2_createWidget("nextmatch-entryheader", { id: cf_id, - application: field.type, + only_app: field.type, blur: field.label }, this); } @@ -1660,7 +1660,7 @@ var et2_nextmatch_entryheader = et2_link_entry.extend(et2_INextmatchHeader, { if(typeof this.nextmatch.activeFilters.col_filter == 'undefined') this.nextmatch.activeFilters.col_filter = {}; if(selected && selected.item.value) { - if(event.data.options.application) + if(event.data.options.only_app) { // Only one application, just give the ID this.nextmatch.activeFilters["col_filter"][this.id] = selected.item.value; diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 3a4ea1998f..56309ddc0c 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -389,7 +389,6 @@ var et2_link_entry = et2_inputWidget.extend({ init: function() { this._super.apply(this, arguments); - this.div = null; this.search = null; this.app_select = null; this._oldValue = {id: null, app: this.options.only_app}; @@ -536,7 +535,7 @@ var et2_link_entry = et2_inputWidget.extend({ }, getDOMNode: function() { - return this.div[0]; + return this.div ? this.div[0] : null; }, transformAttributes: function(_attrs) { diff --git a/etemplate/js/et2_widget_selectAccount.js b/etemplate/js/et2_widget_selectAccount.js index 425f291c3a..bf18fe603d 100644 --- a/etemplate/js/et2_widget_selectAccount.js +++ b/etemplate/js/et2_widget_selectAccount.js @@ -63,9 +63,6 @@ var et2_selectAccount = et2_selectbox.extend({ this._super.apply(this, arguments); - // Allow search 'inside' this widget - this.supportedWidgetClasses = [et2_link_entry]; - // Holder for search jQuery nodes this.search = null; @@ -98,6 +95,9 @@ var et2_selectAccount = et2_selectbox.extend({ } else if (type == 'popup') { + // Allow search 'inside' this widget + this.supportedWidgetClasses = [et2_link_entry]; + this._create_search(); // Use empty label as blur if(this.options.empty_label) this.search_widget.set_blur(this.options.empty_label); @@ -112,11 +112,12 @@ var et2_selectAccount = et2_selectbox.extend({ } this.search_widget.search.change(this, function(event) { var value = event.data.search_widget.getValue(); - event.data.value = typeof value == 'object' ? value.id : value; + event.data.value = typeof value == 'object' && value ? value.id : value; event.data.input.trigger("change"); }); } - this.setDOMNode(this.search_widget.getDOMNode()); + var div = jQuery(document.createElement("div")).append(this.search_widget.getDOMNode()); + this.setDOMNode(div[0]); } }, @@ -145,12 +146,16 @@ var et2_selectAccount = et2_selectbox.extend({ } else if (type == 'popup') { + // Allow search 'inside' this widget + this.supportedWidgetClasses = [et2_link_entry]; + /** * Popup takes the dialog and embeds it in place of the selectbox */ var dialog = this._open_multi_search(); dialog.dialog("close"); - this.setDOMNode(this.dialog[0]); + var div = jQuery(document.createElement("div")).append(this.dialog); + this.setDOMNode(div[0]); var select_col = jQuery('#selection_col',dialog).children(); var selected = jQuery('#selected', select_col); @@ -290,7 +295,7 @@ var et2_selectAccount = et2_selectbox.extend({ var search = this.search = jQuery(document.createElement("div")); var search_widget = this.search_widget = et2_createWidget('link-entry', { - 'application': 'home-accounts', + 'only_app': 'home-accounts', 'query': function(request, response) { // Clear previous search results for multi-select if(!request.options)