diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index de3afb52cc..88587f011c 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -102,6 +102,9 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { var global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~'); if(global_data.fields) this.options.fields = global_data.fields; + // For checking app entries + var apps = egw.link_app_list(); + // Create the table rows for(var field_name in this.options.customfields) { @@ -116,7 +119,8 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { .appendTo(this.tbody); var cf = jQuery(document.createElement("td")) .appendTo(row); - var setup_function = '_setup_'+field.type; + var setup_function = '_setup_'+(apps[field.type] ? 'link_entry' : field.type.replace("-","_")); + var attrs = { 'id': id, 'statustext': field.help, @@ -143,7 +147,8 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { delete(attrs.label); // Create widget - var widget = this.widgets[field_name] = et2_createWidget(field.type, attrs, this); +console.debug(attrs); + var widget = this.widgets[field_name] = et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this); } // Field is not to be shown @@ -225,6 +230,10 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { _setup_select: function(field_name, field, attrs) { attrs.select_options = field.values; }, + _setup_link_entry: function(field_name, field, attrs) { + attrs.type = "link-entry"; + attrs.application = field.type; + }, /** * Code for implementing et2_IDetachedDOM diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index df6e03f169..5a83841632 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1140,7 +1140,7 @@ var et2_nextmatch_customfields = et2_nextmatch_header.extend({ widget = et2_createWidget("nextmatch-entryheader", { id: cf_id, application: field.type, - blur: field.label, + blur: field.label }, this); } else diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 9f75fd6648..cd452cd940 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -645,17 +645,26 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], { }, set_value: function(_value) { - if(!_value || !_value.title) { - this.link.text("").unbind(); - return; - } - if(typeof _value != 'object' && !this.options.application) + if(typeof _value != 'object' && _value && !this.options.application) { console.warn("Bad value for link widget. Need an object with keys 'app', 'id', and optionally 'title'", _value); return; } + // Application set, just passed ID + else if (_value == parseInt(_value)) + { + _value = { + app: this.options.application, + id: _value + }; + } + if(!_value || jQuery.isEmptyObject(_value)) { + this.link.text("").unbind(); + return; + } if(!_value.title) { - var title = egw.link_title(_value.app, _value.id, this.set_value, this); + var self = this; + var title = egw.link_title(_value.app, _value.id, function(title) {self.set_title(self.link[0], title);}, this); if(title != null) { _value.title = title; } @@ -665,11 +674,19 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], { return; } } - - this.link.text(_value.title).unbind() + this.set_title(this.link, _value.title); + this.link.unbind() .click( function(){egw.open(_value.id, _value.app, "edit", _value.extra);}); }, + /** + * Sets the text to be displayed. + * Used as a callback, so node is provided to make sure we get the right one + */ + set_title: function(node, _value) { + jQuery(node).text(_value+""); + }, + /** * Creates a list of attributes which can be set when working in the * "detached" mode. The result is stored in the _attrs array which is provided @@ -703,7 +720,7 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], { } }); -et2_register_widget(et2_link, ["link"]); +et2_register_widget(et2_link, ["link", "link-entry_ro"]); /** * UI widget for one or more links, comma separated