From 422c35ba929e616f82ee8738db6160cb52fbc8b0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 18 Oct 2011 19:15:32 +0000 Subject: [PATCH] Hide app selectbox if application is specified --- etemplate/js/et2_widget_link.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 4202c4c2e7..9f75fd6648 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -355,24 +355,32 @@ var et2_link_entry = et2_valueWidget.extend({ this.div = $j(document.createElement("div")).addClass("et2_link_entry"); // Application selection + this.app_select = $j(document.createElement("select")).appendTo(this.div) .change(function(e) { self.cache = {}; // Clear cache when app changes self.options.value.app = self.app_select.val(); }) .css("width","39%"); + var opt_count = 0; for(var key in this.options.select_options) { + opt_count++; var option = $j(document.createElement("option")) .attr("value", key) .text(this.options.select_options[key]); option.appendTo(this.app_select); } + this.app_select.val(this.options.application); + if(opt_count == 1) + { + this.app_select.hide(); + } self.options.value.app = this.app_select.val(); // Search input this.search = $j(document.createElement("input")).attr("type", "search") .css("width","50%") - .focus(function(){self.app_select.show();}) + .focus(function(){if(!self.options.application) {self.app_select.show();}}) .appendTo(this.div); this.set_blur(this.options.blur ? this.options.blur : egw.lang("search"), this.search); @@ -401,7 +409,19 @@ var et2_link_entry = et2_valueWidget.extend({ this._super.apply(this, arguments); - _attrs["select_options"] = egw.link_app_list('query'); + _attrs["select_options"] = {}; + if(_attrs["application"]) + { + var apps = et2_csvSplit(_attrs["application"], null, ","); + for(var i = 0; i < apps.length; i++) + { + _attrs["select_options"][apps[i]] = egw.lang(apps[i]); + } + } + else + { + _attrs["select_options"] = egw.link_app_list('query'); + } // Check whether the options entry was found, if not read it from the // content array.