From 358df21fd2e6c04ad4bde9c123c0961ba445231f Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 15 Jun 2016 08:51:07 -0600 Subject: [PATCH] Fix resource (contact, resource, etc.) label sometimes not found --- api/js/etemplate/et2_widget_taglist.js | 2 +- calendar/js/et2_widget_owner.js | 30 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/et2_widget_taglist.js b/api/js/etemplate/et2_widget_taglist.js index ffb3f6c25e..8dedc2a1ea 100644 --- a/api/js/etemplate/et2_widget_taglist.js +++ b/api/js/etemplate/et2_widget_taglist.js @@ -832,7 +832,7 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR var min_width = jQuery('.ms-sel-item',this.div ).first().outerWidth() || this.div.children().first().width(); // Not ready yet - if(min_width === null) return; + if(min_width === null || !this.taglist) return; min_width += (this.options.multiple === 'toggle' ? jQuery('.toggle',this.div).outerWidth() : 0); min_width += this.taglist.trigger ? this.taglist.trigger.outerWidth(true) : 0; diff --git a/calendar/js/et2_widget_owner.js b/calendar/js/et2_widget_owner.js index 5092bad79b..b125e263a6 100644 --- a/calendar/js/et2_widget_owner.js +++ b/calendar/js/et2_widget_owner.js @@ -90,6 +90,36 @@ var et2_calendar_owner = (function(){ "use strict"; return et2_taglist_email.ext { if(this.taglist == null) return null; return this.taglist.getValue(); + }, + + /** + * Override parent to handle our special additional data types (c#,r#,etc.) when they + * are not available client side. + * + * @param {string|string[]} _value array of selected owners, which can be a number, + * or a number prefixed with one character indicating the resource type. + */ + set_value: function(_value) + { + this._super.apply(this, arguments); + + // If parent didn't find a label, label will be the same as ID so we + // can find them that way + for(var i = 0; i < this.options.value.length; i++) + { + var value = this.options.value[i]; + if(value.id == value.label) + { + // Proper label was not fount by parent - ask directly + egw.json('calendar_owner_etemplate_widget::ajax_owner',value.id,function(data) {value.label = data;}, this).sendRequest(); + } + } + + if(this.taglist) + { + this.taglist.clear(true); + this.taglist.addToSelection(this.options.value,true); + } } });}).call(this); et2_register_widget(et2_calendar_owner, ["calendar-owner"]); \ No newline at end of file