mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-04 21:18:54 +01:00
* Addressbook: fixed sorting of category tree
fixes not displayed cat-tree and validation error introduced with r47575
This commit is contained in:
parent
6d9421e034
commit
2a6168a1c2
@ -125,6 +125,20 @@ class etemplate_widget_tree extends etemplate_widget
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if given $id is cat_id attribute of one of given array members
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param array $cats
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function in_cats($id, array $cats)
|
||||||
|
{
|
||||||
|
return (boolean)array_filter($cats, function($cat) use($id){
|
||||||
|
return $cat['id'] == $id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate input
|
* Validate input
|
||||||
*
|
*
|
||||||
@ -149,7 +163,7 @@ class etemplate_widget_tree extends etemplate_widget
|
|||||||
$allowed += self::selOptions($form_name);
|
$allowed += self::selOptions($form_name);
|
||||||
foreach((array) $value as $val)
|
foreach((array) $value as $val)
|
||||||
{
|
{
|
||||||
if ($this->type == 'tree-cat' && !($this->attrs['multiple'] && !$val) && !isset($allowed[$val]) ||
|
if ($this->type == 'tree-cat' && !($this->attrs['multiple'] && !$val) && !self::in_cats($val, $allowed) ||
|
||||||
$this->type == 'tree' && !self::in_tree($val, $allowed))
|
$this->type == 'tree' && !self::in_tree($val, $allowed))
|
||||||
{
|
{
|
||||||
self::set_validation_error($form_name,lang("'%1' is NOT allowed%2)!", $val,
|
self::set_validation_error($form_name,lang("'%1' is NOT allowed%2)!", $val,
|
||||||
@ -169,7 +183,7 @@ class etemplate_widget_tree extends etemplate_widget
|
|||||||
self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
|
self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
|
||||||
}
|
}
|
||||||
$valid =& self::get_array($validated, $form_name, true);
|
$valid =& self::get_array($validated, $form_name, true);
|
||||||
$valid = $value;
|
if (true) $valid = $value;
|
||||||
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
|
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ var et2_tree = et2_inputWidget.extend(
|
|||||||
|
|
||||||
// Try again according to ID
|
// Try again according to ID
|
||||||
if(!content_options) content_options = this.getArrayMgr("sel_options").getEntry(this.id);
|
if(!content_options) content_options = this.getArrayMgr("sel_options").getEntry(this.id);
|
||||||
if(_attrs["select_options"] && content_options)
|
if(_attrs["select_options"] && !jQuery.isEmptyObject(_attrs["select_options"]) && content_options)
|
||||||
{
|
{
|
||||||
_attrs["select_options"] = jQuery.extend({},_attrs["select_options"],content_options);
|
_attrs["select_options"] = jQuery.extend({},_attrs["select_options"],content_options);
|
||||||
} else if (content_options) {
|
} else if (content_options) {
|
||||||
@ -250,10 +250,11 @@ var et2_tree = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Structure data for category tree
|
// Structure data for category tree
|
||||||
if(this._type == 'tree-cat' && !jQuery.isArray(options)) {
|
if(this._type == 'tree-cat')
|
||||||
|
{
|
||||||
var data = {id:0,item:[]};
|
var data = {id:0,item:[]};
|
||||||
var stack = [];
|
var stack = {};
|
||||||
for(var key in options)
|
for(var key=0; key < options.length; key++)
|
||||||
{
|
{
|
||||||
// See if item has an icon
|
// See if item has an icon
|
||||||
if(options[key].data && typeof options[key].data.icon !== 'undefined' && options[key].data.icon)
|
if(options[key].data && typeof options[key].data.icon !== 'undefined' && options[key].data.icon)
|
||||||
|
Loading…
Reference in New Issue
Block a user