From 59e76d78c520e4cbc4288f1d6609bbea50e49e05 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 21 Jul 2014 14:51:47 +0000 Subject: [PATCH] Fix extra options not used in read only select-account --- etemplate/js/et2_widget_selectAccount.js | 32 ++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_widget_selectAccount.js b/etemplate/js/et2_widget_selectAccount.js index a44e883b86..b4f2de90cd 100644 --- a/etemplate/js/et2_widget_selectAccount.js +++ b/etemplate/js/et2_widget_selectAccount.js @@ -855,17 +855,13 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM], // No clicks either .off(); - if(this.options.select_options && this.options.select_options[_value] || this.options.empty_label) + if(this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) || this.options.empty_label) { if(!_value) { // Empty label from selectbox this.list.append("
  • "+this.options.empty_label+"
  • "); } - else if (this.options.select_options[_value]) - { - this.list.append("
  • "+this.options.select_options[_value]+"
  • "); - } else if (typeof _value == 'object') { // An array with 0 / empty in it? @@ -882,6 +878,32 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM], } } } + else + { + // Options are not indexed, so we must look + var search = _value; + if (!jQuery.isArray(search)) + { + search = [_value]; + } + for(var j = 0; j < search.length; j++) + { + var found = false; + + // Not having a value to look up causes an infinite loop + if(!search[j]) continue; + + for(var i in this.options.select_options) + { + if(this.options.select_options[i].value == search[j]) + { + this.list.append("
  • "+this.options.select_options[i].label+"
  • "); + break; + } + } + + } + } } } });