From 30958db5024e40a63da1564e8df11d757f5624fd Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 11 Jan 2017 17:37:48 +0100 Subject: [PATCH] [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. --- addons/web_kanban/static/src/js/kanban_record.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web_kanban/static/src/js/kanban_record.js b/addons/web_kanban/static/src/js/kanban_record.js index c784073f2a5..0d1816d660f 100644 --- a/addons/web_kanban/static/src/js/kanban_record.js +++ b/addons/web_kanban/static/src/js/kanban_record.js @@ -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');