mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
Etemplate: Fix for some attributes not getting set
This commit is contained in:
parent
870cb9f175
commit
8910983c8e
@ -119,7 +119,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
if (!this.options || !this.options.customfields)
|
||||
return;
|
||||
// Already set up - avoid duplicates in nextmatch
|
||||
if (this.getType() == 'customfields-list' && !this.isInTree())
|
||||
if (this.getType() == 'customfields-list' && !this.isInTree() && Object.keys(this.widgets).length > 0)
|
||||
return;
|
||||
if (!jQuery.isEmptyObject(this.widgets))
|
||||
return;
|
||||
@ -282,7 +282,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
// Make sure widget is created, and has the needed function
|
||||
if (!this.widgets[field_name] || !this.widgets[field_name].set_value)
|
||||
continue;
|
||||
var value = _value[this.options.prefix + field_name] ? _value[et2_customfields_list.PREFIX + field_name] : null;
|
||||
var value = _value[this.options.prefix + field_name] ? _value[this.options.prefix + field_name] : null;
|
||||
// Check if ID was missing
|
||||
if (value == null && this.id == et2_customfields_list.DEFAULT_ID && this.getArrayMgr("content").getEntry(this.options.prefix + field_name)) {
|
||||
value = this.getArrayMgr("content").getEntry(this.options.prefix + field_name);
|
||||
|
@ -189,7 +189,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
if(!this.options || !this.options.customfields) return;
|
||||
|
||||
// Already set up - avoid duplicates in nextmatch
|
||||
if(this.getType() == 'customfields-list' && !this.isInTree()) return;
|
||||
if(this.getType() == 'customfields-list' && !this.isInTree() && Object.keys(this.widgets).length > 0) return;
|
||||
if(!jQuery.isEmptyObject(this.widgets)) return;
|
||||
|
||||
// Check for global setting changes (visibility)
|
||||
@ -391,7 +391,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
|
||||
// Make sure widget is created, and has the needed function
|
||||
if(!this.widgets[field_name] || !this.widgets[field_name].set_value) continue;
|
||||
let value = _value[this.options.prefix + field_name] ? _value[et2_customfields_list.PREFIX + field_name] : null;
|
||||
let value = _value[this.options.prefix + field_name] ? _value[this.options.prefix + field_name] : null;
|
||||
|
||||
// Check if ID was missing
|
||||
if(value == null && this.id == et2_customfields_list.DEFAULT_ID && this.getArrayMgr("content").getEntry(this.options.prefix + field_name))
|
||||
|
@ -195,7 +195,7 @@ class Widget
|
||||
$template = $this;
|
||||
while($reader->moveToNextAttribute())
|
||||
{
|
||||
if ($reader->name != 'id' && $template->attr[$reader->name] != $reader->value)
|
||||
if ($reader->name != 'id' && $template->attr[$reader->name] !== $reader->value)
|
||||
{
|
||||
if (!$cloned)
|
||||
{
|
||||
@ -209,7 +209,7 @@ class Widget
|
||||
// expand attributes values, otherwise eg. validation can not use attrs referencing to content
|
||||
if ($value[0] == '@' || strpos($value, '$cont') !== false)
|
||||
{
|
||||
$value = self::expand_name($value, null, null, null, null,
|
||||
$template->attrs[$reader->name] = $value = self::expand_name($value, null, null, null, null,
|
||||
isset(self::$cont) ? self::$cont : self::$request->content);
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ class Customfields extends Transformer
|
||||
|
||||
public function __construct($xml)
|
||||
{
|
||||
$this->attrs['prefix'] = self::$prefix;
|
||||
parent::__construct($xml);
|
||||
}
|
||||
|
||||
@ -124,7 +125,7 @@ class Customfields extends Transformer
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
}
|
||||
|
||||
if(!$app)
|
||||
if(!$app && !$customfields)
|
||||
{
|
||||
$app =& $this->setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']);
|
||||
if ($this->attrs['sub-app']) $app .= '-'.$this->attrs['sub-app'];
|
||||
@ -138,6 +139,10 @@ class Customfields extends Transformer
|
||||
// app changed
|
||||
$customfields =& Api\Storage\Customfields::get($app);
|
||||
}
|
||||
if($this->attrs['customfields'])
|
||||
{
|
||||
$customfields = $this->attrs['customfields'];
|
||||
}
|
||||
// Filter fields
|
||||
if($this->attrs['field-names'])
|
||||
{
|
||||
@ -174,20 +179,20 @@ class Customfields extends Transformer
|
||||
|
||||
// Rmove fields for none private cutomfields when name refers to a single custom field
|
||||
$matches = null;
|
||||
if (($pos=strpos($form_name,self::$prefix)) !== false &&
|
||||
preg_match($preg = '/'.self::$prefix.'([^\]]+)/',$form_name,$matches) && !isset($fields[$name=$matches[1]]))
|
||||
if (($pos=strpos($form_name,$this->attrs['prefix'])) !== false &&
|
||||
preg_match($preg = '/'.$this->attrs['prefix'].'([^\]]+)/',$form_name,$matches) && !isset($fields[$name=$matches[1]]))
|
||||
{
|
||||
unset($fields[$key]);
|
||||
}
|
||||
}
|
||||
// check if name refers to a single custom field --> show only that
|
||||
$matches = null;
|
||||
if (($pos=strpos($form_name,self::$prefix)) !== false && // allow the prefixed name to be an array index too
|
||||
preg_match($preg = '/'.self::$prefix.'([^\]]+)/',$form_name,$matches) && isset($fields[$name=$matches[1]]))
|
||||
if (($pos=strpos($form_name,$this->attrs['prefix'])) !== false && // allow the prefixed name to be an array index too
|
||||
preg_match($preg = '/'.$this->attrs['prefix'].'([^\]]+)/',$form_name,$matches) && isset($fields[$name=$matches[1]]))
|
||||
{
|
||||
$fields = array($name => $fields[$name]);
|
||||
$value = array(self::$prefix.$name => $value);
|
||||
$form_name = self::$prefix.$name;
|
||||
$value = array($this->attrs['prefix'].$name => $value);
|
||||
$form_name = $this->attrs['prefix'].$name;
|
||||
}
|
||||
|
||||
if(!is_array($fields)) $fields = array();
|
||||
@ -216,7 +221,7 @@ class Customfields extends Transformer
|
||||
{
|
||||
if (!empty($this->attrs['sub-type']) && !empty($field['type2']) &&
|
||||
strpos(','.$field['type2'].',',','.$field['type2'].',') === false) continue; // not for our content type//
|
||||
if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break;
|
||||
if (isset($value[$this->attrs['prefix'].$lname]) && $value[$this->attrs['prefix'].$lname] !== '') //break;
|
||||
{
|
||||
$fields_with_vals[]=$lname;
|
||||
}
|
||||
@ -400,7 +405,14 @@ class Customfields extends Transformer
|
||||
// if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find
|
||||
if (!$this->id) $content = array_merge($content, $value_in);
|
||||
//error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in));
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
if($this->getElementAttribute($form_name, 'customfields'))
|
||||
{
|
||||
$customfields =& $this->getElementAttribute($form_name, 'customfields');
|
||||
}
|
||||
else
|
||||
{
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
}
|
||||
if(is_array($value_in))
|
||||
{
|
||||
foreach(array_keys($value_in) as $field)
|
||||
|
Loading…
Reference in New Issue
Block a user