fixed cat-id in nextmatch header of addressbook is in id-order and not alphabetic/hierarchical order

This commit is contained in:
Ralf Becker 2014-02-18 16:35:54 +00:00
parent f04d607e2b
commit ae057bd957
3 changed files with 32 additions and 25 deletions

View File

@ -148,7 +148,20 @@ class etemplate_widget_menupopup extends etemplate_widget
*/ */
public function beforeSendToClient($cname) public function beforeSendToClient($cname)
{ {
$form_name = self::form_name($cname, $this->id); $matches = null;
if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something'
{
$form_name = $this->id;
}
// happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]'
elseif ($cname == 'nm' && preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches))
{
$form_name = $matches[2];
}
else
{
$form_name = self::form_name($cname, $this->id);
}
if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array();
if ($this->attrs['type']) if ($this->attrs['type'])
{ {

View File

@ -175,18 +175,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
{ {
$cat_app = $value['cat_app'] ? $value['cat_app'] : $GLOBALS['egw_info']['flags']['current_app']; $cat_app = $value['cat_app'] ? $value['cat_app'] : $GLOBALS['egw_info']['flags']['current_app'];
$value['options-cat_id'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,'.$cat_app,$no_lang,false,$value['cat_id']); $value['options-cat_id'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,'.$cat_app,$no_lang,false,$value['cat_id']);
// Prevent double encoding - widget does this on its own, but we're just grabbing the options etemplate_widget_menupopup::fix_encoded_options($value['options-cat_id']);
foreach($value['options-cat_id'] as &$label)
{
if(!is_array($label))
{
$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
}
elseif($label['label'])
{
$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
}
}
} }
// Favorite group for admins // Favorite group for admins
@ -547,7 +536,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
if (is_int($n) && is_array($rows)) if (is_int($n) && is_array($rows))
{ {
if (is_null($first)) $first = $n; if (is_null($first)) $first = $n;
if ($row[$is_parent]) // if app supports parent_id / hierarchy, set parent_id and is_parent if ($row[$is_parent]) // if app supports parent_id / hierarchy, set parent_id and is_parent
{ {
$row['is_parent'] = isset($is_parent_value) ? $row['is_parent'] = isset($is_parent_value) ?

View File

@ -199,25 +199,30 @@ var et2_selectbox = et2_inputWidget.extend(
} }
// Maybe in a row, and options got stuck in ${row} instead of top level // Maybe in a row, and options got stuck in ${row} instead of top level
var row_stuck = ['${row}','{$row}']; // not sure this code is still needed, as server-side no longer creates ${row} or {$row} for select-options
for(var i = 0; i < row_stuck.length; i++) if(!content_options || content_options.length == 0)
{ {
if((!content_options || content_options.length == 0) && ( var row_stuck = ['${row}','{$row}'];
// perspectiveData.row in nm, data["${row}"] in an auto-repeat grid for(var i = 0; i < row_stuck.length; i++)
this.getArrayMgr("sel_options").perspectiveData.row || this.getArrayMgr("sel_options").data[row_stuck[i]]))
{ {
var row_id = this.id.replace(/[0-9]+/,row_stuck[i]); // perspectiveData.row in nm, data["${row}"] in an auto-repeat grid
content_options = this.getArrayMgr("sel_options").getEntry(row_id); if(this.getArrayMgr("sel_options").perspectiveData.row || this.getArrayMgr("sel_options").data[row_stuck[i]])
if(!content_options || content_options.length == 0)
{ {
content_options = this.getArrayMgr("sel_options").getEntry(row_stuck[i] + '[' + this.id + ']'); var row_id = this.id.replace(/[0-9]+/,row_stuck[i]);
content_options = this.getArrayMgr("sel_options").getEntry(row_id);
if(!content_options || content_options.length == 0)
{
content_options = this.getArrayMgr("sel_options").getEntry(row_stuck[i] + '[' + 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)
{
_attrs["select_options"] = content_options; _attrs["select_options"] = content_options;
} }
} }