Removed KanbanRecord hack to use kanban fields registry

bzr revid: nicolas.vanhoren@openerp.com-20130429114305-3b24eixyj4xts9lv
This commit is contained in:
niv-openerp 2013-04-29 13:43:05 +02:00
parent 87c1fab873
commit f99ce17ecf
2 changed files with 33 additions and 25 deletions

View File

@ -162,7 +162,7 @@
</t>
<t t-if="record.type_display.raw_value == 'progress'">
<t t-if="record.type_condition.raw_value =='higher'">
<div class="oe_goal_gauge"></div>
<field name="current" widget="goal" options="{'max_field': 'target_goal', 'label_field': 'type_suffix'}"/>
</t>
<t t-if="record.type_condition.raw_value != 'higher'">
<div t-attf-class="oe_goal_state #{record.current.raw_value == record.target_goal.raw_value+1 ? 'oe_orange' : record.current.raw_value &gt; record.target_goal.raw_value ? 'oe_red' : 'oe_green'}">

View File

@ -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");
};