2012-04-04 08:41:44 +00:00
|
|
|
openerp.project = function(openerp) {
|
2012-05-22 15:58:15 +00:00
|
|
|
openerp.web_kanban.KanbanView.include({
|
2012-07-12 11:33:26 +00:00
|
|
|
project_display_members_names: function() {
|
|
|
|
/*
|
|
|
|
* Set avatar title for members.
|
|
|
|
* In kanban views, many2many fields only return a list of ids.
|
|
|
|
* We can implement return value of m2m fields like [(1,"Adminstration"),...].
|
|
|
|
*/
|
2012-05-09 06:55:22 +00:00
|
|
|
var self = this;
|
2012-07-12 11:33:26 +00:00
|
|
|
var members_ids = [];
|
|
|
|
|
|
|
|
// Collect members ids
|
2012-08-24 18:27:43 +00:00
|
|
|
self.$el.find('img[data-member_id]').each(function() {
|
2012-07-12 11:33:26 +00:00
|
|
|
members_ids.push($(this).data('member_id'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Find their matching names
|
|
|
|
var dataset = new openerp.web.DataSetSearch(self, 'res.users', self.session.context, [['id', 'in', _.uniq(members_ids)]]);
|
2012-10-31 10:31:48 +00:00
|
|
|
dataset.read_slice(['id', 'name']).done(function(result) {
|
2012-07-12 11:33:26 +00:00
|
|
|
_.each(result, function(v, k) {
|
|
|
|
// Set the proper value in the DOM
|
2012-08-24 18:27:43 +00:00
|
|
|
self.$el.find('img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
|
2012-07-12 11:33:26 +00:00
|
|
|
offset: 10
|
2012-05-22 15:58:15 +00:00
|
|
|
});
|
2012-04-11 05:43:56 +00:00
|
|
|
});
|
2012-07-12 11:33:26 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
on_groups_started: function() {
|
|
|
|
var self = this;
|
|
|
|
self._super.apply(self, arguments);
|
|
|
|
|
|
|
|
if (self.dataset.model === 'project.project') {
|
|
|
|
self.project_display_members_names();
|
2012-05-09 06:55:22 +00:00
|
|
|
}
|
2012-10-31 05:09:05 +00:00
|
|
|
},
|
|
|
|
on_record_moved: function(record, old_group, old_index, new_group, new_index){
|
|
|
|
var self = this;
|
2012-10-31 05:47:41 +00:00
|
|
|
this._super.apply(this, arguments);
|
2012-10-31 05:09:05 +00:00
|
|
|
if(new_group.state.folded)
|
|
|
|
new_group.do_action_toggle_fold();
|
2012-04-04 08:41:44 +00:00
|
|
|
}
|
|
|
|
});
|
2012-05-24 16:07:52 +00:00
|
|
|
|
|
|
|
openerp.web_kanban.KanbanRecord.include({
|
|
|
|
on_card_clicked: function() {
|
|
|
|
if (this.view.dataset.model === 'project.project') {
|
|
|
|
this.$('.oe_kanban_project_list a').first().click();
|
|
|
|
} else {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
}
|
2012-10-29 06:15:39 +00:00
|
|
|
},
|
2012-05-24 16:07:52 +00:00
|
|
|
});
|
2012-05-21 13:09:14 +00:00
|
|
|
};
|