[MERGE] forward port of branch saas-3 up to d36eee9
[odoo/odoo.git] / addons / web_kanban / static / src / js / kanban.js
1 openerp.web_kanban = function (instance) {
2
3 var _t = instance.web._t,
4    _lt = instance.web._lt;
5 var QWeb = instance.web.qweb;
6 instance.web.views.add('kanban', 'instance.web_kanban.KanbanView');
7
8 instance.web_kanban.KanbanView = instance.web.View.extend({
9     template: "KanbanView",
10     display_name: _lt('Kanban'),
11     default_nr_columns: 1,
12     view_type: "kanban",
13     quick_create_class: "instance.web_kanban.QuickCreate",
14     number_of_color_schemes: 10,
15     init: function (parent, dataset, view_id, options) {
16         this._super(parent, dataset, view_id, options);
17         var self = this;
18         _.defaults(this.options, {
19             "quick_creatable": true,
20             "creatable": true,
21             "create_text": undefined,
22             "read_only_mode": false,
23             "confirm_on_delete": true,
24         });
25         this.fields_view = {};
26         this.fields_keys = [];
27         this.group_by = null;
28         this.group_by_field = {};
29         this.grouped_by_m2o = false;
30         this.many2manys = [];
31         this.state = {
32             groups : {},
33             records : {}
34         };
35         this.groups = [];
36         this.aggregates = {};
37         this.group_operators = ['avg', 'max', 'min', 'sum', 'count'];
38         this.qweb = new QWeb2.Engine();
39         this.qweb.debug = instance.session.debug;
40         this.qweb.default_dict = _.clone(QWeb.default_dict);
41         this.has_been_loaded = $.Deferred();
42         this.search_domain = this.search_context = this.search_group_by = null;
43         this.currently_dragging = {};
44         this.limit = options.limit || 40;
45         this.add_group_mutex = new $.Mutex();
46     },
47     view_loading: function(r) {
48         return this.load_kanban(r);
49     },
50     start: function() {
51         var self = this;
52         this._super.apply(this, arguments);
53         this.$el.on('click', '.oe_kanban_dummy_cell', function() {
54             if (self.$buttons) {
55                 self.$buttons.find('.oe_kanban_add_column').openerpBounce();
56             }
57         });
58     },
59     destroy: function() {
60         this._super.apply(this, arguments);
61         $('html').off('click.kanban');
62     },
63     load_kanban: function(data) {
64         this.fields_view = data;
65
66         // use default order if defined in xml description
67         var default_order = this.fields_view.arch.attrs.default_order,
68             unsorted = !this.dataset._sort.length;
69         if (unsorted && default_order) {
70             this.dataset.set_sort(default_order.split(','));
71         }
72
73         this.$el.addClass(this.fields_view.arch.attrs['class']);
74         this.$buttons = $(QWeb.render("KanbanView.buttons", {'widget': this}));
75         if (this.options.$buttons) {
76             this.$buttons.appendTo(this.options.$buttons);
77         } else {
78             this.$el.find('.oe_kanban_buttons').replaceWith(this.$buttons);
79         }
80         this.$buttons
81             .on('click', 'button.oe_kanban_button_new', this.do_add_record)
82             .on('click', '.oe_kanban_add_column', this.do_add_group);
83         this.$groups = this.$el.find('.oe_kanban_groups tr');
84         this.fields_keys = _.keys(this.fields_view.fields);
85         this.add_qweb_template();
86         this.has_been_loaded.resolve();
87         this.trigger('kanban_view_loaded', data);
88         return $.when();
89     },
90     _is_quick_create_enabled: function() {
91         if (!this.options.quick_creatable || !this.is_action_enabled('create'))
92             return false;
93         if (this.fields_view.arch.attrs.quick_create !== undefined)
94             return JSON.parse(this.fields_view.arch.attrs.quick_create);
95         return !! this.group_by;
96     },
97     is_action_enabled: function(action) {
98         if (action === 'create' && !this.options.creatable)
99             return false;
100         return this._super(action);
101     },
102     /*  add_qweb_template
103     *   select the nodes into the xml and send to extract_aggregates the nodes with TagName="field"
104     */
105     add_qweb_template: function() {
106         for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) {
107             var child = this.fields_view.arch.children[i];
108             if (child.tag === "templates") {
109                 this.transform_qweb_template(child);
110                 this.qweb.add_template(instance.web.json_node_to_xml(child));
111                 break;
112             } else if (child.tag === 'field') {
113                 this.extract_aggregates(child);
114             }
115         }
116     },
117     /*  extract_aggregates
118     *   extract the agggregates from the nodes (TagName="field")
119     */
120     extract_aggregates: function(node) {
121         for (var j = 0, jj = this.group_operators.length; j < jj;  j++) {
122             if (node.attrs[this.group_operators[j]]) {
123                 this.aggregates[node.attrs.name] = node.attrs[this.group_operators[j]];
124                 break;
125             }
126         }
127     },
128     transform_qweb_template: function(node) {
129         var qweb_add_if = function(node, condition) {
130             if (node.attrs[QWeb.prefix + '-if']) {
131                 condition = _.str.sprintf("(%s) and (%s)", node.attrs[QWeb.prefix + '-if'], condition);
132             }
133             node.attrs[QWeb.prefix + '-if'] = condition;
134         };
135         // Process modifiers
136         if (node.tag && node.attrs.modifiers) {
137             var modifiers = JSON.parse(node.attrs.modifiers || '{}');
138             if (modifiers.invisible) {
139                 qweb_add_if(node, _.str.sprintf("!kanban_compute_domain(%s)", JSON.stringify(modifiers.invisible)));
140             }
141         }
142         switch (node.tag) {
143             case 'field':
144                 var ftype = this.fields_view.fields[node.attrs.name].type;
145                 ftype = node.attrs.widget ? node.attrs.widget : ftype;
146                 if (ftype === 'many2many') {
147                     if (_.indexOf(this.many2manys, node.attrs.name) < 0) {
148                         this.many2manys.push(node.attrs.name);
149                     }
150                     node.tag = 'div';
151                     node.attrs['class'] = (node.attrs['class'] || '') + ' oe_form_field oe_tags';
152                 } else if (instance.web_kanban.fields_registry.contains(ftype)) {
153                     // do nothing, the kanban record will handle it
154                 } else {
155                     node.tag = QWeb.prefix;
156                     node.attrs[QWeb.prefix + '-esc'] = 'record.' + node.attrs['name'] + '.value';
157                 }
158                 break;
159             case 'button':
160             case 'a':
161                 var type = node.attrs.type || '';
162                 if (_.indexOf('action,object,edit,open,delete'.split(','), type) !== -1) {
163                     _.each(node.attrs, function(v, k) {
164                         if (_.indexOf('icon,type,name,args,string,context,states,kanban_states'.split(','), k) != -1) {
165                             node.attrs['data-' + k] = v;
166                             delete(node.attrs[k]);
167                         }
168                     });
169                     if (node.attrs['data-string']) {
170                         node.attrs.title = node.attrs['data-string'];
171                     }
172                     if (node.attrs['data-icon']) {
173                         node.children = [{
174                             tag: 'img',
175                             attrs: {
176                                 src: instance.session.prefix + '/web/static/src/img/icons/' + node.attrs['data-icon'] + '.png',
177                                 width: '16',
178                                 height: '16'
179                             }
180                         }];
181                     }
182                     if (node.tag == 'a') {
183                         node.attrs.href = '#';
184                     } else {
185                         node.attrs.type = 'button';
186                     }
187                     node.attrs['class'] = (node.attrs['class'] || '') + ' oe_kanban_action oe_kanban_action_' + node.tag;
188                 }
189                 break;
190         }
191         if (node.children) {
192             for (var i = 0, ii = node.children.length; i < ii; i++) {
193                 this.transform_qweb_template(node.children[i]);
194             }
195         }
196     },
197     do_add_record: function() {
198         this.dataset.index = null;
199         this.do_switch_view('form');
200     },
201     do_add_group: function() {
202         var self = this;
203         self.do_action({
204             name: _t("Add column"),
205             res_model: self.group_by_field.relation,
206             views: [[false, 'form']],
207             type: 'ir.actions.act_window',
208             target: "new",
209             context: self.dataset.get_context(),
210             flags: {
211                 action_buttons: true,
212             }
213         });
214         var am = instance.webclient.action_manager;
215         var form = am.dialog_widget.views.form.controller;
216         form.on("on_button_cancel", am.dialog, am.dialog.close);
217         form.on('record_created', self, function(r) {
218             (new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r]).done(function(new_record) {
219                 am.dialog.close();
220                 var domain = self.dataset.domain.slice(0);
221                 domain.push([self.group_by, '=', new_record[0][0]]);
222                 var dataset = new instance.web.DataSetSearch(self, self.dataset.model, self.dataset.get_context(), domain);
223                 var datagroup = {
224                     get: function(key) {
225                         return this[key];
226                     },
227                     value: new_record[0],
228                     length: 0,
229                     aggregates: {},
230                 };
231                 var new_group = new instance.web_kanban.KanbanGroup(self, [], datagroup, dataset);
232                 self.do_add_groups([new_group]).done(function() {
233                     $(window).scrollTo(self.groups.slice(-1)[0].$el, { axis: 'x' });
234                 });
235             });
236         });
237     },
238     do_search: function(domain, context, group_by) {
239         var self = this;
240         this.search_domain = domain;
241         this.search_context = context;
242         this.search_group_by = group_by;
243         return $.when(this.has_been_loaded).then(function() {
244             self.group_by = group_by.length ? group_by[0] : self.fields_view.arch.attrs.default_group_by;
245             self.group_by_field = self.fields_view.fields[self.group_by] || {};
246             self.grouped_by_m2o = (self.group_by_field.type === 'many2one');
247             self.$buttons.find('.oe_alternative').toggle(self.grouped_by_m2o);
248             self.$el.toggleClass('oe_kanban_grouped_by_m2o', self.grouped_by_m2o);
249             var grouping_fields = self.group_by ? [self.group_by].concat(_.keys(self.aggregates)) : undefined;
250             if (!_.isEmpty(grouping_fields)) {
251                 // ensure group_by fields are read.
252                 self.fields_keys = _.unique(self.fields_keys.concat(grouping_fields));
253             }
254             var grouping = new instance.web.Model(self.dataset.model, context, domain).query(self.fields_keys).group_by(grouping_fields);
255             return self.alive($.when(grouping)).done(function(groups) {
256                 self.remove_no_result();
257                 if (groups) {
258                     self.do_process_groups(groups);
259                 } else {
260                     self.do_process_dataset();
261                 }
262             });
263         });
264     },
265     do_process_groups: function(groups) {
266         var self = this;
267         this.$el.find('table:first').show();
268         this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
269         this.add_group_mutex.exec(function() {
270             self.do_clear_groups();
271             self.dataset.ids = [];
272             if (!groups.length) {
273                 self.no_result();
274                 return false;
275             }
276             self.nb_records = 0;
277             var groups_array = [];
278             return $.when.apply(null, _.map(groups, function (group, index) {
279                 var def = $.when([]);
280                 var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
281                     new instance.web.CompoundContext(self.dataset.get_context(), group.model.context()), group.model.domain());
282                 if (group.attributes.length >= 1) {
283                     def = dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit });
284                 }
285                 return def.then(function(records) {
286                         self.nb_records += records.length;
287                         self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
288                         groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
289                 });
290             })).then(function () {
291                 if(!self.nb_records) {
292                     self.no_result();
293                 }
294                 if (self.dataset.index >= self.nb_records){
295                     self.dataset.index = self.dataset.size() ? 0 : null;
296                 }
297                 return self.do_add_groups(groups_array);
298             });
299         });
300     },
301     do_process_dataset: function() {
302         var self = this;
303         this.$el.find('table:first').show();
304         this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
305         this.add_group_mutex.exec(function() {
306             var def = $.Deferred();
307             self.do_clear_groups();
308             self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).done(function(records) {
309                 var kgroup = new instance.web_kanban.KanbanGroup(self, records, null, self.dataset);
310                 if (!_.isEmpty(self.dataset.ids) && (self.dataset.index === null || self.dataset.index >= self.dataset.ids.length)) {
311                     self.dataset.index = 0;
312                 } else if (_.isEmpty(self.dataset.ids)){
313                     self.dataset.index = null;
314                 }
315                 self.do_add_groups([kgroup]).done(function() {
316                     if (_.isEmpty(records)) {
317                         self.no_result();
318                     }
319                     def.resolve();
320                 });
321             }).done(null, function() {
322                 def.reject();
323             });
324             return def;
325         });
326     },
327     do_reload: function() {
328         this.do_search(this.search_domain, this.search_context, this.search_group_by);
329     },
330     do_clear_groups: function() {
331         var groups = this.groups.slice(0);
332         this.groups = [];
333         _.each(groups, function(group) {
334             group.destroy();
335         });
336     },
337     do_add_groups: function(groups) {
338         var self = this;
339         var $parent = this.$el.parent();
340         this.$el.detach();
341         _.each(groups, function(group) {
342             self.groups[group.undefined_title ? 'unshift' : 'push'](group);
343         });
344         var $last_td = self.$el.find('.oe_kanban_groups_headers td:last');
345         var groups_started = _.map(this.groups, function(group) {
346             if (!group.is_started) {
347                 group.on("add_record", self, function () {
348                     self.remove_no_result();
349                 });
350                 return group.insertBefore($last_td);
351             }
352         });
353         return $.when.apply(null, groups_started).done(function () {
354             self.on_groups_started();
355             self.$el.appendTo($parent);
356             _.each(self.groups, function(group) {
357                 group.compute_cards_auto_height();
358             });
359         });
360     },
361     on_groups_started: function() {
362         var self = this;
363         if (this.group_by || this.fields_keys.indexOf("sequence") !== -1) {
364             // Kanban cards drag'n'drop
365             var prev_widget, is_folded, record, $columns;
366             if (this.group_by) {
367                 $columns = this.$el.find('.oe_kanban_column .oe_kanban_column_cards, .oe_kanban_column .oe_kanban_folded_column_cards');
368             } else {
369                 $columns = this.$el.find('.oe_kanban_column_cards');
370             }
371             $columns.sortable({
372                 handle : '.oe_kanban_draghandle',
373                 start: function(event, ui) {
374                     self.currently_dragging.index = ui.item.parent().children('.oe_kanban_record').index(ui.item);
375                     self.currently_dragging.group = prev_widget = ui.item.parents('.oe_kanban_column:first').data('widget');
376                     ui.item.find('*').on('click.prevent', function(ev) {
377                         return false;
378                     });
379                     record = ui.item.data('widget');
380                     record.$el.bind('mouseup',function(ev,ui){
381                         if (is_folded) {
382                             record.$el.hide();
383                         }
384                         record.$el.unbind('mouseup');
385                     })
386                     ui.placeholder.height(ui.item.height());
387                 },
388                 over: function(event, ui) {
389                     var parent = $(event.target).parent();
390                     prev_widget.highlight(false);
391                     is_folded = parent.hasClass('oe_kanban_group_folded'); 
392                     if (is_folded) {
393                         var widget = parent.data('widget');
394                         widget.highlight(true);
395                         prev_widget = widget;
396                     }
397                  },
398                 revert: 150,
399                 stop: function(event, ui) {
400                     prev_widget.highlight(false);
401                     var old_index = self.currently_dragging.index;
402                     var new_index = ui.item.parent().children('.oe_kanban_record').index(ui.item);
403                     var old_group = self.currently_dragging.group;
404                     var new_group = ui.item.parents('.oe_kanban_column:first').data('widget');
405                     if (!(old_group.title === new_group.title && old_group.value === new_group.value && old_index == new_index)) {
406                         self.on_record_moved(record, old_group, old_index, new_group, new_index);
407                     }
408                     setTimeout(function() {
409                         // A bit hacky but could not find a better solution for Firefox (problem not present in chrome)
410                         // http://stackoverflow.com/questions/274843/preventing-javascript-click-event-with-scriptaculous-drag-and-drop
411                         ui.item.find('*').off('click.prevent');
412                     }, 0);
413                 },
414                 scroll: false
415             });
416             // Keep connectWith out of the sortable initialization for performance sake:
417             // http://www.planbox.com/blog/development/coding/jquery-ui-sortable-slow-to-bind.html
418             $columns.sortable({ connectWith: $columns });
419
420             // Kanban groups drag'n'drop
421             var start_index;
422             if (this.grouped_by_m2o) {
423                 this.$('.oe_kanban_groups_headers').sortable({
424                     items: '.oe_kanban_group_header',
425                     helper: 'clone',
426                     axis: 'x',
427                     opacity: 0.5,
428                     scroll: false,
429                     start: function(event, ui) {
430                         start_index = ui.item.index();
431                         self.$('.oe_kanban_record, .oe_kanban_quick_create').css({ visibility: 'hidden' });
432                     },
433                     stop: function(event, ui) {
434                         var stop_index = ui.item.index();
435                         if (start_index !== stop_index) {
436                             var $start_column = self.$('.oe_kanban_groups_records .oe_kanban_column').eq(start_index);
437                             var $stop_column = self.$('.oe_kanban_groups_records .oe_kanban_column').eq(stop_index);
438                             var method = (start_index > stop_index) ? 'insertBefore' : 'insertAfter';
439                             $start_column[method]($stop_column);
440                             var tmp_group = self.groups.splice(start_index, 1)[0];
441                             self.groups.splice(stop_index, 0, tmp_group);
442                             var new_sequence = _.pluck(self.groups, 'value');
443                             (new instance.web.DataSet(self, self.group_by_field.relation)).resequence(new_sequence).done(function(r) {
444                                 if (r === false) {
445                                     console.error("Kanban: could not resequence model '%s'. Probably no 'sequence' field.", self.group_by_field.relation);
446                                 }
447                             });
448                         }
449                         self.$('.oe_kanban_record, .oe_kanban_quick_create').css({ visibility: 'visible' });
450                     }
451                 });
452             }
453         } else {
454             this.$el.find('.oe_kanban_draghandle').removeClass('oe_kanban_draghandle');
455         }
456         this.postprocess_m2m_tags();
457     },
458     on_record_moved : function(record, old_group, old_index, new_group, new_index) {
459         var self = this;
460         record.$el.find('[title]').tooltip('destroy');
461         $(old_group.$el).add(new_group.$el).find('.oe_kanban_aggregates, .oe_kanban_group_length').hide();
462         if (old_group === new_group) {
463             new_group.records.splice(old_index, 1);
464             new_group.records.splice(new_index, 0, record);
465             new_group.do_save_sequences();
466         } else {
467             old_group.records.splice(old_index, 1);
468             new_group.records.splice(new_index, 0, record);
469             record.group = new_group;
470             var data = {};
471             data[this.group_by] = new_group.value;
472             this.dataset.write(record.id, data, {}).done(function() {
473                 record.do_reload();
474                 new_group.do_save_sequences();
475                 if (new_group.state.folded) {
476                     new_group.do_action_toggle_fold();
477                     record.prependTo(new_group.$records.find('.oe_kanban_column_cards'));
478                 }
479             }).fail(function(error, evt) {
480                 evt.preventDefault();
481                 alert(_t("An error has occured while moving the record to this group: ") + error.data.message);
482                 self.do_reload(); // TODO: use draggable + sortable in order to cancel the dragging when the rcp fails
483             });
484         }
485     },
486
487     do_show: function() {
488         if (this.$buttons) {
489             this.$buttons.show();
490         }
491         this.do_push_state({});
492         return this._super();
493     },
494     do_hide: function () {
495         if (this.$buttons) {
496             this.$buttons.hide();
497         }
498         return this._super();
499     },
500     open_record: function(id, editable) {
501         if (this.dataset.select_id(id)) {
502             this.do_switch_view('form', null, { mode: editable ? "edit" : undefined });
503         } else {
504             this.do_warn("Kanban: could not find id#" + id);
505         }
506     },
507     no_result: function() {
508         var self = this;
509         if (this.groups.group_by
510             || !this.options.action
511             || (!this.options.action.help && !this.options.action.get_empty_list_help)) {
512             return;
513         }
514         this.$el.css("position", "relative");
515         $(QWeb.render('KanbanView.nocontent', { content : this.options.action.get_empty_list_help || this.options.action.help})).insertBefore(this.$('table:first'));
516         this.$el.find('.oe_view_nocontent').click(function() {
517             self.$buttons.openerpBounce();
518         });
519     },
520     remove_no_result: function() {
521         this.$el.css("position", "");
522         this.$el.find('.oe_view_nocontent').remove();
523     },
524
525     /*
526     *  postprocessing of fields type many2many
527     *  make the rpc request for all ids/model and insert value inside .oe_tags fields
528     */
529     postprocess_m2m_tags: function() {
530         var self = this;
531         if (!this.many2manys.length) {
532             return;
533         }
534         var relations = {};
535         this.groups.forEach(function(group) {
536             group.records.forEach(function(record) {
537                 self.many2manys.forEach(function(name) {
538                     var field = record.record[name];
539                     var $el = record.$('.oe_form_field.oe_tags[name=' + name + ']').empty();
540                     if (!relations[field.relation]) {
541                         relations[field.relation] = { ids: [], elements: {}};
542                     }
543                     var rel = relations[field.relation];
544                     field.raw_value.forEach(function(id) {
545                         rel.ids.push(id);
546                         if (!rel.elements[id]) {
547                             rel.elements[id] = [];
548                         }
549                         rel.elements[id].push($el[0]);
550                     });
551                 });
552             });
553         });
554        _.each(relations, function(rel, rel_name) {
555             var dataset = new instance.web.DataSetSearch(self, rel_name, self.dataset.get_context());
556             dataset.name_get(_.uniq(rel.ids)).done(function(result) {
557                 result.forEach(function(nameget) {
558                     $(rel.elements[nameget[0]]).append('<span class="oe_tag">' + _.str.escapeHTML(nameget[1]) + '</span>');
559                 });
560             });
561         });
562     }
563 });
564
565
566 function get_class(name) {
567     return new instance.web.Registry({'tmp' : name}).get_object("tmp");
568 }
569
570 instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
571     template: 'KanbanView.group_header',
572     init: function (parent, records, group, dataset) {
573         var self = this;
574         this._super(parent);
575         this.$has_been_started = $.Deferred();
576         this.view = parent;
577         this.group = group;
578         this.dataset = dataset;
579         this.dataset_offset = 0;
580         this.aggregates = {};
581         this.value = this.title = null;
582         if (this.group) {
583             this.value = group.get('value');
584             this.title = group.get('value');
585             if (this.value instanceof Array) {
586                 this.title = this.value[1];
587                 this.value = this.value[0];
588             }
589             var field = this.view.group_by_field;
590             if (!_.isEmpty(field)) {
591                 try {
592                     this.title = instance.web.format_value(group.get('value'), field, false);
593                 } catch(e) {}
594             }
595             _.each(this.view.aggregates, function(value, key) {
596                 self.aggregates[value] = instance.web.format_value(group.get('aggregates')[key], {type: 'float'});
597             });
598         }
599
600         if (this.title === false) {
601             this.title = _t('Undefined');
602             this.undefined_title = true;
603         }
604         var key = this.view.group_by + '-' + this.value;
605         if (!this.view.state.groups[key]) {
606             this.view.state.groups[key] = {
607                 folded: group ? group.get('folded') : false
608             };
609         }
610         this.state = this.view.state.groups[key];
611         this.$records = null;
612
613         this.records = [];
614         this.$has_been_started.done(function() {
615             self.do_add_records(records);
616         });
617     },
618     start: function() {
619         var self = this;
620         if (! self.view.group_by) {
621             self.$el.addClass("oe_kanban_no_group");
622             self.quick = new (get_class(self.view.quick_create_class))(this, self.dataset, {}, false)
623                 .on('added', self, self.proxy('quick_created'));
624             self.quick.replace($(".oe_kanban_no_group_qc_placeholder"));
625         }
626         this.$records = $(QWeb.render('KanbanView.group_records_container', { widget : this}));
627         this.$records.insertBefore(this.view.$el.find('.oe_kanban_groups_records td:last'));
628
629         this.$el.on('click', '.oe_kanban_group_dropdown li a', function(ev) {
630             var fn = 'do_action_' + $(ev.target).data().action;
631             if (typeof(self[fn]) === 'function') {
632                 self[fn]($(ev.target));
633             }
634         });
635
636         this.$el.find('.oe_kanban_add').click(function () {
637             if (self.view.quick) {
638                 self.view.quick.trigger('close');
639             }
640             if (self.quick) {
641                 return false;
642             }
643             self.view.$el.find('.oe_view_nocontent').hide();
644             var ctx = {};
645             ctx['default_' + self.view.group_by] = self.value;
646             self.quick = new (get_class(self.view.quick_create_class))(this, self.dataset, ctx, true)
647                 .on('added', self, self.proxy('quick_created'))
648                 .on('close', self, function() {
649                     self.view.$el.find('.oe_view_nocontent').show();
650                     this.quick.destroy();
651                     delete self.view.quick;
652                     delete this.quick;
653                 });
654             self.quick.appendTo($(".oe_kanban_group_list_header", self.$records));
655             self.quick.focus();
656             self.view.quick = self.quick;
657         });
658         // Add bounce effect on image '+' of kanban header when click on empty space of kanban grouped column.
659         this.$records.on('click', '.oe_kanban_show_more', this.do_show_more);
660         if (this.state.folded) {
661             this.do_toggle_fold();
662         }
663         this.$el.data('widget', this);
664         this.$records.data('widget', this);
665         this.$has_been_started.resolve();
666         var add_btn = this.$el.find('.oe_kanban_add');
667         add_btn.tooltip({delay: { show: 500, hide:1000 }});
668         this.$records.find(".oe_kanban_column_cards").click(function (ev) {
669             if (ev.target == ev.currentTarget) {
670                 if (!self.state.folded) {
671                     add_btn.openerpBounce();
672                 }
673             }
674         });
675         this.is_started = true;
676         var def_tooltip = this.fetch_tooltip();
677         return $.when(def_tooltip);
678     },
679     fetch_tooltip: function() {
680         if (! this.group)
681             return;
682         var field_name = this.view.group_by;
683         var field = this.view.group_by_field;
684         var field_desc = null;
685         var recurse = function(node) {
686             if (node.tag === "field" && node.attrs.name === field_name) {
687                 field_desc = node;
688                 return;
689             }
690             _.each(node.children, function(child) {
691                 if (field_desc === null)
692                     recurse(child);
693             });
694         };
695         recurse(this.view.fields_view.arch);
696         if (! field_desc)
697             return;
698         var options = instance.web.py_eval(field_desc.attrs.options || '{}')
699         if (! options.tooltip_on_group_by)
700             return;
701
702         var self = this;
703         if (this.value) {
704             return (new instance.web.Model(field.relation)).query([options.tooltip_on_group_by])
705                     .filter([["id", "=", this.value]]).first().then(function(res) {
706                 self.tooltip = res[options.tooltip_on_group_by];
707                 self.$(".oe_kanban_group_title_text").attr("title", self.tooltip || self.title || "").tooltip();
708             });
709         }
710     },
711     compute_cards_auto_height: function() {
712         // oe_kanban_no_auto_height is an empty class used to disable this feature
713         if (!this.view.group_by) {
714             var min_height = 0;
715             var els = [];
716             _.each(this.records, function(r) {
717                 var $e = r.$el.children(':first:not(.oe_kanban_no_auto_height)').css('min-height', 0);
718                 if ($e.length) {
719                     els.push($e[0]);
720                     min_height = Math.max(min_height, $e.outerHeight());
721                 }
722             });
723             $(els).css('min-height', min_height);
724         }
725     },
726     destroy: function() {
727         this._super();
728         if (this.$records) {
729             this.$records.remove();
730         }
731     },
732     do_show_more: function(evt) {
733         var self = this;
734         var ids = self.view.dataset.ids.splice(0);
735         return this.dataset.read_slice(this.view.fields_keys.concat(['__last_update']), {
736             'limit': self.view.limit,
737             'offset': self.dataset_offset += self.view.limit
738         }).then(function(records) {
739             self.view.dataset.ids = ids.concat(self.dataset.ids);
740             self.do_add_records(records);
741             self.compute_cards_auto_height();
742             self.view.postprocess_m2m_tags();
743             return records;
744         });
745     },
746     do_add_records: function(records, prepend) {
747         var self = this;
748         var $list_header = this.$records.find('.oe_kanban_group_list_header');
749         var $show_more = this.$records.find('.oe_kanban_show_more');
750         var $cards = this.$records.find('.oe_kanban_column_cards');
751
752         _.each(records, function(record) {
753             var rec = new instance.web_kanban.KanbanRecord(self, record);
754             if (!prepend) {
755                 rec.appendTo($cards);
756                 self.records.push(rec);
757             } else {
758                 rec.prependTo($cards);
759                 self.records.unshift(rec);
760             }
761         });
762         if ($show_more.length) {
763             var size = this.dataset.size();
764             $show_more.toggle(this.records.length < size).find('.oe_kanban_remaining').text(size - this.records.length);
765         }
766     },
767     remove_record: function(id, remove_from_dataset) {
768         for (var i = 0; i < this.records.length; i++) {
769             if (this.records[i]['id'] === id) {
770                 this.records.splice(i, 1);
771                 i--;
772             }
773         }
774     },
775     do_toggle_fold: function(compute_width) {
776         this.$el.add(this.$records).toggleClass('oe_kanban_group_folded');
777         this.state.folded = this.$el.is('.oe_kanban_group_folded');
778         this.$("ul.oe_kanban_group_dropdown li a[data-action=toggle_fold]").text((this.state.folded) ? _t("Unfold") : _t("Fold"));
779     },
780     do_action_toggle_fold: function() {
781         this.do_toggle_fold();
782     },
783     do_action_edit: function() {
784         var self = this;
785         self.do_action({
786             res_id: this.value,
787             name: _t("Edit column"),
788             res_model: self.view.group_by_field.relation,
789             views: [[false, 'form']],
790             type: 'ir.actions.act_window',
791             target: "new",
792             flags: {
793                 action_buttons: true,
794             }
795         });
796         var am = instance.webclient.action_manager;
797         var form = am.dialog_widget.views.form.controller;
798         form.on("on_button_cancel", am.dialog, function() { return am.dialog.$dialog_box.modal('hide'); });
799         form.on('record_saved', self, function() {
800             am.dialog.$dialog_box.modal('hide');
801             self.view.do_reload();
802         });
803     },
804     do_action_delete: function() {
805         var self = this;
806         if (confirm(_t("Are you sure to remove this column ?"))) {
807             (new instance.web.DataSet(self, self.view.group_by_field.relation)).unlink([self.value]).done(function(r) {
808                 self.view.do_reload();
809             });
810         }
811     },
812     do_save_sequences: function() {
813         var self = this;
814         if (_.indexOf(this.view.fields_keys, 'sequence') > -1) {
815             var new_sequence = _.pluck(this.records, 'id');
816             self.view.dataset.resequence(new_sequence);
817         }
818     },
819     /**
820      * Handles a newly created record
821      *
822      * @param {id} id of the newly created record
823      */
824     quick_created: function (record) {
825         var id = record, self = this;
826         self.view.remove_no_result();
827         self.trigger("add_record");
828         this.dataset.read_ids([id], this.view.fields_keys)
829             .done(function (records) {
830                 self.view.dataset.ids.push(id);
831                 self.do_add_records(records, true);
832             });
833     },
834     highlight: function(show){
835         if(show){
836             this.$el.addClass('oe_kanban_column_higlight');
837             this.$records.addClass('oe_kanban_column_higlight');
838         }else{
839             this.$el.removeClass('oe_kanban_column_higlight');
840             this.$records.removeClass('oe_kanban_column_higlight');
841         }
842     }
843 });
844
845 instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
846     template: 'KanbanView.record',
847     init: function (parent, record) {
848         this._super(parent);
849         this.group = parent;
850         this.view = parent.view;
851         this.id = null;
852         this.set_record(record);
853         if (!this.view.state.records[this.id]) {
854             this.view.state.records[this.id] = {
855                 folded: false
856             };
857         }
858         this.state = this.view.state.records[this.id];
859         this.fields = {};
860     },
861     set_record: function(record) {
862         var self = this;
863         this.id = record.id;
864         this.values = {};
865         _.each(record, function(v, k) {
866             self.values[k] = {
867                 value: v
868             };
869         });
870         this.record = this.transform_record(record);
871     },
872     start: function() {
873         var self = this;
874         this._super();
875         this.init_content();
876     },
877     init_content: function() {
878         var self = this;
879         self.sub_widgets = [];
880         this.$("[data-field_id]").each(function() {
881             self.add_widget($(this));
882         });
883         this.$el.data('widget', this);
884         this.bind_events();
885     },
886     transform_record: function(record) {
887         var self = this,
888             new_record = {};
889         _.each(record, function(value, name) {
890             var r = _.clone(self.view.fields_view.fields[name] || {});
891             if ((r.type === 'date' || r.type === 'datetime') && value) {
892                 r.raw_value = instance.web.auto_str_to_date(value);
893             } else {
894                 r.raw_value = value;
895             }
896             r.value = instance.web.format_value(value, r);
897             new_record[name] = r;
898         });
899         return new_record;
900     },
901     renderElement: function() {
902         this.qweb_context = {
903             instance: instance,
904             record: this.record,
905             widget: this,
906             read_only_mode: this.view.options.read_only_mode,
907         };
908         for (var p in this) {
909             if (_.str.startsWith(p, 'kanban_')) {
910                 this.qweb_context[p] = _.bind(this[p], this);
911             }
912         }
913         var $el = instance.web.qweb.render(this.template, {
914             'widget': this,
915             'content': this.view.qweb.render('kanban-box', this.qweb_context)
916         });
917         this.replaceElement($el);
918         this.replace_fields();
919     },
920     replace_fields: function() {
921         var self = this;
922         this.$("field").each(function() {
923             var $field = $(this);
924             var $nfield = $("<span></span");
925             var id = _.uniqueId("kanbanfield");
926             self.fields[id] = $field;
927             $nfield.attr("data-field_id", id);
928             $field.replaceWith($nfield);
929         });
930     },
931     add_widget: function($node) {
932         var $orig = this.fields[$node.data("field_id")];
933         var field = this.record[$orig.attr("name")];
934         var type = field.type;
935         type = $orig.attr("widget") ? $orig.attr("widget") : type;
936         var obj = instance.web_kanban.fields_registry.get_object(type);
937         var widget = new obj(this, field, $orig);
938         this.sub_widgets.push(widget);
939         widget.replace($node);
940     },
941     bind_events: function() {
942         var self = this;
943         this.setup_color_picker();
944         this.$el.find('[title]').each(function(){
945             $(this).tooltip({
946                 delay: { show: 500, hide: 0},
947                 title: function() {
948                     var template = $(this).attr('tooltip');
949                     if (!self.view.qweb.has_template(template)) {
950                         return false;
951                     }
952                     return self.view.qweb.render(template, self.qweb_context);
953                 },
954             });
955         });
956
957         // If no draghandle is found, make the whole card as draghandle (provided one can edit)
958         if (!this.$el.find('.oe_kanban_draghandle').length) {
959             this.$el.children(':first')
960                 .toggleClass('oe_kanban_draghandle', this.view.is_action_enabled('edit'));
961         }
962
963         this.$el.find('.oe_kanban_action').click(function(ev) {
964             ev.preventDefault();
965             var $action = $(this),
966                 type = $action.data('type') || 'button',
967                 method = 'do_action_' + (type === 'action' ? 'object' : type);
968             if ((type === 'edit' || type === 'delete') && ! self.view.is_action_enabled(type)) {
969                 self.view.open_record(self.id, true);
970             } else if (_.str.startsWith(type, 'switch_')) {
971                 self.view.do_switch_view(type.substr(7));
972             } else if (typeof self[method] === 'function') {
973                 self[method]($action);
974             } else {
975                 self.do_warn("Kanban: no action for type : " + type);
976             }
977         });
978
979         if (this.$el.find('.oe_kanban_global_click,.oe_kanban_global_click_edit').length) {
980             this.$el.on('click', function(ev) {
981                 if (!ev.isTrigger && !$._data(ev.target, 'events')) {
982                     var trigger = true;
983                     var elem = ev.target;
984                     var ischild = true;
985                     var children = [];
986                     while (elem) {
987                         var events = $._data(elem, 'events');
988                         if (elem == ev.currentTarget) {
989                             ischild = false;
990                         }
991                         if (ischild) {
992                             children.push(elem);
993                             if (events && events.click) {
994                                 // do not trigger global click if one child has a click event registered
995                                 trigger = false;
996                             }
997                         }
998                         if (trigger && events && events.click) {
999                             _.each(events.click, function(click_event) {
1000                                 if (click_event.selector) {
1001                                     // For each parent of original target, check if a
1002                                     // delegated click is bound to any previously found children
1003                                     _.each(children, function(child) {
1004                                         if ($(child).is(click_event.selector)) {
1005                                             trigger = false;
1006                                         }
1007                                     });
1008                                 }
1009                             });
1010                         }
1011                         elem = elem.parentElement;
1012                     }
1013                     if (trigger) {
1014                         self.on_card_clicked(ev);
1015                     }
1016                 }
1017             });
1018         }
1019     },
1020     /* actions when user click on the block with a specific class
1021      *  open on normal view : oe_kanban_global_click
1022      *  open on form/edit view : oe_kanban_global_click_edit
1023      */
1024     on_card_clicked: function(ev) {
1025         if(this.$el.find('.oe_kanban_global_click_edit').size()>0)
1026             this.do_action_edit();
1027         else
1028             this.do_action_open();
1029     },
1030     setup_color_picker: function() {
1031         var self = this;
1032         var $el = this.$el.find('ul.oe_kanban_colorpicker');
1033         if ($el.length) {
1034             $el.html(QWeb.render('KanbanColorPicker', {
1035                 widget: this
1036             }));
1037             $el.on('click', 'a', function(ev) {
1038                 ev.preventDefault();
1039                 var color_field = $(this).parents('.oe_kanban_colorpicker').first().data('field') || 'color';
1040                 var data = {};
1041                 data[color_field] = $(this).data('color');
1042                 self.view.dataset.write(self.id, data, {}).done(function() {
1043                     self.record[color_field] = $(this).data('color');
1044                     self.do_reload();
1045                 });
1046             });
1047         }
1048     },
1049     do_action_delete: function($action) {
1050         var self = this;
1051         function do_it() {
1052             return $.when(self.view.dataset.unlink([self.id])).done(function() {
1053                 self.group.remove_record(self.id);
1054                 self.destroy();
1055             });
1056         }
1057         if (this.view.options.confirm_on_delete) {
1058             if (confirm(_t("Are you sure you want to delete this record ?"))) {
1059                 return do_it();
1060             }
1061         } else
1062             return do_it();
1063     },
1064     do_action_edit: function($action) {
1065         this.view.open_record(this.id, true);
1066     },
1067     do_action_open: function($action) {
1068         this.view.open_record(this.id);
1069     },
1070     do_action_object: function ($action) {
1071         var button_attrs = $action.data();
1072         this.view.do_execute_action(button_attrs, this.view.dataset, this.id, this.do_reload);
1073     },
1074     do_reload: function() {
1075         var self = this;
1076         this.view.dataset.read_ids([this.id], this.view.fields_keys.concat(['__last_update'])).done(function(records) {
1077              _.each(self.sub_widgets, function(el) {
1078                  el.destroy();
1079              });
1080              self.sub_widgets = [];
1081             if (records.length) {
1082                 self.set_record(records[0]);
1083                 self.renderElement();
1084                 self.init_content();
1085                 self.group.compute_cards_auto_height();
1086                 self.view.postprocess_m2m_tags();
1087             } else {
1088                 self.destroy();
1089             }
1090         });
1091     },
1092     kanban_getcolor: function(variable) {
1093         var index = 0;
1094         switch (typeof(variable)) {
1095             case 'string':
1096                 for (var i=0, ii=variable.length; i<ii; i++) {
1097                     index += variable.charCodeAt(i);
1098                 }
1099                 break;
1100             case 'number':
1101                 index = Math.round(variable);
1102                 break;
1103             default:
1104                 return '';
1105         }
1106         var color = (index % this.view.number_of_color_schemes);
1107         return color;
1108     },
1109     kanban_color: function(variable) {
1110         var color = this.kanban_getcolor(variable);
1111         return color === '' ? '' : 'oe_kanban_color_' + color;
1112     },
1113     kanban_image: function(model, field, id, cache, options) {
1114         options = options || {};
1115         var url;
1116         if (this.record[field] && this.record[field].value && !instance.web.form.is_bin_size(this.record[field].value)) {
1117             url = 'data:image/png;base64,' + this.record[field].value;
1118         } else if (this.record[field] && ! this.record[field].value) {
1119             url = "/web/static/src/img/placeholder.png";
1120         } else {
1121             id = JSON.stringify(id);
1122             if (options.preview_image)
1123                 field = options.preview_image;
1124             url = this.session.url('/web/binary/image', {model: model, field: field, id: id});
1125             if (cache !== undefined) {
1126                 // Set the cache duration in seconds.
1127                 url += '&cache=' + parseInt(cache, 10);
1128             }
1129         }
1130         return url;
1131     },
1132     kanban_text_ellipsis: function(s, size) {
1133         size = size || 160;
1134         if (!s) {
1135             return '';
1136         } else if (s.length <= size) {
1137             return s;
1138         } else {
1139             return s.substr(0, size) + '...';
1140         }
1141     },
1142     kanban_compute_domain: function(domain) {
1143         return instance.web.form.compute_domain(domain, this.values);
1144     }
1145 });
1146
1147 /**
1148  * Quick creation view.
1149  *
1150  * Triggers a single event "added" with a single parameter "name", which is the
1151  * name entered by the user
1152  *
1153  * @class
1154  * @type {*}
1155  */
1156 instance.web_kanban.QuickCreate = instance.web.Widget.extend({
1157     template: 'KanbanView.quick_create',
1158
1159     /**
1160      * close_btn: If true, the widget will display a "Close" button able to trigger
1161      * a "close" event.
1162      */
1163     init: function(parent, dataset, context, buttons) {
1164         this._super(parent);
1165         this._dataset = dataset;
1166         this._buttons = buttons || false;
1167         this._context = context || {};
1168     },
1169     start: function () {
1170         var self = this;
1171         self.$input = this.$el.find('input');
1172         self.$input.keyup(function(event){
1173             if(event.keyCode == 13){
1174                 self.quick_add();
1175             }
1176         });
1177         $(".oe_kanban_quick_create").focusout(function (e) {
1178             var val = self.$el.find('input').val();
1179             if (/^\s*$/.test(val)) { self.trigger('close'); }
1180             e.stopImmediatePropagation();
1181         });
1182         $(".oe_kanban_quick_create_add", this.$el).click(function () {
1183             self.quick_add();
1184             self.focus();
1185         });
1186         $(".oe_kanban_quick_create_close", this.$el).click(function (ev) {
1187             ev.preventDefault();
1188             self.trigger('close');
1189         });
1190         self.$input.keyup(function(e) {
1191             if (e.keyCode == 27 && self._buttons) {
1192                 self.trigger('close');
1193             }
1194         });
1195     },
1196     focus: function() {
1197         this.$el.find('input').focus();
1198     },
1199     /**
1200      * Handles user event from nested quick creation view
1201      */
1202     quick_add: function () {
1203         var self = this;
1204         var val = this.$input.val();
1205         if (/^\s*$/.test(val)) { this.$el.remove(); return; }
1206         this._dataset.call(
1207             'name_create', [val, new instance.web.CompoundContext(
1208                     this._dataset.get_context(), this._context)])
1209             .then(function(record) {
1210                 self.$input.val("");
1211                 self.trigger('added', record[0]);
1212             }, function(error, event) {
1213                 event.preventDefault();
1214                 return self.slow_create();
1215             });
1216     },
1217     slow_create: function() {
1218         var self = this;
1219         var pop = new instance.web.form.SelectCreatePopup(this);
1220         pop.select_element(
1221             self._dataset.model,
1222             {
1223                 title: _t("Create: ") + (this.string || this.name),
1224                 initial_view: "form",
1225                 disable_multiple_selection: true
1226             },
1227             [],
1228             {"default_name": self.$input.val()}
1229         );
1230         pop.on("elements_selected", self, function(element_ids) {
1231             self.$input.val("");
1232             self.trigger('added', element_ids[0]);
1233         });
1234     }
1235 });
1236
1237 /**
1238  * Interface to be implemented by kanban fields.
1239  *
1240  */
1241 instance.web_kanban.FieldInterface = {
1242     /**
1243         Constructor.
1244         - parent: The widget's parent.
1245         - field: A dictionary giving details about the field, including the current field's value in the
1246             raw_value field.
1247         - $node: The field <field> tag as it appears in the view, encapsulated in a jQuery object.
1248     */
1249     init: function(parent, field, $node) {},
1250 };
1251
1252 /**
1253  * Abstract class for classes implementing FieldInterface.
1254  *
1255  * Properties:
1256  *     - value: useful property to hold the value of the field. By default, the constructor
1257  *     sets value property.
1258  *
1259  */
1260 instance.web_kanban.AbstractField = instance.web.Widget.extend(instance.web_kanban.FieldInterface, {
1261     /**
1262         Constructor that saves the field and $node parameters and sets the "value" property.
1263     */
1264     init: function(parent, field, $node) {
1265         this._super(parent);
1266         this.field = field;
1267         this.$node = $node;
1268         this.options = instance.web.py_eval(this.$node.attr("options") || '{}');
1269         this.set("value", field.raw_value);
1270     },
1271 });
1272
1273 instance.web_kanban.Priority = instance.web_kanban.AbstractField.extend({
1274     init: function(parent, field, $node) {
1275         this._super.apply(this, arguments);
1276         this.name = $node.attr('name')
1277         this.parent = parent;
1278     },
1279     prepare_priority: function() {
1280         var self = this;
1281         var selection = this.field.selection || [];
1282         var init_value = selection && selection[0][0] || 0;
1283         var data = _.map(selection.slice(1), function(element, index) {
1284             var value = {
1285                 'value': element[0],
1286                 'name': element[1],
1287                 'click_value': element[0],
1288             }
1289             if (index == 0 && self.get('value') == element[0]) {
1290                 value['click_value'] = init_value;
1291             }
1292             return value;
1293         });
1294         return data;
1295     },
1296     renderElement: function() {
1297         var self = this;
1298         this.record_id = self.parent.id;
1299         this.priorities = self.prepare_priority();
1300         this.$el = $(QWeb.render("Priority", {'widget': this}));
1301         this.$el.find('li').click(self.do_action.bind(self));
1302     },
1303     do_action: function(e) {
1304         var self = this;
1305         var li = $(e.target).closest( "li" );
1306         if (li.length) {
1307             var value = {};
1308             value[self.name] = String(li.data('value'));
1309             return self.parent.view.dataset._model.call('write', [[self.record_id], value, self.parent.view.dataset.get_context()]).done(self.reload_record.bind(self.parent));
1310         }
1311     },
1312     reload_record: function() {
1313         this.do_reload();
1314     },
1315 });
1316
1317 instance.web_kanban.KanbanSelection = instance.web_kanban.AbstractField.extend({
1318     init: function(parent, field, $node) {
1319         this._super.apply(this, arguments);
1320         this.name = $node.attr('name')
1321         this.parent = parent;
1322     },
1323     prepare_dropdown_selection: function() {
1324         var data = [];
1325         _.map(this.field.selection || [], function(res) {
1326             var value = {
1327                 'name': res[0],
1328                 'tooltip': res[1],
1329                 'state_name': res[1],
1330             }
1331             if (res[0] == 'normal') { value['state_class'] = 'oe_kanban_status'; }
1332             else if (res[0] == 'done') { value['state_class'] = 'oe_kanban_status oe_kanban_status_green'; }
1333             else { value['state_class'] = 'oe_kanban_status oe_kanban_status_red'; }
1334             data.push(value);
1335         });
1336         return data;
1337     },
1338     renderElement: function() {
1339         var self = this;
1340         this.record_id = self.parent.id;
1341         this.states = self.prepare_dropdown_selection();;
1342         this.$el = $(QWeb.render("KanbanSelection", {'widget': self}));
1343         this.$el.find('li').click(self.do_action.bind(self));
1344     },
1345     do_action: function(e) {
1346         var self = this;
1347         var li = $(e.target).closest( "li" );
1348         if (li.length) {
1349             var value = {};
1350             value[self.name] = String(li.data('value'));
1351             return self.parent.view.dataset._model.call('write', [[self.record_id], value, self.parent.view.dataset.get_context()]).done(self.reload_record.bind(self.parent));
1352         }
1353     },
1354     reload_record: function() {
1355         this.do_reload();
1356     },
1357 });
1358
1359 instance.web_kanban.fields_registry = new instance.web.Registry({});
1360 instance.web_kanban.fields_registry.add('priority','instance.web_kanban.Priority');
1361 instance.web_kanban.fields_registry.add('kanban_state_selection','instance.web_kanban.KanbanSelection');
1362 };
1363
1364 // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: