[IMP] using sidebar and better javascript

bzr revid: mat@openerp.com-20130322151803-nzb41s0mxvaidrel
This commit is contained in:
Martin Trigaux
2013-03-22 16:18:03 +01:00
parent 80541abdbf
commit 391947f7cc
5 changed files with 36 additions and 31 deletions
+1 -1
View File
@@ -46,7 +46,7 @@
<button string="Goal Reached" type="object" name="action_reach" states="inprogress,inprogress_update" />
<button string="Goal Failed" type="object" name="action_fail" states="inprogress,inprogress_update"/>
<button string="Reset Completion" type="object" name="action_cancel" states="failed,reached"/>
<button string="Reset Completion" type="object" name="action_cancel" states="failed,reached" groups="base.group_no_one" />
<field name="state" widget="statusbar" statusbar_visible="inprogress" />
</header>
<sheet>
+10 -10
View File
@@ -25,7 +25,7 @@
-moz-column-count: 3;
}*/
.openerp .oe_mail_wall .oe_user_sidebar {
.openerp .oe_mail_wall .oe_mail_wall_aside {
margin-left: 20px;
margin-top: 20px;
position: relative;
@@ -33,40 +33,40 @@
vertical-align: top;
width: 250px;
}
.openerp .oe_user_sidebar .oe_gamification_goal {
.openerp .oe_mail_wall_aside .oe_gamification_goal {
background: #EDEDF6;
height: auto;
padding: 15px;
border: solid 1px rgba(0,0,0,0.03);
}
.openerp .oe_user_sidebar .oe_gamification_goal .oe_goal_reached:before {
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_reached:before {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMSCREbCamR5gAAAXhJREFUOMuV0z9rlEEQBvDf7htFFIwQBCvRQuFAJSJooY29VrH0E1hcCqNign8SYzAxRfTA0nyAg3wBK1GCKSwTK8G7j6AgiHl3LbLmwOQu8Wl2mZ15Zp6ZnWC/GMcrjBvBdTRkX4P/QdNZrGKkWN7sn+CuE5IvsqOyKFnRMhb3DJwsZ2VV5ZgoCt5qGdsyD8ITzGJSW3BVkAUdlZsu++0T/SU8xxQeuyj7LKEWJKcs6Px16y9harv0NVEQBZWmBR33e26Dm/hMW3BLLUvW/XJBlM31XIZMlNsi7pWa5jGjIbiBXBLd8UL+N0e0WIInvMNp8+Wltqx2SBJk06Z98HRnkUHTOZWPomEVojOiUZV26foP2XkHdD3aSRBxXDIsSRKyddmyGklQa5vRtbl7myprvrnisOBa0TuEgyBhziXwfneCrTG+9kDSkgQJSbaJ2ix42H9QYXvTakdEG4KThfanoKHS9XIvgt7KjspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=);
margin-left:-40px;
}
.openerp .oe_user_sidebar .oe_gamification_goal .oe_goal_failed:before {
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_failed:before {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMVECkXmaDBcAAAAUxJREFUKM+N0jFrVEEUhuFnV1KICS7ExcLCSgiCYJXCxt5C8B+ohYVgYeUfMJBCUIydkCpRLG3EThSxU0ypxMZKYQkSzd7cO3dmLJxNNhckGTgMfHPe+c6ZOZ7Sb7gauOIIq+V2wwVjFjNtYhS4dgh0L1EnvhtzKbGdyQW+8R/ofmJc8r64Ra/hYuJHEbda7nSgB1PQRsVpc2j+xfnEZjncjtz9zLHIw0SdyZH3uwx/wmDq5oaFyKeJc2QzsVOgVzXDveRBp5fAucjbTJ5E5EWYhtDvPkJiC1878rdEdUAZHHQ7FVkrpdaJ35lQXJ8EZveST5a9Zr7lZYFS5HHF2cjztF/ys11OgDP0auYjbwrURFZGzMAvjkfW077z6z/MGjGMfCxQFXnU7fsdvcjq5FsSH1RcnkAty4eM3EqiyTTW6AeuB5aOOOTLgZt/AfLdvLh74DfrAAAAAElFTkSuQmCC);
margin-left:-40px;
}
.openerp .oe_user_sidebar .oe_gamification_goal .oe_goal_reached,
.openerp .oe_user_sidebar .oe_gamification_goal .oe_goal_failed {
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_reached,
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_failed {
text-decoration: line-through;
padding-left: 20px;
}
.openerp .oe_mail_wall .oe_user_sidebar ul {
.openerp .oe_mail_wall .oe_mail_wall_aside ul {
list-style-type: none;
padding-left: 20px;
margin-bottom: 10px;
}
.openerp .oe_mail_wall .oe_user_sidebar li {
.openerp .oe_mail_wall .oe_mail_wall_aside li {
margin-bottom: 10px;
}
.openerp .oe_mail_wall .oe_user_sidebar li progress {
.openerp .oe_mail_wall .oe_mail_wall_aside li progress {
width: 80%;
display: inline-block;
}
.openerp .oe_mail_wall .oe_user_sidebar li p {
.openerp .oe_mail_wall .oe_mail_wall_aside li p {
margin:5px 0;
}
.openerp .oe_mail_wall .oe_mail {
@@ -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'));
}
});
};
@@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="mail.Root">
<t t-jquery="div" t-operation="after">
<div class="oe_user_sidebar" />
</t>
</t>
<t t-name="user_wall">
<templates>
<t t-name="gamification.user_wall_sidebar" class="oe_gamification_user_wall_sidebar">
<div class="oe_gamification_goal"><em>Your goal list is empty</em></div>
</t>
<t t-name="goal_list_to_do">
<t t-name="gamification.goal_list_to_do">
<div t-foreach="widget.goals_info.info" t-as="plan">
<h3><t t-esc="plan.name"/></h3>
<ul class="oe_goals_list">
+1
View File
@@ -195,6 +195,7 @@
</tbody>
</table>
<div class="oe_mail-placeholder"></div>
<aside class="oe_mail_wall_aside"></aside>
</div>
<!--