[IMP] web_kanban: introduced color attribute

An attribute `color` has been introduced on the kanban record ;
it contains the field name of the color and set the corresponding
class on the record.

This will add the corresponding class for the kanban color and avoid
to set manually the good old

`t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)}'

on the kanban record.
This commit is contained in:
Martin Geubelle
2017-01-19 11:57:20 +01:00
parent 3649b7f359
commit 30958db502
@@ -98,6 +98,7 @@ var KanbanRecord = Widget.extend({
renderElement: function () {
this._super();
this.setup_color();
this.setup_color_picker();
this.$el.addClass('o_kanban_record');
this.$el.data('record', this);
@@ -267,6 +268,17 @@ var KanbanRecord = Widget.extend({
this.trigger_up('kanban_record_update', event.data);
},
/*
* If an attribute `color` is set on the kanban record,
* this will add the corresponding color class.
*/
setup_color: function() {
var color_field = this.$el.attr('color');
if (color_field && color_field in this.fields) {
this.$el.addClass(this.kanban_color(this.values[color_field].value));
}
},
setup_color_picker: function() {
var self = this;
var $colorpicker = this.$('ul.oe_kanban_colorpicker');