[IMP] update button with refresh

bzr revid: mat@openerp.com-20130322111344-7qs3o2tvbx7h4qln
This commit is contained in:
Martin Trigaux 2013-03-22 12:13:44 +01:00
parent f691d13810
commit 80541abdbf
5 changed files with 44 additions and 10 deletions

View File

@ -185,8 +185,9 @@ class gamification_goal(osv.Model):
If a goal reaches the target value, the status is set to reached
If the end date is passed (at least +1 day, time not considered) without
the target value being reached, the goal is set as failed."""
if context is None: context = {}
for goal in self.browse(cr, uid, ids, context=context or {}):
for goal in self.browse(cr, uid, ids, context=context):
if goal.state in ('draft', 'canceled'):
# skip if goal draft or canceled
continue

View File

@ -44,10 +44,13 @@ class res_users_gamification_group(osv.Model):
vals['goals'].append({
'id': goal.id,
'type_name': goal.type_id.name,
'type_condition': goal.type_id.condition,
'type_description': goal.type_description,
'state': goal.state,
'completeness': goal.completeness,
'computation_mode': goal.computation_mode,
'current': goal.current,
'target_goal': goal.target_goal,
})
# skip plans where all goal are done or failed
if not all_done:

View File

@ -31,7 +31,7 @@
position: relative;
display: inline-block;
vertical-align: top;
width: 220px;
width: 250px;
}
.openerp .oe_user_sidebar .oe_gamification_goal {
background: #EDEDF6;
@ -57,12 +57,18 @@
.openerp .oe_mail_wall .oe_user_sidebar ul {
list-style-type: none;
padding-left: 20px;
margin-bottom: 10px;
}
.openerp .oe_mail_wall .oe_user_sidebar li {
margin-bottom: 10px;
}
.openerp .oe_mail_wall .oe_user_sidebar li progress {
width: 80%;
display: inline-block;
}
.openerp .oe_mail_wall .oe_user_sidebar li p {
margin:5px 0;
}
.openerp .oe_mail_wall .oe_mail {
display: inline-block;
}

View File

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

View File

@ -19,10 +19,17 @@
<t t-if="goal.type_description">
<p><t t-esc="goal.type_description" /></p>
</t>
<p><progress t-att-value="goal.completeness" max="100"/></p>
<t t-if="goal.computation_mode == 'manually'">
<a href="#">done!</a>
</t>
<p>
<t t-if="goal.type_condition == 'higher'">
<progress t-att-value="goal.completeness" max="100"/>
</t>
<t t-if="goal.type_condition == 'lower'">
<t t-esc="goal.current" /> (less than <t t-esc="goal.target_goal"/>)
</t>
<a class="oe_update_goal" rol="button" t-attf-id="{goal.id}">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMWCRMG1/sI6gAAAR1JREFUKM910T9L1nEUBfCPP39S4pAuba0FDoEhbc6CLkEUvQMb7hKFDU29gCYPNFUoiH9WRwedhBB8CS1Bg7WEKKH12PJ94GnoTJfDOece7h3TkGQCk+hxVVVnjZ/Gz6q6TqJLMvTcxRG+4l0T38MXPE0yVlW6qhoa5jCLG/jQuEXM4BOWk+hb0n2sYQVdVX1uhvc4xRbe4rBPMo4n+I7NqroYqXmFXTzEC9zpcbOt3m8CIzVhkGSvGR50GMdtDPwfZzjHoGvCUyygH9YZqQW3MIXjHr9wgFU8axdRVZJMocNjHONbV1W/sYMf+Ig3SSZb8kts4xFeV9VF19JO8GpEdNnmFSxhv6oO8M+n1zGP51X1J8lsS1/FRpIe/gIpymSOkJCtuQAAAABJRU5ErkJggg==" alt="update" />
</a>
</p>
</li>
</ul>
</div>