mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-18 20:08:34 +01:00
* All apps/customfields:
Fix customfields options with multiple negated fields and single custom field Specify css class on customfield's row with named as field's id, in order to be able to customize its style
This commit is contained in:
parent
8af7a8a6b8
commit
02e525b95f
@ -63,7 +63,7 @@
|
||||
<menulist>
|
||||
<menupopup id="${row}[cf_type2]" no_lang="1" multiple="true" empty_label="All"/>
|
||||
</menulist>
|
||||
<description id="${row}[cf_name]" />
|
||||
<description id="${row}[cf_name]" no_lang="1" />
|
||||
<vbox>
|
||||
<description id="${row}[cf_label]" no_lang="1"/>
|
||||
<description id="${row}[cf_label]"/>
|
||||
|
@ -135,17 +135,21 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
// app changed
|
||||
$customfields =& egw_customfields::get($app);
|
||||
}
|
||||
|
||||
// Filter fields
|
||||
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;
|
||||
$this->attrs['field-names'] = substr($this->attrs['field_names'],1);
|
||||
if ($f[0] == "!")
|
||||
{
|
||||
$f= substr($f,1);
|
||||
$negate_fields[]= $f;
|
||||
}
|
||||
$field_filters []= $f;
|
||||
}
|
||||
$field_filter = explode(',', $this->attrs['field_names']);
|
||||
}
|
||||
|
||||
$fields = $customfields;
|
||||
|
||||
$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
|
||||
if($field_filter && (!$negate_field_filter && !in_array($key, $field_filter) ||
|
||||
$negate_field_filter && in_array($key, $field_filter)))
|
||||
if($field_filters && in_array($key, $negate_fields) && in_array($key, $field_filters))
|
||||
{
|
||||
unset($fields[$key]);
|
||||
}
|
||||
@ -169,11 +172,11 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
// 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("/$this->prefix([^\]]+)/",$form_name,$matches) && isset($fields[$name=$matches[1]]))
|
||||
preg_match($preg = '/'.self::$prefix.'([^\]]+)/',$form_name,$matches) && isset($fields[$name=$matches[1]]))
|
||||
{
|
||||
$fields = array($name => $fields[$name]);
|
||||
$value = array($this->prefix.$name => $value);
|
||||
$form_name = substr($form_name,0,-strlen("[$this->prefix$name]"));
|
||||
$value = array(self::$prefix.$name => $value);
|
||||
$form_name = self::$prefix.$name;
|
||||
}
|
||||
|
||||
if(!is_array($fields)) $fields = array();
|
||||
@ -199,7 +202,7 @@ class etemplate_widget_customfields extends etemplate_widget_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[$this->prefix.$lname]) && $value[$this->prefix.$lname] !== '') //break;
|
||||
if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break;
|
||||
{
|
||||
$fields_with_vals[]=$lname;
|
||||
}
|
||||
@ -368,7 +371,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
{
|
||||
self::set_validation_error($field,lang('Field must not be empty !!!'),'');
|
||||
}
|
||||
$field_name = self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field);
|
||||
$field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id,1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field);
|
||||
$valid =& self::get_array($validated, $field_name, true);
|
||||
|
||||
if (is_array($valid)) $valid = implode(',', $valid);
|
||||
|
@ -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: '#',
|
||||
|
||||
@ -189,7 +189,8 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput
|
||||
{
|
||||
|
||||
var row = jQuery(document.createElement("tr"))
|
||||
.appendTo(this.tbody);
|
||||
.appendTo(this.tbody)
|
||||
.addClass(this.id+'_'+id);
|
||||
var cf = jQuery(document.createElement("td"))
|
||||
.appendTo(row);
|
||||
if(!field.type) field.type = 'text";'
|
||||
@ -286,15 +287,22 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput
|
||||
// Set the value for this element
|
||||
var contentMgr = this.getArrayMgr("content");
|
||||
if (contentMgr != null) {
|
||||
var val = contentMgr.getEntry(this.id);
|
||||
var val = contentMgr.getEntry(this.id);
|
||||
_attrs["value"] = {};
|
||||
if (val !== null)
|
||||
{
|
||||
// Only set the values that match desired custom fields
|
||||
for(var key in val)
|
||||
if(this.id.indexOf(this.prefix) === 0 && data.fields[this.id.replace(this.prefix,'')] === true)
|
||||
{
|
||||
if(key.indexOf(this.prefix) == 0) {
|
||||
_attrs["value"][key] = val[key];
|
||||
_attrs['value'][this.id] = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only set the values that match desired custom fields
|
||||
for(var key in val)
|
||||
{
|
||||
if(key.indexOf(this.prefix) == 0) {
|
||||
_attrs["value"][key] = val[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
//_attrs["value"] = val;
|
||||
|
Loading…
Reference in New Issue
Block a user