From 1af6f3a707c9df21a0573874dbdd09eecd1df49b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 16 Apr 2015 14:52:13 +0000 Subject: [PATCH] Modifications to cached options - country list no longer supports options when caching - copy options to avoid modification with additonal options --- etemplate/js/et2_extension_nextmatch.js | 6 +++++- etemplate/js/et2_widget_selectbox.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index ea6e8fdd77..46670cfc43 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -2832,9 +2832,13 @@ var et2_nextmatch_customfields = et2_customfields_list.extend(et2_INextmatchHead if(field.type == 'select') { + if(field.values && typeof field.values[''] !== 'undefined') + { + delete(field.values['']); + } widget = et2_createWidget("nextmatch-filterheader", { id: cf_id, - label: field.label, + empty_label: field.label, select_options: field.values }, this); } diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 7e017e3a1c..fcadbbda37 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -785,7 +785,12 @@ jQuery.extend(et2_selectbox, { var old_type = widget._type; widget._type = type; - type_options = this[type_function].call(this, widget, attrs); + if(typeof attrs.other == 'string') + { + attrs.other = attrs.other.split(','); + } + // Copy, to avoid accidental modification + jQuery.extend(true, type_options, this[type_function].call(this, widget, attrs)); widget._type = old_type; } @@ -1040,7 +1045,7 @@ jQuery.extend(et2_selectbox, return this.cached_server_side_options(widget, options, attrs); }, country_options: function(widget, attrs) { - var options = ','+(attrs.other||[]).join(','); + var options = ','; return this.cached_server_side_options(widget, options, attrs); }, dow_options: function(widget,attrs) { @@ -1068,6 +1073,9 @@ jQuery.extend(et2_selectbox, */ cached_server_side_options: function(widget, options_string, attrs) { + // normalize options by removing trailing commas + options_string = options_string.replace(/,+$/, ''); + var cache_id = widget._type+'_'+options_string; var cache = egw.window.et2_selectbox.type_cache[cache_id]; if (typeof cache == 'undefined')