diff --git a/etemplate/js/et2_widget_selectAccount.js b/etemplate/js/et2_widget_selectAccount.js index 404035737d..5092b2c8e2 100644 --- a/etemplate/js/et2_widget_selectAccount.js +++ b/etemplate/js/et2_widget_selectAccount.js @@ -26,6 +26,17 @@ */ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM], { + attributes: { + "empty_label": { + "name": "Empty label", + "type": "string", + "default": "", + "description": "Textual label for first row, eg: 'All' or 'None'. ID will be ''" + }, + }, + + legacyOptions: ["empty_label"], + init: function(_parent, options) { /** Resolve some circular dependency problems here @@ -39,6 +50,15 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM], { this._super.apply(this, arguments); + // Legacy options could have row count or empty label in first slot + if(typeof this.options.empty_label == "string") + { + if(isNaN(this.options.empty_label)) + { + this.options.empty_label = this.egw().lang(this.options.empty_label); + } + } + this.options.application = 'home-accounts'; // Don't make it look like a link though @@ -50,6 +70,27 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM], { // Don't make it look like a link though jQuery('li',this.list).removeClass("et2_link et2_link_string"); + + // Empty label from selectbox + if(this.options.empty_label) + { + if(!_value) + { + this.list.append("
  • "+this.options.empty_label+"
  • "); + } + else + { + // An array with 0 / empty in it? + for(var i = 0; i < _value.length; i++) + { + if(!_value[i] || !parseInt(_value[i])) + { + this.list.append("
  • "+this.options.empty_label+"
  • "); + return; + } + } + } + } } }); et2_register_widget(et2_selectAccount_ro, ["select-account_ro"]);