- Fix read-only multi-select, was not displaying

- Fix issue with 'rows' being separate, threw off other options
- Move around icon/color multi-select options, use them for users.  We'll see.
This commit is contained in:
Nathan Gray 2012-04-30 23:29:31 +00:00
parent 4684f25530
commit f716f7fd6b
2 changed files with 39 additions and 11 deletions

View File

@ -121,7 +121,9 @@ class etemplate_widget_menupopup extends etemplate_widget
if ($this->attrs['type'])
{
// += to keep further options set by app code
self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'], $this->attrs['options'],
self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'],
// typeOptions thinks # of rows is the first thing in options
($this->attrs['rows'] && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options']),
$no_lang, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name));
// if no_lang was modified, forward modification to the client
@ -293,14 +295,14 @@ class etemplate_widget_menupopup extends etemplate_widget
}
$s .= $global_marker;
}
$options[$cat['id']] = empty($cat['description']) ? $s : array(
$options[$cat['id']] = array(
'label' => $s,
'title' => $cat['description'],
'title' => empty($cat['description']) ? $s : $cat['description'],
);
// For multi-select, send data too
if($rows > 1)
{
$options[$cat['id']]['data'] = $cat['data'];
$options[$cat['id']] += $cat['data'];
}
}
// preserv unavailible cats (eg. private user-cats)
@ -590,7 +592,6 @@ class etemplate_widget_menupopup extends etemplate_widget
$acc['account_'.$name] = $data[$id][$name];
}
}
$info = $show_type ? '('.$acc['account_type'].') ' : '';
if ($acc['account_type'] == 'g')
{
@ -613,6 +614,12 @@ class etemplate_widget_menupopup extends etemplate_widget
$acc['account_firstname'],$acc['account_lastname']);
break;
}
if($show_type) {
$info = array(
'label' => $info,
'icon' => $acc['account_type'] == 'g' ? 'addressbook/group' : 'users'
);
}
return $info;
}
}

View File

@ -220,18 +220,18 @@ var et2_selectbox = et2_inputWidget.extend({
}
// Some special stuff for categories
if(option_data)
if(option_data )
{
if(option_data.data.icon)
if(option_data.icon)
{
var img = this.egw().image(option_data.data.icon);
var img = this.egw().image(option_data.icon);
jQuery(document.createElement("img"))
.attr("src", img)
.appendTo(label);
}
if(option_data.data.color)
if(option_data.color)
{
label.css("background-color",option_data.data.color);
label.css("background-color",option_data.color);
}
}
label.append(jQuery("<span>"+_label+"</span>"))
@ -519,7 +519,10 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM], {
// Handle read-only multiselects in the same way
createMultiSelect: function() {
this.createInputWidget();
this.span = $j(document.createElement("ul"))
.addClass("et2_selectbox readonly");
this.setDOMNode(this.span[0]);
},
loadFromXML: function(_node) {
@ -543,7 +546,25 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM], {
},
set_value: function(_value) {
if(typeof _value == "string" && _value.match(/[,0-9]+$/) !== null && this.options.multiple)
{
_value = _value.split(',');
}
this.value = _value;
if(typeof _value == "object")
{
this.span.empty();
for(var i = 0; i < _value.length; i++)
{
var option = this.optionValues[_value[i]];
if(typeof option === "object")
{
option = option.label;
}
this.span.append("<li>"+option+"</li>");
}
return;
}
var option = this.optionValues[_value];
if (typeof option === 'object')
{