From 3fd98b0f80f4bfe20fbced3f4990f79065b06b1e Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 18 Sep 2012 17:30:35 +0200 Subject: [PATCH] [IMP]kanban : div widget many2many_tags => field bzr revid: chm@openerp.com-20120918153035-xutvjflw057s8t18 --- addons/web_kanban/static/src/js/kanban.js | 40 +++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index fe15b22feee..6d68e62899a 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -71,6 +71,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ this.fields_keys = _.keys(this.fields_view.fields); this.add_qweb_template(); this.has_been_loaded.resolve(); + + this._super.apply(this, arguments); + return $.when(); }, _is_quick_create_enabled: function() { @@ -85,6 +88,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ return false; return this._super(action); }, + /* add_qweb_template + * select the nodes into the xml and send to extract_aggregates the nodes with TagName="field" + */ add_qweb_template: function() { for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) { var child = this.fields_view.arch.children[i]; @@ -97,6 +103,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ } } }, + /* extract_aggregates + * extract the agggregates from the nodes (TagName="field") + */ extract_aggregates: function(node) { for (var j = 0, jj = this.group_operators.length; j < jj; j++) { if (node.attrs[this.group_operators[j]]) { @@ -121,9 +130,15 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ } switch (node.tag) { case 'field': - node.tag = QWeb.prefix; - node.attrs[QWeb.prefix + '-esc'] = 'record.' + node.attrs['name'] + '.value'; - this.extract_aggregates(node); + if(this.fields_view.fields[ node.attrs['name'] ].type == 'many2many'){ + node.tag = 'div'; + node.attrs['class'] = 'oe_kanban_many2many_tags'; + node.attrs['model'] = this.fields_view.fields[node.attrs['name']].relation; + node.attrs['t-att-data'] = 'record.' + node.attrs['name'] + '.raw_value'; + }else { + node.tag = QWeb.prefix; + node.attrs[QWeb.prefix + '-esc'] = 'record.' + node.attrs['name'] + '.value'; + } break; case 'button': case 'a': @@ -163,17 +178,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ } } }, - /* widget for list of tags/categories... - * make :
+ /* widget for list of tags/categories... */ transform_widget_many2many: function(){ var self=this, arg={}; // select all widget - self.$el.find("[widget='many2many_tags']").each(function(){ - var model = $(this).attr("model"), - data = $(this).attr("data"), - list = data.split(","); + self.$el.find(".oe_kanban_many2many_tags").each(function(){ + var model = $(this).attr("model"); + var data = $(this).attr("data"); + var list = data.split(","); //select all id (per model) if(!arg[model]) arg[model]=[]; for(var t=0;t'+result[t][1]+''); } - }, - function(r){ - console.log('Error',r); } ); } @@ -717,6 +728,9 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ transform_record: function(record) { var self = this, new_record = {}; + + console.log(this, record); + _.each(record, function(value, name) { var r = _.clone(self.view.fields_view.fields[name] || {}); if ((r.type === 'date' || r.type === 'datetime') && value) {