Fix customfields options with multiple negated fields and single custom field

This commit is contained in:
Hadi Nategh 2015-03-27 16:32:51 +00:00
parent 9bfe86633c
commit 01e339815f
2 changed files with 12 additions and 9 deletions

View File

@ -135,17 +135,21 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
// app changed // app changed
$customfields =& egw_customfields::get($app); $customfields =& egw_customfields::get($app);
} }
// Filter fields // Filter fields
if($this->attrs['field-names']) if($this->attrs['field-names'])
{ {
if($this->attrs['field-names'][0] == '!') $fields_name = explode(',', $this->attrs['field-names']);
foreach($fields_name as &$f)
{ {
$negate_field_filter = true; if ($f[0] == "!")
$this->attrs['field-names'] = substr($this->attrs['field-names'],1); {
$f= substr($f,1);
$negate_fields[]= $f;
}
$field_filters []= $f;
} }
$field_filter = explode(',', $this->attrs['field-names']);
} }
$fields = $customfields; $fields = $customfields;
$use_private = self::expand_name($this->attrs['use-private'],0,0,'','',self::$cont); $use_private = self::expand_name($this->attrs['use-private'],0,0,'','',self::$cont);
@ -160,8 +164,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
} }
// Remove filtered fields // Remove filtered fields
if($field_filter && (!$negate_field_filter && !in_array($key, $field_filter) || if($field_filters && in_array($key, $negate_fields) && in_array($key, $field_filters))
$negate_field_filter && in_array($key, $field_filter)))
{ {
unset($fields[$key]); unset($fields[$key]);
} }
@ -173,7 +176,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
{ {
$fields = array($name => $fields[$name]); $fields = array($name => $fields[$name]);
$value = array(self::$prefix.$name => $value); $value = array(self::$prefix.$name => $value);
$form_name = substr($form_name,0,-strlen('['.self::$prefix.$name.']')); $form_name = self::$prefix.$name;
} }
if(!is_array($fields)) $fields = array(); if(!is_array($fields)) $fields = array();

View File

@ -53,7 +53,7 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput
} }
}, },
legacyOptions: ["type_filter","private"], // Field restriction & private done server-side legacyOptions: ["type_filter","private", "fields"], // Field restriction & private done server-side
prefix: '#', prefix: '#',