If a widget is transformed into a template, try to load and process that template too.

This commit is contained in:
Nathan Gray 2015-01-14 20:10:34 +00:00
parent 4e27f324c9
commit 06abca167d
4 changed files with 19 additions and 14 deletions

View File

@ -175,7 +175,7 @@ class contact_widget extends etemplate_widget_entry
{ {
$value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']); $value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']);
} }
// fall-throught // fall-through
case 'contact-value': case 'contact-value':
default: default:
if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax

View File

@ -58,7 +58,7 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer
* *
* @param string $cname * @param string $cname
*/ */
public function beforeSendToClient($cname) public function beforeSendToClient($cname, array $expand=array())
{ {
$attrs = $this->attrs; $attrs = $this->attrs;
@ -96,7 +96,7 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer
$old_type = self::getElementAttribute($this->id, 'type'); $old_type = self::getElementAttribute($this->id, 'type');
parent::beforeSendToClient($cname); parent::beforeSendToClient($cname, $expand);
// Check for conflict - more than one with same id/field and different type // Check for conflict - more than one with same id/field and different type
if($old_type && $old_type != $this->type) if($old_type && $old_type != $this->type)

View File

@ -99,7 +99,7 @@ abstract class etemplate_widget_transformer extends etemplate_widget
* *
* @param string $cname * @param string $cname
*/ */
public function beforeSendToClient($cname) public function beforeSendToClient($cname, array $expand=array())
{ {
$attrs = $this->attrs; $attrs = $this->attrs;
$form_name = self::form_name($cname, $this->id); $form_name = self::form_name($cname, $this->id);
@ -136,6 +136,14 @@ abstract class etemplate_widget_transformer extends etemplate_widget
self::$request->sel_options[$form_name] = $val; self::$request->sel_options[$form_name] = $val;
break; break;
case 'type': // not an attribute in etemplate2 case 'type': // not an attribute in etemplate2
if($val == 'template')
{
// If the widget has been transformed into a template, we
// also need to try and instanciate & parse the template too
$transformed_template = etemplate_widget_template::instance($attrs['template']);
$this->expand_widget($transformed_template, $expand);
$transformed_template->run('beforeSendToClient',array($cname,$expand));
}
default: default:
self::setElementAttribute($form_name, $attr, $val); self::setElementAttribute($form_name, $attr, $val);
break; break;

View File

@ -59,9 +59,6 @@ var et2_entry = et2_valueWidget.extend(
legacyOptions: ["field","compare","alternate_fields"], legacyOptions: ["field","compare","alternate_fields"],
// Doesn't really need a namespace, but this simplifies the sub-widgets
createNamespace: true,
prefix: '~', prefix: '~',
/** /**
@ -102,17 +99,17 @@ var et2_entry = et2_valueWidget.extend(
*/ */
loadField: function() { loadField: function() {
// Create widget of correct type // Create widget of correct type
var entry = {type: 'label'}; var attrs = {
id: this.id + '[' +this.options.field+']',
type: 'label',
readonly: this.options.readonly
};
var modifications = this.getArrayMgr("modifications"); var modifications = this.getArrayMgr("modifications");
if(modifications && this.options.field) if(modifications && this.options.field)
{ {
jQuery.extend(entry, modifications.getEntry(this.options.field)); jQuery.extend(attrs, modifications.getEntry(attrs.id));
} }
var attrs = {
id: this.options.field,
type: entry.type || 'label',
readonly: this.options.readonly
};
// Supress labels on templates // Supress labels on templates
if(attrs.type == 'template' && this.options.label) if(attrs.type == 'template' && this.options.label)
{ {