[IMP] Added possibility to customize the tipsy of kanban groups in kanban views

bzr revid: nicolas.vanhoren@openerp.com-20130719154604-vgr3wtn6xm1ezywg
This commit is contained in:
niv-openerp 2013-07-19 17:46:04 +02:00
parent f37497aaa8
commit 6021f031e5
1 changed files with 35 additions and 3 deletions

View File

@ -574,8 +574,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
});
},
start: function() {
var self = this,
def = this._super();
var self = this;
if (! self.view.group_by) {
self.$el.addClass("oe_kanban_no_group");
self.quick = new (get_class(self.view.quick_create_class))(this, self.dataset, {}, false)
@ -632,7 +631,40 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
}
});
this.is_started = true;
return def;
var def_tooltip = this.fetch_tooltip();
return $.when(def_tooltip);
},
fetch_tooltip: function() {
if (! this.group)
return;
var field_name = this.view.group_by;
var field = this.view.group_by_field;
var field_desc = null;
var recurse = function(node) {
if (node.tag === "field" && node.attrs.name === field_name) {
field_desc = node;
return;
}
_.each(node.children, function(child) {
if (field_desc === null)
recurse(child);
});
};
recurse(this.view.fields_view.arch);
if (! field_desc)
return;
var options = instance.web.py_eval(field_desc.attrs.options || '{}')
if (! options.tooltip_on_group_by)
return;
var self = this;
if (this.value) {
return (new instance.web.Model(field.relation)).query([options.tooltip_on_group_by])
.filter([["id", "=", this.value]]).first().then(function(res) {
self.tooltip = res[options.tooltip_on_group_by];
self.$(".oe_kanban_group_title_text").attr("title", self.tooltip || self.title || "").tipsy({html: true});
});
}
},
compute_cards_auto_height: function() {
// oe_kanban_no_auto_height is an empty class used to disable this feature