diff options
| author | Raphael Collet <rco@openerp.com> | 2012-05-09 12:13:20 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2012-05-09 12:13:20 +0200 |
| commit | 8a4959cd290685109955677df2b75a40867d88d9 (patch) | |
| tree | f7255389b198d0a902af3c42863de21f5383548e /addons/project/static/src/js/project.js | |
| parent | e4fdf1b061b7cc859e3d257dcab504caf8e8ebf2 (diff) | |
| parent | 700061a30a4dea502d6e73f623d4704bdce0e8b0 (diff) | |
[MERGE] trunk-project-gallery-apa (project gallery view)
bzr revid: rco@openerp.com-20120509101320-rpprue0b12ss3laj
Diffstat (limited to 'addons/project/static/src/js/project.js')
| -rw-r--r-- | addons/project/static/src/js/project.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/project/static/src/js/project.js b/addons/project/static/src/js/project.js new file mode 100644 index 00000000000..09a7c9eb256 --- /dev/null +++ b/addons/project/static/src/js/project.js @@ -0,0 +1,48 @@ +openerp.project = function(openerp) { + openerp.web_kanban.ProjectKanban = openerp.web_kanban.KanbanRecord.include({ + bind_events: function() { + var self = this; + self._super(); + if(this.view.dataset.model == 'project.project') { + + /*set avatar title for members. + In many2many fields, returns only list of ids. + we can implement return value of m2m fields like [(1,"Adminstration"),...]. + */ + _.each($(this.$element).find('.project_avatar'),function(avatar){ + var dataset = new openerp.web.DataSetSearch(this, 'res.users', self.session.context, [['id','=',avatar.id]]); + dataset.read_slice(['name']).then(function(result){ + avatar.setAttribute("title",result[0].name) + }); + }); + + // set sequence like Tasks,Issues,Timesheets and Phases + var my_list = $("#list a") + my_list.sort(function (a, b) { + var aValue = parseInt(a.id); + var bValue = parseInt(b.id); + return aValue == bValue ? 0 : aValue < bValue ? -1 : 1; + }); + $('#list').replaceWith(my_list); + + // when vignette is clicked, it opens the first action in sequence + if (my_list.length != 0) { + var click_button = $(this.$element).find('.click_button') + click_button.attr('data-name', my_list[0].getAttribute('data-name')); + click_button.attr('data-type', "action"); + } + + /* set background color. + we can do other way to implement new widget. + because we need to rpc call for that. + */ + this.$element.find('.bgcolor').click(function(){ + var color = parseInt($(this).find('span').attr('class').split(' ')[0].substring(16)) + var color_class = $(this).find('span').attr('class').split(' ')[0] + $(this).closest('#oe_project_kanban_vignette').removeClass().addClass(color_class + ' oe_project_kanban_vignette'); + self.view.dataset.write(parseInt(this.id), {color:color}); + }); + } + } + }); +} |
