diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-04-29 13:43:05 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-04-29 13:43:05 +0200 |
| commit | f99ce17ecf8234542914458b5b2ba1f101781f22 (patch) | |
| tree | 4fd644120058401b19e8f300e56878d330f668fb /addons/gamification/static/src | |
| parent | 87c1fab873ed246fb5f3152377a82bad49c8a982 (diff) | |
Removed KanbanRecord hack to use kanban fields registry
bzr revid: nicolas.vanhoren@openerp.com-20130429114305-3b24eixyj4xts9lv
Diffstat (limited to 'addons/gamification/static/src')
| -rw-r--r-- | addons/gamification/static/src/js/gamification.js | 56 |
1 files changed, 32 insertions, 24 deletions
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"); + + }; |
