[IMP] refactor the handling of many2many tags in issues and tasks kanban views
bzr revid: abo@openerp.com-20120712113326-a0p30oij7g67gmtj
This commit is contained in:
parent
7ccb648390
commit
4af50da7dc
|
@ -42,8 +42,5 @@ portal are installed.
|
||||||
'css': [
|
'css': [
|
||||||
'static/src/css/portal_project_issue.css',
|
'static/src/css/portal_project_issue.css',
|
||||||
],
|
],
|
||||||
'js': [
|
|
||||||
'static/src/js/portal_project_issue.js',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
<div class="oe_left">
|
<div class="oe_left">
|
||||||
<t t-foreach="record.categ_ids.raw_value" t-as="categ_id">
|
<t t-foreach="record.categ_ids.raw_value" t-as="categ_id">
|
||||||
<span class="oe_form_field_many2manytags_box" t-att-data-categ_id="categ_id"></span>
|
<span class="oe_form_field_many2manytags_box" t-att-data-categ_id="categ_id"></span>
|
||||||
</t
|
</t>
|
||||||
> </div>
|
</div>
|
||||||
<div class="oe_right">
|
<div class="oe_right">
|
||||||
Creation: <field name="create_date"/>
|
Creation: <field name="create_date"/>
|
||||||
<span class="oe_kanban_highlight">
|
<span class="oe_kanban_highlight">
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
openerp.portal_project_issue = function(openerp) {
|
|
||||||
openerp.web_kanban.KanbanView.include({
|
|
||||||
on_groups_started: function() {
|
|
||||||
var self = this;
|
|
||||||
self._super.apply(this, arguments);
|
|
||||||
|
|
||||||
if (this.dataset.model === 'project.issue' || this.dataset.model === 'project.task') {
|
|
||||||
/*
|
|
||||||
* Set proper names to project categories.
|
|
||||||
* In kanban views, many2many fields only return a list of ids.
|
|
||||||
* Therefore, we have to fetch the matching data by ourselves.
|
|
||||||
*/
|
|
||||||
var categ_ids = [];
|
|
||||||
|
|
||||||
// Collect categories ids
|
|
||||||
this.$element.find('.oe_form_field_many2manytags_box').each(function() {
|
|
||||||
categ_ids.push($(this).data('categ_id'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Find their matching names
|
|
||||||
var dataset = new openerp.web.DataSetSearch(this, 'project.category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]);
|
|
||||||
dataset.read_slice(['id', 'name']).then(function(result) {
|
|
||||||
_.each(result, function(v, k) {
|
|
||||||
// Set the proper value in the DOM and display the element
|
|
||||||
self.$element.find('.oe_form_field_many2manytags_box[data-categ_id=' + v.id + ']').text(v.name).toggle();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,25 +1,61 @@
|
||||||
openerp.project = function(openerp) {
|
openerp.project = function(openerp) {
|
||||||
openerp.web_kanban.KanbanView.include({
|
openerp.web_kanban.KanbanView.include({
|
||||||
on_groups_started: function() {
|
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"),...].
|
||||||
|
*/
|
||||||
var self = this;
|
var self = this;
|
||||||
self._super.apply(this, arguments);
|
var members_ids = [];
|
||||||
if (this.dataset.model === 'project.project') {
|
|
||||||
/* Set avatar title for members.
|
// Collect members ids
|
||||||
In many2many fields, returns only list of ids.
|
self.$element.find('.oe_kanban_project_avatars img').each(function() {
|
||||||
we can implement return value of m2m fields like [(1,"Adminstration"),...].
|
members_ids.push($(this).data('member_id'));
|
||||||
*/
|
});
|
||||||
var members_ids = [];
|
|
||||||
this.$element.find('.oe_kanban_project_avatars img').each(function() {
|
// Find their matching names
|
||||||
members_ids.push($(this).data('member_id'));
|
var dataset = new openerp.web.DataSetSearch(self, 'res.users', self.session.context, [['id', 'in', _.uniq(members_ids)]]);
|
||||||
});
|
dataset.read_slice(['id', 'name']).then(function(result) {
|
||||||
var dataset = new openerp.web.DataSetSearch(this, 'res.users', self.session.context, [['id', 'in', _.uniq(members_ids)]]);
|
_.each(result, function(v, k) {
|
||||||
dataset.read_slice(['id', 'name']).then(function(result) {
|
// Set the proper value in the DOM
|
||||||
_.each(result, function(v, k) {
|
self.$element.find('.oe_kanban_project_avatars img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
|
||||||
self.$element.find('.oe_kanban_project_avatars img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
|
offset: 10
|
||||||
offset: 10
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
project_display_categ_names: function() {
|
||||||
|
/*
|
||||||
|
* Set proper names to project categories.
|
||||||
|
* In kanban views, many2many fields only return a list of ids.
|
||||||
|
* Therefore, we have to fetch the matching data by ourselves.
|
||||||
|
*/
|
||||||
|
var self = this;
|
||||||
|
var categ_ids = [];
|
||||||
|
|
||||||
|
// Collect categories ids
|
||||||
|
self.$element.find('.oe_form_field_many2manytags_box').each(function() {
|
||||||
|
categ_ids.push($(this).data('categ_id'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find their matching names
|
||||||
|
var dataset = new openerp.web.DataSetSearch(self, 'project.category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]);
|
||||||
|
dataset.read_slice(['id', 'name']).then(function(result) {
|
||||||
|
_.each(result, function(v, k) {
|
||||||
|
// Set the proper value in the DOM and display the element
|
||||||
|
self.$element.find('.oe_form_field_many2manytags_box[data-categ_id=' + v.id + ']').text(v.name).toggle();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
on_groups_started: function() {
|
||||||
|
var self = this;
|
||||||
|
self._super.apply(self, arguments);
|
||||||
|
|
||||||
|
if (self.dataset.model === 'project.project') {
|
||||||
|
self.project_display_members_names();
|
||||||
|
} else if (self.dataset.model === 'project.task') {
|
||||||
|
self.project_display_categ_names();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,7 +38,7 @@ and decide on their status as they evolve.
|
||||||
'website': 'http://www.openerp.com',
|
'website': 'http://www.openerp.com',
|
||||||
'images': ['images/issue_analysis.jpeg','images/project_issue.jpeg'],
|
'images': ['images/issue_analysis.jpeg','images/project_issue.jpeg'],
|
||||||
'depends': [
|
'depends': [
|
||||||
'base_status',
|
'base_status',
|
||||||
'crm',
|
'crm',
|
||||||
'project',
|
'project',
|
||||||
],
|
],
|
||||||
|
@ -65,6 +65,9 @@ and decide on their status as they evolve.
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
'application': True,
|
'application': True,
|
||||||
'certificate' : '001236490750848623845',
|
'certificate' : '001236490750848623845',
|
||||||
|
'js': [
|
||||||
|
'static/src/js/project_issue.js',
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
openerp.portal_project_issue = function(openerp) {
|
||||||
|
openerp.web_kanban.KanbanView.include({
|
||||||
|
on_groups_started: function() {
|
||||||
|
var self = this;
|
||||||
|
self._super.apply(this, arguments);
|
||||||
|
|
||||||
|
if (self.dataset.model === 'project.issue') {
|
||||||
|
// Load project's categories names from m2m field
|
||||||
|
self.project_display_categ_names();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue