Get row category colors working

This commit is contained in:
Nathan Gray 2012-05-08 22:23:08 +00:00
parent 30e86a8195
commit 92dbd693d7
2 changed files with 45 additions and 6 deletions

View File

@ -299,11 +299,8 @@ class etemplate_widget_menupopup extends etemplate_widget
'label' => $s,
'title' => empty($cat['description']) ? $s : $cat['description'],
);
// For multi-select, send data too
if($rows > 1)
{
$options[$cat['id']] += $cat['data'];
}
// Send data too
$options[$cat['id']] += $cat['data'];
}
// preserv unavailible cats (eg. private user-cats)
/* TODO

View File

@ -428,7 +428,49 @@ var et2_nextmatch_rowProvider = Class.extend({
// TODO: Implement other fields than "class"
if (_data["class"])
{
_tr.setAttribute("class", _mgrs["content"].expandName(_data["class"]));
var classes = _mgrs["content"].expandName(_data["class"]);
// Get fancy with categories
var cats = [];
if(_data["class"].indexOf("cat") !== false)
{
cats = classes.match(/(cat_)?([0-9]+)/);
var invalid = typeof cats[1] == 'undefined';
if(invalid) egw().debug("warn", "Invalid class '%s', prefixed with 'cat_'",cats[0]);
cats = [cats[2]];
field = _data["class"].match(/\[(.*?cat.*?)\]/);
// Get category info
if(!this.categories)
{
if(field.length > 1)
{
var categories = _mgrs["sel_options"].getEntry(field[1]);
if(!categories) categories = _mgrs["sel_options"].getEntry('${row}'+field[0]);
}
// Cache
if(categories) this.categories = categories;
}
for(var i = 0; i < cats.length; i++)
{
// Need cat_, classes can't start with a number
var cat_class = 'cat_'+cats[i];
// Check for existing class
// Create class
if(this.categories[cats[i]] && this.categories[cats[i]].color)
{
var cat = this.categories[cats[i]];
egw().css('.'+cat_class, "background-color: " + cat.color + ";");
}
classes = classes.replace(cats[i], cat_class);
}
classes += " row_category";
}
_tr.setAttribute("class", classes);
}
}