From 24edc5615ba7e20f465e4b1b8e11fcabb81fdb79 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 21 Mar 2013 12:01:52 +0100 Subject: [ADD] basic widget for goal list bzr revid: mat@openerp.com-20130321110152-0wa9b3uuyk2qvk0d --- addons/gamification/static/src/js/gamification.js | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 addons/gamification/static/src/js/gamification.js (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js new file mode 100644 index 00000000000..4c7e25980d9 --- /dev/null +++ b/addons/gamification/static/src/js/gamification.js @@ -0,0 +1,38 @@ +openerp.gamification = function(instance) { + console.log("Debug statement: file loaded"); + + instance.Side_bar = instance.mail.Widget.include( { + init: function (parent, action) { + console.log("Init function"); + var self = this; + this._super(parent, action); + this.deferred = $.Deferred(); + this.res_user = new instance.web.DataSetSearch(this, 'res.users'); + this.goals_info = {}; + console.log("init"); + }, + renderElement: function() { + var self = this; + this._super.apply(this, arguments); + console.log("Render!"); + self.render_template(self.$el.filter(".oe_user_sidebar"),'user_wall'); + self.get_goal_todo_info(); + }, + render_template: function(target,template) { + var self = this; + target.append(instance.web.qweb.render(template,{'widget': self})); + }, + get_goal_todo_info: function() { + var self = this; + var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { + self.goals_info['info'] = res + }); + $.when(goals_info).done(function() { + console.log(self.goals_info.info); + if(self.goals_info.info.length > 0){ + self.render_template(self.$el.find(".oe_gamification_goal"),'goal_list_to_do'); + } + }); + }, + }); +}; -- cgit v1.2.3 From f691d138103ec351be61855d226239d47054b7d4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Mar 2013 09:51:51 +0100 Subject: [IMP] skip plans with all goals finished bzr revid: mat@openerp.com-20130322085151-r6sse6383z6ya9by --- addons/gamification/static/src/js/gamification.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 4c7e25980d9..2820666d56d 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -22,6 +22,10 @@ openerp.gamification = function(instance) { var self = this; target.append(instance.web.qweb.render(template,{'widget': self})); }, + render_template_replace: function(target,template) { + var self = this; + target.html(instance.web.qweb.render(template,{'widget': self})); + }, get_goal_todo_info: function() { var self = this; var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { @@ -30,7 +34,7 @@ openerp.gamification = function(instance) { $.when(goals_info).done(function() { console.log(self.goals_info.info); if(self.goals_info.info.length > 0){ - self.render_template(self.$el.find(".oe_gamification_goal"),'goal_list_to_do'); + self.render_template_replace(self.$el.find(".oe_gamification_goal"),'goal_list_to_do'); } }); }, -- cgit v1.2.3 From 80541abdbf27d77014dec403d562f616408061c5 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Mar 2013 12:13:44 +0100 Subject: [IMP] update button with refresh bzr revid: mat@openerp.com-20130322111344-7qs3o2tvbx7h4qln --- addons/gamification/static/src/js/gamification.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 2820666d56d..667f856059e 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -3,18 +3,26 @@ openerp.gamification = function(instance) { instance.Side_bar = instance.mail.Widget.include( { init: function (parent, action) { - console.log("Init function"); var self = this; this._super(parent, action); this.deferred = $.Deferred(); this.res_user = new instance.web.DataSetSearch(this, 'res.users'); this.goals_info = {}; - console.log("init"); + }, + events: { + 'click a.oe_update_goal': function(event) { + var self = this; + var goal_id = parseInt(event.target.id); + console.log(goal_id); + var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]); + $.when(goal_updated).done(function() { + self.get_goal_todo_info(); + }); + } }, renderElement: function() { var self = this; this._super.apply(this, arguments); - console.log("Render!"); self.render_template(self.$el.filter(".oe_user_sidebar"),'user_wall'); self.get_goal_todo_info(); }, @@ -28,6 +36,7 @@ openerp.gamification = function(instance) { }, get_goal_todo_info: function() { var self = this; + console.log(this); var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { self.goals_info['info'] = res }); @@ -38,5 +47,13 @@ openerp.gamification = function(instance) { } }); }, + update_goal: function() { + console.log(this); + console.log(instance.Side_bar); + var goal_update = new instance.web.Model('gamification.goal').call('update', [[parseInt(this.id)]]); + $.when(goal_update).done(function() { + // $(".oe_user_sidebar").find(".oe_gamification_goal").html(instance.web.qweb.render('goal_list_to_do')); + }); + }, }); }; -- cgit v1.2.3 From 391947f7cc94c237d05f970872fdbec02f56fc65 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Mar 2013 16:18:03 +0100 Subject: [IMP] using sidebar and better javascript bzr revid: mat@openerp.com-20130322151803-nzb41s0mxvaidrel --- addons/gamification/static/src/js/gamification.js | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 667f856059e..5b503171337 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -1,7 +1,9 @@ openerp.gamification = function(instance) { console.log("Debug statement: file loaded"); + var QWeb = instance.web.qweb; - instance.Side_bar = instance.mail.Widget.include( { + instance.gamification.Sidebar = instance.web.Widget.extend({ + template: 'gamification.user_wall_sidebar', init: function (parent, action) { var self = this; this._super(parent, action); @@ -12,8 +14,7 @@ openerp.gamification = function(instance) { events: { 'click a.oe_update_goal': function(event) { var self = this; - var goal_id = parseInt(event.target.id); - console.log(goal_id); + var goal_id = parseInt(event.currentTarget.id); var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]); $.when(goal_updated).done(function() { self.get_goal_todo_info(); @@ -23,37 +24,46 @@ openerp.gamification = function(instance) { renderElement: function() { var self = this; this._super.apply(this, arguments); - self.render_template(self.$el.filter(".oe_user_sidebar"),'user_wall'); self.get_goal_todo_info(); }, render_template: function(target,template) { var self = this; - target.append(instance.web.qweb.render(template,{'widget': self})); + target.append(QWeb.render(template,{'widget': self})); }, render_template_replace: function(target,template) { var self = this; - target.html(instance.web.qweb.render(template,{'widget': self})); + target.html(QWeb.render(template,{'widget': self})); }, get_goal_todo_info: function() { var self = this; - console.log(this); var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { self.goals_info['info'] = res }); $.when(goals_info).done(function() { console.log(self.goals_info.info); if(self.goals_info.info.length > 0){ - self.render_template_replace(self.$el.find(".oe_gamification_goal"),'goal_list_to_do'); + self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); } }); }, update_goal: function() { - console.log(this); - console.log(instance.Side_bar); var goal_update = new instance.web.Model('gamification.goal').call('update', [[parseInt(this.id)]]); $.when(goal_update).done(function() { - // $(".oe_user_sidebar").find(".oe_gamification_goal").html(instance.web.qweb.render('goal_list_to_do')); + $(".oe_user_sidebar").find(".oe_gamification_goal").html(QWeb.render('gamification.goal_list_to_do')); }); }, }); + + instance.mail.Widget.include({ + init: function (parent, action) { + var self = this; + this._super(parent, action); + }, + start: function() { + this._super(); + var self = this; + var sidebar = new instance.gamification.Sidebar(self); + sidebar.appendTo($('.oe_mail_wall_aside')); + } + }); }; -- cgit v1.2.3 From 632a9d4bcbd89398e9d165422a35779902552039 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Mar 2013 17:05:20 +0100 Subject: [IMP] show description button bzr revid: mat@openerp.com-20130322160520-pq9eaoqtnsvwvj7d --- addons/gamification/static/src/js/gamification.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 5b503171337..485f18b67dd 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -19,7 +19,11 @@ openerp.gamification = function(instance) { $.when(goal_updated).done(function() { self.get_goal_todo_info(); }); - } + }, + 'click a.oe_show_description': function(event) { + var goal_id = parseInt(event.currentTarget.id); + this.$el.find('.oe_type_description_'+goal_id).toggle(10); + }, }, renderElement: function() { var self = this; @@ -43,15 +47,10 @@ openerp.gamification = function(instance) { console.log(self.goals_info.info); if(self.goals_info.info.length > 0){ self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); + self.$el.find('.oe_type_description').hide(); } }); }, - update_goal: function() { - var goal_update = new instance.web.Model('gamification.goal').call('update', [[parseInt(this.id)]]); - $.when(goal_update).done(function() { - $(".oe_user_sidebar").find(".oe_gamification_goal").html(QWeb.render('gamification.goal_list_to_do')); - }); - }, }); instance.mail.Widget.include({ -- cgit v1.2.3 From 02725e359daca7936b0b3a8109ecf1f16f98032b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Sun, 24 Mar 2013 14:46:58 +0100 Subject: [FIX] call correct method for cron bzr revid: mat@openerp.com-20130324134658-0kx6v1st048gkm1r --- addons/gamification/static/src/js/gamification.js | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 485f18b67dd..cf6542b3456 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -24,6 +24,34 @@ openerp.gamification = function(instance) { var goal_id = parseInt(event.currentTarget.id); this.$el.find('.oe_type_description_'+goal_id).toggle(10); }, + 'click a.oe_goal_action': function(event) { + var self = this; + var goal_id = parseInt(event.currentTarget.id); + var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]); + + console.log(goal_action); + // var action = { + // name : 'Complete Profile', + // type: 'ir.actions.act_window', + // res_model: 'res.users', + // views: [[false, 'form']], + // res_id : event.data.uid, + // target: 'new', + // flags : { action_buttons: true }, + // }; + // var action_manager = new instance.web.ActionManager(this); + // action_manager.do_action(action); + // var form = action_manager.dialog_widget.views.form.controller; + // form.on('load_record', self, function(){ + // form.fields[$(self).attr('id')].$el.find("input").focus() + // }) + // form.on("on_button_cancel", action_manager.dialog, action_manager.dialog.close); + // form.on('save', self, function() { + // action_manager.dialog.close(); + // location.reload(); + // }); + + } }, renderElement: function() { var self = this; -- cgit v1.2.3 From 8a04406a28fb8a3a4b49c04a6bb9609fd8b9260e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Sun, 24 Mar 2013 19:05:57 +0100 Subject: [IMP] action button (almost working) bzr revid: mat@openerp.com-20130324180557-ttos23t09uayh6zx --- addons/gamification/static/src/js/gamification.js | 31 +++++++---------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index cf6542b3456..d24e0b4159c 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -27,29 +27,16 @@ openerp.gamification = function(instance) { 'click a.oe_goal_action': function(event) { var self = this; var goal_id = parseInt(event.currentTarget.id); - var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]); + var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]).then(function(res) { + goal_action['action'] = res; + }); + $.when(goal_action).done(function() { + console.log(goal_action); + var action_manager = new instance.web.ActionManager(this); + action_manager.do_action(goal_action.action); - console.log(goal_action); - // var action = { - // name : 'Complete Profile', - // type: 'ir.actions.act_window', - // res_model: 'res.users', - // views: [[false, 'form']], - // res_id : event.data.uid, - // target: 'new', - // flags : { action_buttons: true }, - // }; - // var action_manager = new instance.web.ActionManager(this); - // action_manager.do_action(action); - // var form = action_manager.dialog_widget.views.form.controller; - // form.on('load_record', self, function(){ - // form.fields[$(self).attr('id')].$el.find("input").focus() - // }) - // form.on("on_button_cancel", action_manager.dialog, action_manager.dialog.close); - // form.on('save', self, function() { - // action_manager.dialog.close(); - // location.reload(); - // }); + //var form = action_manager.dialog_widget.views.form.controller; + }); } }, -- cgit v1.2.3 From 364612d0be52e6677a26f8a083d58b52d81c7f0a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 25 Mar 2013 16:39:53 +0100 Subject: [IMP] use board view for sidebar bzr revid: mat@openerp.com-20130325153953-zch12sfx62s5i6xc --- addons/gamification/static/src/js/gamification.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index d24e0b4159c..28323b29421 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -1,5 +1,4 @@ openerp.gamification = function(instance) { - console.log("Debug statement: file loaded"); var QWeb = instance.web.qweb; instance.gamification.Sidebar = instance.web.Widget.extend({ @@ -31,7 +30,6 @@ openerp.gamification = function(instance) { goal_action['action'] = res; }); $.when(goal_action).done(function() { - console.log(goal_action); var action_manager = new instance.web.ActionManager(this); action_manager.do_action(goal_action.action); -- cgit v1.2.3 From 0aa973b9f024ebefaa2f2ec9f47060e721a5c54a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 25 Mar 2013 17:15:27 +0100 Subject: [IMP] refresh button for plan bzr revid: mat@openerp.com-20130325161527-qes3lqpzevdmdsx6 --- addons/gamification/static/src/js/gamification.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 28323b29421..08b6155a4f1 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -19,6 +19,14 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }, + 'click a.oe_update_plan': function(event) { + var self = this; + var plan_id = parseInt(event.currentTarget.id); + var goals_updated = new instance.web.Model('gamification.goal.plan').call('quick_update', [plan_id]); + $.when(goals_updated).done(function() { + self.get_goal_todo_info(); + }); + }, 'click a.oe_show_description': function(event) { var goal_id = parseInt(event.currentTarget.id); this.$el.find('.oe_type_description_'+goal_id).toggle(10); @@ -35,8 +43,7 @@ openerp.gamification = function(instance) { //var form = action_manager.dialog_widget.views.form.controller; }); - - } + }, }, renderElement: function() { var self = this; -- cgit v1.2.3 From bfcf26bf19610e70b41954ff4e2c3818c1e53a77 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 25 Mar 2013 17:52:35 +0100 Subject: [IMP] use help to show goal description bzr revid: mat@openerp.com-20130325165235-q0wwyrdfrak5utkr --- addons/gamification/static/src/js/gamification.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 08b6155a4f1..01004d94edd 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -27,10 +27,10 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }, - 'click a.oe_show_description': function(event) { - var goal_id = parseInt(event.currentTarget.id); - this.$el.find('.oe_type_description_'+goal_id).toggle(10); - }, + // 'click a.oe_show_description': function(event) { + // var goal_id = parseInt(event.currentTarget.id); + // this.$el.find('.oe_type_description_'+goal_id).toggle(10); + // }, 'click a.oe_goal_action': function(event) { var self = this; var goal_id = parseInt(event.currentTarget.id); -- cgit v1.2.3 From 635df4028a8cf9d5185e31d21df67daf609506b3 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Mar 2013 16:45:53 +0100 Subject: [ADD] monetary field bzr revid: mat@openerp.com-20130326154553-t8cacle6s1oll4r9 --- addons/gamification/static/src/js/gamification.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 01004d94edd..62de4835842 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -64,13 +64,31 @@ openerp.gamification = function(instance) { self.goals_info['info'] = res }); $.when(goals_info).done(function() { - console.log(self.goals_info.info); if(self.goals_info.info.length > 0){ self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.$el.find('.oe_type_description').hide(); + self.render_money_fields(self.goals_info.info[0].currency); } }); }, + render_money_fields: function(currency_id) { + var self = this; + + self.dfm = new instance.web.form.DefaultFieldManager(self); + self.$el.find(".oe_goal_field_monetary").each(function() { + money_field = new instance.web.form.FieldMonetary(self.dfm, { + attrs: { + modifiers: '{"readonly": true}' + } + }); + money_field.set('currency', currency_id); + money_field.get_currency_info(); + money_field.set('value', parseInt($(this).text())); + console.log(money_field.get('value')); + money_field.replace($(this)); + console.log(money_field.$el.html()); + }); + } }); instance.mail.Widget.include({ -- cgit v1.2.3 From b08a2f2bbc8f615b778ec75e4b8f410626c52800 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 27 Mar 2013 11:50:40 +0100 Subject: [ADD] user defined action for goal update bzr revid: mat@openerp.com-20130327105040-ezlg1ml0xvoe5z58 --- addons/gamification/static/src/js/gamification.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 62de4835842..dfd8b2f607b 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -75,6 +75,7 @@ openerp.gamification = function(instance) { var self = this; self.dfm = new instance.web.form.DefaultFieldManager(self); + // Generate a FieldMonetary for each .oe_goal_field_monetary self.$el.find(".oe_goal_field_monetary").each(function() { money_field = new instance.web.form.FieldMonetary(self.dfm, { attrs: { @@ -84,9 +85,7 @@ openerp.gamification = function(instance) { money_field.set('currency', currency_id); money_field.get_currency_info(); money_field.set('value', parseInt($(this).text())); - console.log(money_field.get('value')); money_field.replace($(this)); - console.log(money_field.$el.html()); }); } }); -- cgit v1.2.3 From 84b2b3411ac27aafc15c55c0d6c0c76416375df4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Mar 2013 12:52:15 +0100 Subject: [IMP] render progressbar bzr revid: mat@openerp.com-20130329115215-bpm450x04kp0os9z --- addons/gamification/static/src/js/gamification.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index dfd8b2f607b..d415d35a890 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -68,6 +68,7 @@ openerp.gamification = function(instance) { self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.$el.find('.oe_type_description').hide(); self.render_money_fields(self.goals_info.info[0].currency); + self.render_progress_bars(); } }); }, @@ -87,6 +88,21 @@ openerp.gamification = function(instance) { money_field.set('value', parseInt($(this).text())); money_field.replace($(this)); }); + }, + render_progress_bars: function() { + var self = this; + + dfm = new instance.web.form.DefaultFieldManager(self); + // Generate a FieldMonetary for each .oe_goal_field_monetary + self.$el.find(".oe_goal_progress").each(function() { + progress_field = new instance.web.form.FieldProgressBar(dfm, { + attrs: { + modifiers: '{"readonly": true}' + } + }); + progress_field.set('value', $(this).attr('value')); + progress_field.replace($(this)); + }); } }); -- cgit v1.2.3 From 1c52d7e3b9c3f514f719e644feb8d7efd7371aa6 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Mar 2013 16:45:35 +0100 Subject: [ADD] change avatar function bzr revid: mat@openerp.com-20130329154535-a6v8shsc3igv2wiy --- addons/gamification/static/src/js/gamification.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index d415d35a890..7f49f66785f 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -39,7 +39,9 @@ openerp.gamification = function(instance) { }); $.when(goal_action).done(function() { var action_manager = new instance.web.ActionManager(this); - action_manager.do_action(goal_action.action); + action_manager.do_action(goal_action.action).done(function () { + self.get_goal_todo_info(); + }); //var form = action_manager.dialog_widget.views.form.controller; }); -- cgit v1.2.3 From a3c3a07d3ab4f316e0c1a0842744cf2d55f5b7e2 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 2 Apr 2013 14:15:14 +0200 Subject: [IMP] better goals bzr revid: mat@openerp.com-20130402121514-thl9b43jnbu12tr0 --- addons/gamification/static/src/js/gamification.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 7f49f66785f..dcee68197ae 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -13,7 +13,7 @@ openerp.gamification = function(instance) { events: { 'click a.oe_update_goal': function(event) { var self = this; - var goal_id = parseInt(event.currentTarget.id); + var goal_id = parseInt(event.currentTarget.id, 10); var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]); $.when(goal_updated).done(function() { self.get_goal_todo_info(); @@ -21,7 +21,7 @@ openerp.gamification = function(instance) { }, 'click a.oe_update_plan': function(event) { var self = this; - var plan_id = parseInt(event.currentTarget.id); + var plan_id = parseInt(event.currentTarget.id, 10); var goals_updated = new instance.web.Model('gamification.goal.plan').call('quick_update', [plan_id]); $.when(goals_updated).done(function() { self.get_goal_todo_info(); @@ -33,7 +33,7 @@ openerp.gamification = function(instance) { // }, 'click a.oe_goal_action': function(event) { var self = this; - var goal_id = parseInt(event.currentTarget.id); + var goal_id = parseInt(event.currentTarget.id, 10); var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]).then(function(res) { goal_action['action'] = res; }); @@ -45,7 +45,7 @@ openerp.gamification = function(instance) { //var form = action_manager.dialog_widget.views.form.controller; }); - }, + } }, renderElement: function() { var self = this; @@ -63,7 +63,7 @@ openerp.gamification = function(instance) { get_goal_todo_info: function() { var self = this; var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { - self.goals_info['info'] = res + self.goals_info['info'] = res; }); $.when(goals_info).done(function() { if(self.goals_info.info.length > 0){ @@ -87,7 +87,7 @@ openerp.gamification = function(instance) { }); money_field.set('currency', currency_id); money_field.get_currency_info(); - money_field.set('value', parseInt($(this).text())); + money_field.set('value', parseInt($(this).text(), 10)); money_field.replace($(this)); }); }, -- cgit v1.2.3 From 32b523c1d6f52bfb13eff396cf329074ad6bb654 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 8 Apr 2013 15:17:29 +0200 Subject: [IMP] better UI bzr revid: mat@openerp.com-20130408131729-lhlv0mhss502j9m1 --- addons/gamification/static/src/js/gamification.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index dcee68197ae..4aa456964c5 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -27,13 +27,10 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }, - // 'click a.oe_show_description': function(event) { - // var goal_id = parseInt(event.currentTarget.id); - // this.$el.find('.oe_type_description_'+goal_id).toggle(10); - // }, 'click a.oe_goal_action': function(event) { var self = this; var goal_id = parseInt(event.currentTarget.id, 10); + console.log("oe_goal_action"); var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]).then(function(res) { goal_action['action'] = res; }); @@ -62,13 +59,13 @@ openerp.gamification = function(instance) { }, get_goal_todo_info: function() { var self = this; + console.log("get_goal_todo_info"); var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { self.goals_info['info'] = res; }); $.when(goals_info).done(function() { if(self.goals_info.info.length > 0){ self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); - self.$el.find('.oe_type_description').hide(); self.render_money_fields(self.goals_info.info[0].currency); self.render_progress_bars(); } @@ -116,6 +113,7 @@ openerp.gamification = function(instance) { start: function() { this._super(); var self = this; + console.log("start"); var sidebar = new instance.gamification.Sidebar(self); sidebar.appendTo($('.oe_mail_wall_aside')); } -- cgit v1.2.3 From 0f2dad413b0d0cd3325c7b880bce10a2f6e4a5c4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 9 Apr 2013 16:23:02 +0200 Subject: [ADD] use gauge for kanbans bzr revid: mat@openerp.com-20130409142302-lsyye6g5cfl3wa90 --- addons/gamification/static/src/js/gamification.js | 36 +++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 4aa456964c5..34acb568026 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -30,7 +30,6 @@ openerp.gamification = function(instance) { 'click a.oe_goal_action': function(event) { var self = this; var goal_id = parseInt(event.currentTarget.id, 10); - console.log("oe_goal_action"); var goal_action = new instance.web.Model('gamification.goal').call('get_action', [goal_id]).then(function(res) { goal_action['action'] = res; }); @@ -59,7 +58,6 @@ openerp.gamification = function(instance) { }, get_goal_todo_info: function() { var self = this; - console.log("get_goal_todo_info"); var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { self.goals_info['info'] = res; }); @@ -113,9 +111,41 @@ openerp.gamification = function(instance) { start: function() { this._super(); var self = this; - console.log("start"); var sidebar = new instance.gamification.Sidebar(self); sidebar.appendTo($('.oe_mail_wall_aside')); } }); + + instance.web_kanban.KanbanRecord.include({ + start: function () { + var rendering = this._super(); + var self = this; + + $.when(rendering).done(function() { + if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { + var unique_id = _.uniqueId("goal_gauge_"); + self.$el.find('.oe_goal_gauge').attr('id', unique_id); + console.log(self.$el.find('.oe_goal_gauge').empty().get(0)); + // debugger; + var g = new JustGage({ + id: unique_id, + node: self.$el.find('.oe_goal_gauge').empty().get(0), + value: self.record.current.raw_value, + min: 0, + max: self.record.target_goal.raw_value, + title: self.record.type_id.value, + relativeGaugeSize: true + }); + console.log(g); + } + }); + }, + on_card_clicked: function() { + if (this.view.dataset.model === 'gamification.goal.plan') { + this.$('.oe_kanban_project_list a').first().click(); + } else { + this._super.apply(this, arguments); + } + } + }); }; -- cgit v1.2.3 From 5fe85f22782127e2f090d350353624b5ce22d386 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 9 Apr 2013 16:40:30 +0200 Subject: [IMP] better UI bzr revid: mat@openerp.com-20130409144030-rb609qteloq3vrgf --- addons/gamification/static/src/js/gamification.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 34acb568026..220f69cdfd2 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -125,8 +125,7 @@ openerp.gamification = function(instance) { if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { var unique_id = _.uniqueId("goal_gauge_"); self.$el.find('.oe_goal_gauge').attr('id', unique_id); - console.log(self.$el.find('.oe_goal_gauge').empty().get(0)); - // debugger; + var g = new JustGage({ id: unique_id, node: self.$el.find('.oe_goal_gauge').empty().get(0), @@ -134,9 +133,13 @@ openerp.gamification = function(instance) { min: 0, max: self.record.target_goal.raw_value, title: self.record.type_id.value, - relativeGaugeSize: true + relativeGaugeSize: true, + levelColors: [ + "#f9c802", + "#ff0000", + "#a9d70b" + ] }); - console.log(g); } }); }, -- cgit v1.2.3 From f70b0017f63fa9baef330e05e67517d2127e798e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 10 Apr 2013 12:14:54 +0200 Subject: [IMP] fixing and UI bzr revid: mat@openerp.com-20130410101454-nkt8mbt8qb13zrge --- addons/gamification/static/src/js/gamification.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 220f69cdfd2..87550914ecc 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -125,14 +125,14 @@ openerp.gamification = function(instance) { if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { var unique_id = _.uniqueId("goal_gauge_"); self.$el.find('.oe_goal_gauge').attr('id', unique_id); - + console.log(self.record); var g = new JustGage({ id: unique_id, node: self.$el.find('.oe_goal_gauge').empty().get(0), value: self.record.current.raw_value, min: 0, max: self.record.target_goal.raw_value, - title: self.record.type_id.value, + // title: self.record.type_id.value, relativeGaugeSize: true, levelColors: [ "#f9c802", -- cgit v1.2.3 From 1e9805fbfd0936cd228fb7177cc8519d2554432f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 10 Apr 2013 17:30:31 +0200 Subject: [IMP] use suffix in kanban and better view bzr revid: mat@openerp.com-20130410153031-s6op7d7wyfdzrcti --- addons/gamification/static/src/js/gamification.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 87550914ecc..c743d39282a 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -38,8 +38,6 @@ openerp.gamification = function(instance) { action_manager.do_action(goal_action.action).done(function () { self.get_goal_todo_info(); }); - - //var form = action_manager.dialog_widget.views.form.controller; }); } }, @@ -132,13 +130,24 @@ openerp.gamification = function(instance) { value: self.record.current.raw_value, min: 0, max: self.record.target_goal.raw_value, - // title: self.record.type_id.value, relativeGaugeSize: true, + humanFriendly: true, + // add space between value and symbol + // textRenderer: function(value) { + // symbol = self.record.type_suffix.raw_value; + // humannbr = humanFriendlyNumber(value, 0) + // if ((humannbr + symbol).length > 6) { + // return humannbr; + // } else { + // return humannbr + " " + symbol; + // } + // }, + label: self.record.type_suffix.raw_value, levelColors: [ "#f9c802", "#ff0000", "#a9d70b" - ] + ], }); } }); -- cgit v1.2.3 From 28761467fc3c13f45f655b39b58cb233a7a1c1ea Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 11 Apr 2013 17:11:32 +0200 Subject: [IMP] better UI bzr revid: mat@openerp.com-20130411151132-vsk2cnff5uhqmzas --- addons/gamification/static/src/js/gamification.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index c743d39282a..44af26550a0 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -123,7 +123,6 @@ openerp.gamification = function(instance) { if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { var unique_id = _.uniqueId("goal_gauge_"); self.$el.find('.oe_goal_gauge').attr('id', unique_id); - console.log(self.record); var g = new JustGage({ id: unique_id, node: self.$el.find('.oe_goal_gauge').empty().get(0), -- cgit v1.2.3 From 252365095a18b71ac0912ca2bc3f5262ffdd87b8 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 12 Apr 2013 10:54:52 +0200 Subject: [IMP] better badge views and checks bzr revid: mat@openerp.com-20130412085452-mnecqo80cgmo2ecs --- addons/gamification/static/src/js/gamification.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 44af26550a0..a856d057172 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -125,7 +125,7 @@ openerp.gamification = function(instance) { self.$el.find('.oe_goal_gauge').attr('id', unique_id); var g = new JustGage({ id: unique_id, - node: self.$el.find('.oe_goal_gauge').empty().get(0), + node: self.$('.oe_goal_gauge').empty().get(0), value: self.record.current.raw_value, min: 0, max: self.record.target_goal.raw_value, -- cgit v1.2.3 From b18bc579197837ddcc97d9f7292d8cec3bc05d49 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 12 Apr 2013 17:21:50 +0200 Subject: [ADD] use sparklines bzr revid: mat@openerp.com-20130412152150-8679huigt6cfmool --- addons/gamification/static/src/js/gamification.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index a856d057172..aafdcbf8659 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -64,6 +64,7 @@ openerp.gamification = function(instance) { self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.render_money_fields(self.goals_info.info[0].currency); self.render_progress_bars(); + self.render_piechars(); } }); }, @@ -72,7 +73,7 @@ openerp.gamification = function(instance) { self.dfm = new instance.web.form.DefaultFieldManager(self); // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$el.find(".oe_goal_field_monetary").each(function() { + self.$(".oe_goal_field_monetary").each(function() { money_field = new instance.web.form.FieldMonetary(self.dfm, { attrs: { modifiers: '{"readonly": true}' @@ -89,7 +90,7 @@ openerp.gamification = function(instance) { dfm = new instance.web.form.DefaultFieldManager(self); // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$el.find(".oe_goal_progress").each(function() { + self.$(".oe_goal_progress").each(function() { progress_field = new instance.web.form.FieldProgressBar(dfm, { attrs: { modifiers: '{"readonly": true}' @@ -98,6 +99,14 @@ openerp.gamification = function(instance) { progress_field.set('value', $(this).attr('value')); progress_field.replace($(this)); }); + }, + render_piechars: function() { + var self = this; + self.$(".oe_goal_sparkline_piechart").each(function() { + var completeness = parseInt( $(this).attr('data-completeness'), 10); + var values = [completeness, 100-completeness]; + $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#01922D','#ff0000']}); + }); } }); @@ -143,8 +152,8 @@ openerp.gamification = function(instance) { // }, label: self.record.type_suffix.raw_value, levelColors: [ - "#f9c802", "#ff0000", + "#f9c802", "#a9d70b" ], }); -- cgit v1.2.3 From 8d23c604d91b0180f0dca25b3a907aa642d12c5a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 16 Apr 2013 12:27:24 +0200 Subject: [IMP] switch to challenges bzr revid: mat@openerp.com-20130416102724-0ejrlecls30xhol3 --- addons/gamification/static/src/js/gamification.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index aafdcbf8659..7f1e31d2c24 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -105,7 +105,7 @@ openerp.gamification = function(instance) { self.$(".oe_goal_sparkline_piechart").each(function() { var completeness = parseInt( $(this).attr('data-completeness'), 10); var values = [completeness, 100-completeness]; - $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#01922D','#ff0000']}); + $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#0B610B','#F78181']}); }); } }); -- cgit v1.2.3 From b2bb03ba4a26807cee969c238639e60faced138e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 16 Apr 2013 15:48:47 +0200 Subject: [FIX] correct actions bzr revid: mat@openerp.com-20130416134847-celf4nbl7748vnj5 --- addons/gamification/static/src/js/gamification.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 7f1e31d2c24..e68874c866b 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -155,7 +155,7 @@ openerp.gamification = function(instance) { "#ff0000", "#f9c802", "#a9d70b" - ], + ] }); } }); -- cgit v1.2.3 From 06159a516abb7203d997d2dcb77b0fcc849c2b5a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 18 Apr 2013 12:32:29 +0200 Subject: [IMP] show suggested threads bzr revid: mat@openerp.com-20130418103229-xkyu6qyzdola03hn --- addons/gamification/static/src/js/gamification.js | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index e68874c866b..464fd1ace5a 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -9,6 +9,7 @@ openerp.gamification = function(instance) { this.deferred = $.Deferred(); this.res_user = new instance.web.DataSetSearch(this, 'res.users'); this.goals_info = {}; + this.challenge_suggestions = {}; }, events: { 'click a.oe_update_goal': function(event) { @@ -45,6 +46,7 @@ openerp.gamification = function(instance) { var self = this; this._super.apply(this, arguments); self.get_goal_todo_info(); + self.get_challenge_suggestions(); }, render_template: function(target,template) { var self = this; @@ -65,6 +67,22 @@ openerp.gamification = function(instance) { self.render_money_fields(self.goals_info.info[0].currency); self.render_progress_bars(); self.render_piechars(); + } else { + self.$el.filter(".oe_gamification_goal").hide(); + } + }); + }, + get_challenge_suggestions: function() { + var self = this; + var challenge_suggestions = this.res_user.call('get_challenge_suggestions', {}).then(function(res) { + self.challenge_suggestions['info'] = res; + console.log(res); + }); + $.when(challenge_suggestions).done(function() { + if(self.challenge_suggestions.info.length > 0){ + self.render_template_replace(self.$el.filter(".oe_gamification_suggestion"),'gamification.challenge_suggestions'); + } else { + self.$el.filter(".oe_gamification_suggestion").hide(); } }); }, @@ -128,6 +146,7 @@ openerp.gamification = function(instance) { var rendering = this._super(); var self = this; + // add gauge in goal kanban views $.when(rendering).done(function() { if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { var unique_id = _.uniqueId("goal_gauge_"); @@ -140,16 +159,6 @@ openerp.gamification = function(instance) { max: self.record.target_goal.raw_value, relativeGaugeSize: true, humanFriendly: true, - // add space between value and symbol - // textRenderer: function(value) { - // symbol = self.record.type_suffix.raw_value; - // humannbr = humanFriendlyNumber(value, 0) - // if ((humannbr + symbol).length > 6) { - // return humannbr; - // } else { - // return humannbr + " " + symbol; - // } - // }, label: self.record.type_suffix.raw_value, levelColors: [ "#ff0000", @@ -160,6 +169,7 @@ openerp.gamification = function(instance) { } }); }, + // open related goals when clicking on challenge kanban view on_card_clicked: function() { if (this.view.dataset.model === 'gamification.goal.plan') { this.$('.oe_kanban_project_list a').first().click(); -- cgit v1.2.3 From 8a95c92353868f4a1a53ddc27eb6bc5943c06188 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 18 Apr 2013 18:05:12 +0200 Subject: [ADD] wizard to accept challenges bzr revid: mat@openerp.com-20130418160512-v9tw81ddki79kwv5 --- addons/gamification/static/src/js/gamification.js | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 464fd1ace5a..41b6125a4c9 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -40,6 +40,20 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }); + }, + 'click a.oe_challenge_reply': function(event) { + var self = this; + var plan_id = parseInt(event.currentTarget.id, 10); + var plan_action = new instance.web.Model('gamification.goal.plan').call('reply_challenge_wizard', [plan_id]).then(function(res) { + plan_action['action'] = res; + }); + $.when(plan_action).done(function() { + var action_manager = new instance.web.ActionManager(this); + action_manager.do_action(plan_action.action).done(function () { + console.log(plan_action.action); + self.get_goal_todo_info(); + }); + }); } }, renderElement: function() { @@ -65,8 +79,9 @@ openerp.gamification = function(instance) { if(self.goals_info.info.length > 0){ self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.render_money_fields(self.goals_info.info[0].currency); - self.render_progress_bars(); + // self.render_progress_bars(); self.render_piechars(); + self.render_user_avatars(); } else { self.$el.filter(".oe_gamification_goal").hide(); } @@ -76,7 +91,6 @@ openerp.gamification = function(instance) { var self = this; var challenge_suggestions = this.res_user.call('get_challenge_suggestions', {}).then(function(res) { self.challenge_suggestions['info'] = res; - console.log(res); }); $.when(challenge_suggestions).done(function() { if(self.challenge_suggestions.info.length > 0){ @@ -125,6 +139,14 @@ openerp.gamification = function(instance) { var values = [completeness, 100-completeness]; $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#0B610B','#F78181']}); }); + }, + render_user_avatars: function() { + var self = this; + self.$(".oe_user_avatar").each(function() { + var user_id = parseInt( $(this).attr('data-id'), 10); + var url = instance.session.url('/web/binary/image', {model: 'res.users', field: 'image_small', id: user_id}); + $(this).attr("src", url); + }); } }); -- cgit v1.2.3 From 8b400f7e883a0bcee2cd29c7539f786a084b40f5 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 22 Apr 2013 15:33:55 +0200 Subject: [IMP] remove many2many display and clean ups bzr revid: mat@openerp.com-20130422133355-ffhglxrkdia2hz4j --- addons/gamification/static/src/js/gamification.js | 25 ----------------------- 1 file changed, 25 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 41b6125a4c9..edfc304f83f 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -79,8 +79,6 @@ openerp.gamification = function(instance) { if(self.goals_info.info.length > 0){ self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.render_money_fields(self.goals_info.info[0].currency); - // self.render_progress_bars(); - self.render_piechars(); self.render_user_avatars(); } else { self.$el.filter(".oe_gamification_goal").hide(); @@ -117,29 +115,6 @@ openerp.gamification = function(instance) { money_field.replace($(this)); }); }, - render_progress_bars: function() { - var self = this; - - dfm = new instance.web.form.DefaultFieldManager(self); - // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$(".oe_goal_progress").each(function() { - progress_field = new instance.web.form.FieldProgressBar(dfm, { - attrs: { - modifiers: '{"readonly": true}' - } - }); - progress_field.set('value', $(this).attr('value')); - progress_field.replace($(this)); - }); - }, - render_piechars: function() { - var self = this; - self.$(".oe_goal_sparkline_piechart").each(function() { - var completeness = parseInt( $(this).attr('data-completeness'), 10); - var values = [completeness, 100-completeness]; - $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#0B610B','#F78181']}); - }); - }, render_user_avatars: function() { var self = this; self.$(".oe_user_avatar").each(function() { -- cgit v1.2.3 From 021c8de63fad862b2d792ee9a8f52680024a6003 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 22 Apr 2013 16:28:11 +0200 Subject: [ADD] action to create new users bzr revid: mat@openerp.com-20130422142811-yle27izd3zhre2c0 --- addons/gamification/static/src/js/gamification.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index edfc304f83f..6965020e73d 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -50,7 +50,6 @@ openerp.gamification = function(instance) { $.when(plan_action).done(function() { var action_manager = new instance.web.ActionManager(this); action_manager.do_action(plan_action.action).done(function () { - console.log(plan_action.action); self.get_goal_todo_info(); }); }); -- cgit v1.2.3 From 1419b2fa974e4fbad7294f87be03ab01a9417122 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 23 Apr 2013 15:03:51 +0200 Subject: [IMP] users follow goal plan bzr revid: mat@openerp.com-20130423130351-pq3tepnmx2u74au5 --- addons/gamification/static/src/js/gamification.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 6965020e73d..21f7a7ef2a8 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -12,14 +12,7 @@ openerp.gamification = function(instance) { this.challenge_suggestions = {}; }, events: { - 'click a.oe_update_goal': function(event) { - var self = this; - var goal_id = parseInt(event.currentTarget.id, 10); - var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]); - $.when(goal_updated).done(function() { - self.get_goal_todo_info(); - }); - }, + // update a plan and related goals 'click a.oe_update_plan': function(event) { var self = this; var plan_id = parseInt(event.currentTarget.id, 10); @@ -28,6 +21,7 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }, + // action to modify a goal 'click a.oe_goal_action': function(event) { var self = this; var goal_id = parseInt(event.currentTarget.id, 10); @@ -41,6 +35,7 @@ openerp.gamification = function(instance) { }); }); }, + // get more info about a challenge request 'click a.oe_challenge_reply': function(event) { var self = this; var plan_id = parseInt(event.currentTarget.id, 10); -- cgit v1.2.3 From 8182600868879445ce1a96349c545e07a07a3a0f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 24 Apr 2013 10:36:32 +0200 Subject: [IMP] use github version of justgage bzr revid: mat@openerp.com-20130424083632-c68tdeg79wcns9hj --- addons/gamification/static/src/js/gamification.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 21f7a7ef2a8..b004d88f1b9 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -30,8 +30,11 @@ openerp.gamification = function(instance) { }); $.when(goal_action).done(function() { var action_manager = new instance.web.ActionManager(this); - action_manager.do_action(goal_action.action).done(function () { - self.get_goal_todo_info(); + var action = action_manager.do_action(goal_action.action); + $.when(action).done(function () { + new instance.web.Model('gamification.goal').call('update', [[goal_id]]).then(function(res) { + self.get_goal_todo_info(); + }); }); }); }, @@ -140,11 +143,8 @@ openerp.gamification = function(instance) { // add gauge in goal kanban views $.when(rendering).done(function() { if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { - var unique_id = _.uniqueId("goal_gauge_"); - self.$el.find('.oe_goal_gauge').attr('id', unique_id); var g = new JustGage({ - id: unique_id, - node: self.$('.oe_goal_gauge').empty().get(0), + parentNode: self.$('.oe_goal_gauge').empty().get(0), value: self.record.current.raw_value, min: 0, max: self.record.target_goal.raw_value, -- cgit v1.2.3 From f99ce17ecf8234542914458b5b2ba1f101781f22 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 29 Apr 2013 13:43:05 +0200 Subject: Removed KanbanRecord hack to use kanban fields registry bzr revid: nicolas.vanhoren@openerp.com-20130429114305-3b24eixyj4xts9lv --- addons/gamification/static/src/js/gamification.js | 56 +++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index b004d88f1b9..610e74b5d0e 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -136,30 +136,6 @@ openerp.gamification = function(instance) { }); instance.web_kanban.KanbanRecord.include({ - start: function () { - var rendering = this._super(); - var self = this; - - // add gauge in goal kanban views - $.when(rendering).done(function() { - if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) { - var g = new JustGage({ - parentNode: self.$('.oe_goal_gauge').empty().get(0), - value: self.record.current.raw_value, - min: 0, - max: self.record.target_goal.raw_value, - relativeGaugeSize: true, - humanFriendly: true, - label: self.record.type_suffix.raw_value, - levelColors: [ - "#ff0000", - "#f9c802", - "#a9d70b" - ] - }); - } - }); - }, // open related goals when clicking on challenge kanban view on_card_clicked: function() { if (this.view.dataset.model === 'gamification.goal.plan') { @@ -169,4 +145,36 @@ openerp.gamification = function(instance) { } } }); + + instance.gamification.GoalWidget = instance.web_kanban.AbstractField.extend({ + className: "oe_goal_gauge", + start: function() { + var self = this; + var max = 100; + if (this.options.max_field) { + max = self.getParent().record[this.options.max_field].raw_value; + } + var label = ""; + if (this.options.label_field) { + label = self.getParent().record[this.options.label_field].raw_value; + } + this.g = new JustGage({ + parentNode: self.$el[0], + value: self.get("value"), + min: 0, + max: max, + relativeGaugeSize: true, + humanFriendly: true, + label: label, + levelColors: [ + "#ff0000", + "#f9c802", + "#a9d70b" + ] + }); + }, + }); + instance.web_kanban.fields_registry.add("goal", "instance.gamification.GoalWidget"); + + }; -- cgit v1.2.3 From 0ea12d6d918b8bcecb9125272ae7fd31f94b7827 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 29 Apr 2013 17:30:07 +0200 Subject: [IMP] design tweaks bzr revid: mat@openerp.com-20130429153007-tha1wmcvbtp89dz2 --- addons/gamification/static/src/js/gamification.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 610e74b5d0e..272fa109e78 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -123,10 +123,6 @@ openerp.gamification = function(instance) { }); instance.mail.Widget.include({ - init: function (parent, action) { - var self = this; - this._super(parent, action); - }, start: function() { this._super(); var self = this; -- cgit v1.2.3 From a51a1fe65ddf5b7d01d32d1db07d29a8ffa8d419 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 27 May 2013 11:37:38 +0200 Subject: [IMP] don't use new action manager for do_action bzr revid: mat@openerp.com-20130527093738-2dp8uw5nli7xzahu --- addons/gamification/static/src/js/gamification.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 272fa109e78..8c9aff58775 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -29,8 +29,7 @@ openerp.gamification = function(instance) { goal_action['action'] = res; }); $.when(goal_action).done(function() { - var action_manager = new instance.web.ActionManager(this); - var action = action_manager.do_action(goal_action.action); + var action = self.do_action(goal_action.action); $.when(action).done(function () { new instance.web.Model('gamification.goal').call('update', [[goal_id]]).then(function(res) { self.get_goal_todo_info(); @@ -46,8 +45,7 @@ openerp.gamification = function(instance) { plan_action['action'] = res; }); $.when(plan_action).done(function() { - var action_manager = new instance.web.ActionManager(this); - action_manager.do_action(plan_action.action).done(function () { + self.do_action(plan_action.action).done(function () { self.get_goal_todo_info(); }); }); -- cgit v1.2.3 From ba64b6e3e6e65f5c6720af301fafe3322a7aff5d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 2 Oct 2013 17:05:07 +0200 Subject: [FIX] gamification: use gauge merged in web and instead of own version bzr revid: mat@openerp.com-20131002150507-ea76au2frffvfd0r --- addons/gamification/static/src/js/gamification.js | 31 ----------------------- 1 file changed, 31 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 8c9aff58775..ccd5204b2ba 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -139,36 +139,5 @@ openerp.gamification = function(instance) { } } }); - - instance.gamification.GoalWidget = instance.web_kanban.AbstractField.extend({ - className: "oe_goal_gauge", - start: function() { - var self = this; - var max = 100; - if (this.options.max_field) { - max = self.getParent().record[this.options.max_field].raw_value; - } - var label = ""; - if (this.options.label_field) { - label = self.getParent().record[this.options.label_field].raw_value; - } - this.g = new JustGage({ - parentNode: self.$el[0], - value: self.get("value"), - min: 0, - max: max, - relativeGaugeSize: true, - humanFriendly: true, - label: label, - levelColors: [ - "#ff0000", - "#f9c802", - "#a9d70b" - ] - }); - }, - }); - instance.web_kanban.fields_registry.add("goal", "instance.gamification.GoalWidget"); - }; -- cgit v1.2.3 From 122c15c48d430c502adf2df45bad4405a864b5ce Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 17 Dec 2013 17:15:41 +0100 Subject: [REF] gamification: pretty much changing half of the code to make tde happy... bzr revid: mat@openerp.com-20131217161541-oxsgy7gmko2x6qui --- addons/gamification/static/src/js/gamification.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index ccd5204b2ba..9e34d8f09fc 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -12,11 +12,11 @@ openerp.gamification = function(instance) { this.challenge_suggestions = {}; }, events: { - // update a plan and related goals - 'click a.oe_update_plan': function(event) { + // update a challenge and related goals + 'click a.oe_update_challenge': function(event) { var self = this; - var plan_id = parseInt(event.currentTarget.id, 10); - var goals_updated = new instance.web.Model('gamification.goal.plan').call('quick_update', [plan_id]); + var challenge_id = parseInt(event.currentTarget.id, 10); + var goals_updated = new instance.web.Model('gamification.challenge').call('quick_update', [challenge_id]); $.when(goals_updated).done(function() { self.get_goal_todo_info(); }); @@ -40,12 +40,12 @@ openerp.gamification = function(instance) { // get more info about a challenge request 'click a.oe_challenge_reply': function(event) { var self = this; - var plan_id = parseInt(event.currentTarget.id, 10); - var plan_action = new instance.web.Model('gamification.goal.plan').call('reply_challenge_wizard', [plan_id]).then(function(res) { - plan_action['action'] = res; + var challenge_id = parseInt(event.currentTarget.id, 10); + var challenge_action = new instance.web.Model('gamification.challenge').call('reply_challenge_wizard', [challenge_id]).then(function(res) { + challenge_action['action'] = res; }); - $.when(plan_action).done(function() { - self.do_action(plan_action.action).done(function () { + $.when(challenge_action).done(function() { + self.do_action(challenge_action.action).done(function () { self.get_goal_todo_info(); }); }); @@ -132,7 +132,7 @@ openerp.gamification = function(instance) { instance.web_kanban.KanbanRecord.include({ // open related goals when clicking on challenge kanban view on_card_clicked: function() { - if (this.view.dataset.model === 'gamification.goal.plan') { + if (this.view.dataset.model === 'gamification.challenge') { this.$('.oe_kanban_project_list a').first().click(); } else { this._super.apply(this, arguments); -- cgit v1.2.3 From f77aefc07ace66587bc13f7d2fa55755968437c5 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 20 Dec 2013 15:45:21 +0100 Subject: [REF] gamification: cleaning methods and reports bzr revid: mat@openerp.com-20131220144521-wyu1gx8bcitu6nk4 --- addons/gamification/static/src/js/gamification.js | 55 +++++++++++------------ 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 9e34d8f09fc..cf5b2228b08 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -2,12 +2,12 @@ openerp.gamification = function(instance) { var QWeb = instance.web.qweb; instance.gamification.Sidebar = instance.web.Widget.extend({ - template: 'gamification.user_wall_sidebar', + template: 'gamification.UserWallSidebar', init: function (parent, action) { var self = this; this._super(parent, action); this.deferred = $.Deferred(); - this.res_user = new instance.web.DataSetSearch(this, 'res.users'); + // this.res_user = new instance.web.DataSetSearch(this, 'res.users'); this.goals_info = {}; this.challenge_suggestions = {}; }, @@ -51,54 +51,53 @@ openerp.gamification = function(instance) { }); } }, - renderElement: function() { + start: function() { var self = this; this._super.apply(this, arguments); self.get_goal_todo_info(); self.get_challenge_suggestions(); }, - render_template: function(target,template) { - var self = this; - target.append(QWeb.render(template,{'widget': self})); - }, + // render_template: function(target,template) { + // var self = this; + // target.append(QWeb.render(template,{'widget': self})); + // }, render_template_replace: function(target,template) { var self = this; target.html(QWeb.render(template,{'widget': self})); }, get_goal_todo_info: function() { var self = this; - var goals_info = this.res_user.call('get_goals_todo_info', {}).then(function(res) { - self.goals_info['info'] = res; - }); - $.when(goals_info).done(function() { - if(self.goals_info.info.length > 0){ - self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); - self.render_money_fields(self.goals_info.info[0].currency); - self.render_user_avatars(); + var challenges = new instance.web.Model('res.users').call('get_serialised_gamification_summary', []).then(function(result) { + if (result.length === 0) { + self.$el.find(".oe_gamification_challenge_list").hide(); } else { - self.$el.filter(".oe_gamification_goal").hide(); + _.each(result, function(item){ + console.log(item); + var $item = $(QWeb.render("gamification.ChallengeSummary", {challenge: item})); + self.render_money_fields($item); + self.render_user_avatars($item); + self.$el.find('.oe_gamification_challenge_list').append($item); + }); } }); }, get_challenge_suggestions: function() { var self = this; - var challenge_suggestions = this.res_user.call('get_challenge_suggestions', {}).then(function(res) { - self.challenge_suggestions['info'] = res; - }); - $.when(challenge_suggestions).done(function() { - if(self.challenge_suggestions.info.length > 0){ - self.render_template_replace(self.$el.filter(".oe_gamification_suggestion"),'gamification.challenge_suggestions'); + var challenge_suggestions = new instance.web.Model('res.users').call('get_challenge_suggestions', []).then(function(result) { + if (result.length === 0) { + self.$el.find(".oe_gamification_suggestion").hide(); } else { - self.$el.filter(".oe_gamification_suggestion").hide(); + var $item = $(QWeb.render("gamification.ChallengeSuggestion", {challenges: result})); + self.$el.find('.oe_gamification_suggestion').append($item); } }); }, - render_money_fields: function(currency_id) { + render_money_fields: function(item) { var self = this; - self.dfm = new instance.web.form.DefaultFieldManager(self); // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$(".oe_goal_field_monetary").each(function() { + item.find(".oe_goal_field_monetary").each(function() { + var currency_id = parseInt( $(this).attr('data-id'), 10); money_field = new instance.web.form.FieldMonetary(self.dfm, { attrs: { modifiers: '{"readonly": true}' @@ -110,9 +109,9 @@ openerp.gamification = function(instance) { money_field.replace($(this)); }); }, - render_user_avatars: function() { + render_user_avatars: function(item) { var self = this; - self.$(".oe_user_avatar").each(function() { + item.find(".oe_user_avatar").each(function() { var user_id = parseInt( $(this).attr('data-id'), 10); var url = instance.session.url('/web/binary/image', {model: 'res.users', field: 'image_small', id: user_id}); $(this).attr("src", url); -- cgit v1.2.3 From c0eef311602c986e5ab54ebba016eb12d49e1467 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 23 Dec 2013 16:54:04 +0100 Subject: [REF] gamification: add user_from_id on badge, remove outdated-doc, remove useless message_post call bzr revid: mat@openerp.com-20131223155404-h4in4ocr8jakq3ff --- addons/gamification/static/src/js/gamification.js | 41 ++++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index cf5b2228b08..22cfd5f3ab5 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -57,14 +57,6 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); self.get_challenge_suggestions(); }, - // render_template: function(target,template) { - // var self = this; - // target.append(QWeb.render(template,{'widget': self})); - // }, - render_template_replace: function(target,template) { - var self = this; - target.html(QWeb.render(template,{'widget': self})); - }, get_goal_todo_info: function() { var self = this; var challenges = new instance.web.Model('res.users').call('get_serialised_gamification_summary', []).then(function(result) { @@ -72,7 +64,6 @@ openerp.gamification = function(instance) { self.$el.find(".oe_gamification_challenge_list").hide(); } else { _.each(result, function(item){ - console.log(item); var $item = $(QWeb.render("gamification.ChallengeSummary", {challenge: item})); self.render_money_fields($item); self.render_user_avatars($item); @@ -122,12 +113,38 @@ openerp.gamification = function(instance) { instance.mail.Widget.include({ start: function() { this._super(); - var self = this; - var sidebar = new instance.gamification.Sidebar(self); + var sidebar = new instance.gamification.Sidebar(this); sidebar.appendTo($('.oe_mail_wall_aside')); } }); + instance.web_kanban.KanbanView.include({ + start: function() { + this._super(); + $(document).off('keydown.klistener'); + }, + events: { + 'click': function(event) { + var self = this; + if (this.ViewManager.dataset.model === 'gamification.badge') { + this.kkeys = []; + $(document).off('keydown.klistener'); + $(document).on('keydown.klistener', function(event) { + if ("37,38,39,40,65,66".indexOf(event.keyCode) < 0) { + $(document).off('keydown.klistener'); + } else { + self.kkeys.push(event.keyCode); + if (self.kkeys.toString().indexOf("38,38,40,40,37,39,37,39,66,65") >= 0) { + new instance.web.Model('gamification.badge').call('check_progress', []); + $(document).off('keydown.klistener'); + } + } + }); + } + } + } + }); + instance.web_kanban.KanbanRecord.include({ // open related goals when clicking on challenge kanban view on_card_clicked: function() { @@ -136,7 +153,7 @@ openerp.gamification = function(instance) { } else { this._super.apply(this, arguments); } - } + }, }); }; -- cgit v1.2.3 From aefd64e8cfe41db54588dac2c50cf2a50316cc7a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 24 Dec 2013 14:00:23 +0100 Subject: [REF] gamification: compute_code is now similar to ir.actions, cleanup code bzr revid: mat@openerp.com-20131224130023-e4gc91ell38zdtfj --- addons/gamification/static/src/js/gamification.js | 45 +++++++++-------------- 1 file changed, 17 insertions(+), 28 deletions(-) (limited to 'addons/gamification/static/src/js/gamification.js') diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 22cfd5f3ab5..2a8db5f369d 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -7,9 +7,9 @@ openerp.gamification = function(instance) { var self = this; this._super(parent, action); this.deferred = $.Deferred(); - // this.res_user = new instance.web.DataSetSearch(this, 'res.users'); this.goals_info = {}; this.challenge_suggestions = {}; + $(document).off('keydown.klistener'); }, events: { // update a challenge and related goals @@ -49,6 +49,21 @@ openerp.gamification = function(instance) { self.get_goal_todo_info(); }); }); + }, + 'click .oe_goal h4': function(event) { + var self = this; + this.kkeys = []; + $(document).on('keydown.klistener', function(event) { + if ("37,38,39,40,65,66".indexOf(event.keyCode) < 0) { + $(document).off('keydown.klistener'); + } else { + self.kkeys.push(event.keyCode); + if (self.kkeys.toString().indexOf("38,38,40,40,37,39,37,39,66,65") >= 0) { + new instance.web.Model('gamification.badge').call('check_progress', []); + $(document).off('keydown.klistener'); + } + } + }); } }, start: function() { @@ -63,6 +78,7 @@ openerp.gamification = function(instance) { if (result.length === 0) { self.$el.find(".oe_gamification_challenge_list").hide(); } else { + self.$el.find(".oe_gamification_challenge_list").empty(); _.each(result, function(item){ var $item = $(QWeb.render("gamification.ChallengeSummary", {challenge: item})); self.render_money_fields($item); @@ -115,34 +131,7 @@ openerp.gamification = function(instance) { this._super(); var sidebar = new instance.gamification.Sidebar(this); sidebar.appendTo($('.oe_mail_wall_aside')); - } - }); - - instance.web_kanban.KanbanView.include({ - start: function() { - this._super(); - $(document).off('keydown.klistener'); }, - events: { - 'click': function(event) { - var self = this; - if (this.ViewManager.dataset.model === 'gamification.badge') { - this.kkeys = []; - $(document).off('keydown.klistener'); - $(document).on('keydown.klistener', function(event) { - if ("37,38,39,40,65,66".indexOf(event.keyCode) < 0) { - $(document).off('keydown.klistener'); - } else { - self.kkeys.push(event.keyCode); - if (self.kkeys.toString().indexOf("38,38,40,40,37,39,37,39,66,65") >= 0) { - new instance.web.Model('gamification.badge').call('check_progress', []); - $(document).off('keydown.klistener'); - } - } - }); - } - } - } }); instance.web_kanban.KanbanRecord.include({ -- cgit v1.2.3