[ADD] use sparklines
bzr revid: mat@openerp.com-20130412152150-8679huigt6cfmool
This commit is contained in:
@@ -57,6 +57,7 @@ Both goals and badges are flexibles and can be adapted to a large range of modul
|
||||
'js': [
|
||||
'static/src/js/gamification.js',
|
||||
'static/src/js/justgage.js',
|
||||
'static/src/js/jquery.sparkline.2.1.1.min.js',
|
||||
],
|
||||
'qweb': ['static/src/xml/gamification.xml'],
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ class gamification_goal_plan(osv.Model):
|
||||
|
||||
# most complete first, current if same percentage (eg: if several 100%)
|
||||
sorted_board = enumerate(sorted(board_goals, key=lambda k: (k.completeness, k.current), reverse=True))
|
||||
planlines_boards.append({'goal_type': planline.type_id, 'board_goals': sorted_board})
|
||||
planlines_boards.append({'goal_type': planline.type_id, 'board_goals': sorted_board, 'target_goal': planline.target_goal})
|
||||
return planlines_boards
|
||||
|
||||
def get_indivual_goal_info(self, cr, uid, user_id, plan, subset_goal_ids=False, context=None):
|
||||
|
||||
@@ -58,6 +58,8 @@ class res_users_gamification_group(osv.Model):
|
||||
'type_monetary': planline_board['goal_type'].monetary,
|
||||
'type_unit': planline_board['goal_type'].unit,
|
||||
'type_action': True if planline_board['goal_type'].action_id else False,
|
||||
'type_ponctual': planline_board['goal_type'].ponctual,
|
||||
'target_goal': planline_board['target_goal'],
|
||||
'goals': []}
|
||||
for goal in planline_board['board_goals']:
|
||||
vals['goals'].append({
|
||||
@@ -90,6 +92,7 @@ class res_users_gamification_group(osv.Model):
|
||||
'type_monetary': goal.type_id.monetary,
|
||||
'type_unit': goal.type_id.unit,
|
||||
'type_action': True if goal.type_id.action_id else False,
|
||||
'type_ponctual': goal.type_id.ponctual,
|
||||
'state': goal.state,
|
||||
'completeness': goal.completeness,
|
||||
'computation_mode': goal.computation_mode,
|
||||
|
||||
@@ -74,14 +74,14 @@
|
||||
border: solid 1px rgba(0,0,0,0.03);
|
||||
}
|
||||
|
||||
.openerp .oe_gamification_goal .oe_goal_reached:before {
|
||||
/*.openerp .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:-20px;
|
||||
}
|
||||
.openerp .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:-20px;
|
||||
}
|
||||
}*/
|
||||
.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;
|
||||
@@ -105,9 +105,8 @@
|
||||
vertical-align: center;
|
||||
border: none;
|
||||
}
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table td.col1 { width: 25%; }
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table td.col2 { width: 20%; }
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table td.col3 { width: 45%; }
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table td.col1 { width: 40%; }
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table td.col2 { width: 50%; }
|
||||
/* ... and 10% left for ranking */
|
||||
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside table progress,.oe_form_field_progressbar {
|
||||
|
||||
@@ -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"
|
||||
],
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -10,29 +10,28 @@
|
||||
<t t-if="plan.visibility_mode == 'progressbar'">
|
||||
<ul class="oe_goals_list">
|
||||
<li t-foreach="plan.goals" t-as="goal">
|
||||
<span class="oe_goal_sparkline_piechart"></span>
|
||||
<span class="oe_goal_sparkline_piechart" t-att-data-completeness="goal.completeness"></span>
|
||||
<strong t-attf-class="#{goal.state == 'reached' ? 'oe_goal_reached' : goal.state == 'failed' ? 'oe_goal_failed' : ''}" t-att-title="goal.type_description"><t t-esc="goal.type_name" /></strong>
|
||||
<t t-if="goal.computation_mode == 'manually' or goal.type_action">
|
||||
<a class="oe_goal_action" t-att-id="goal.id">modify</a>
|
||||
</t>
|
||||
<t t-if="goal.type_condition == 'higher'">
|
||||
<p>
|
||||
<t t-esc="goal.current" />/<span t-attf-class="#{goal.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.target_goal"/></span>
|
||||
<t t-if="goal.type_unit"><t t-esc="goal.type_unit"/></t>
|
||||
</p>
|
||||
<p><progress class="oe_goal_progress" t-att-value="goal.completeness" max="100"/></p>
|
||||
</t>
|
||||
<t t-if="goal.type_condition == 'lower'">
|
||||
<p>
|
||||
<t t-esc="goal.current" /> (less than
|
||||
<span t-attf-class="#{goal.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.target_goal"/></span>
|
||||
<t t-if="!goal.type_ponctual">
|
||||
<t t-if="goal.type_condition == 'higher'">
|
||||
<p>
|
||||
<t t-esc="goal.current" />/<span t-attf-class="#{goal.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.target_goal"/></span>
|
||||
<t t-if="goal.type_unit"><t t-esc="goal.type_unit"/></t>
|
||||
)
|
||||
</p>
|
||||
</p>
|
||||
<!-- <p><progress class="oe_goal_progress" t-att-value="goal.completeness" max="100"/></p> -->
|
||||
</t>
|
||||
<t t-if="goal.type_condition == 'lower'">
|
||||
<p>
|
||||
<t t-esc="goal.current" /> (less than
|
||||
<span t-attf-class="#{goal.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.target_goal"/></span>
|
||||
<t t-if="goal.type_unit"><t t-esc="goal.type_unit"/></t>
|
||||
)
|
||||
</p>
|
||||
</t>
|
||||
</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> -->
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
@@ -42,6 +41,7 @@
|
||||
<tr>
|
||||
<th colspan="4" t-attf-title="#{planline.type_description ? planline.type_description : ''}">
|
||||
<t t-esc="planline.type_name"/>
|
||||
(Goal: <span t-attf-class="#{planline.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="planline.target_goal" /></span><t t-if="planline.type_unit"> <t t-esc="planline.type_unit"/></t>)
|
||||
<t t-if="planline.type_computation_mode == 'manually' or planline.type_action">
|
||||
<a class="oe_goal_action" t-att-id="planline.own_goal_id">modify</a>
|
||||
</t>
|
||||
@@ -50,19 +50,22 @@
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Pers.</th>
|
||||
<th>compl.</th>
|
||||
<th>Current</th>
|
||||
<th>current</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="planline.goals" t-as="goal" t-attf-class="#{goal.id == planline.own_goal_id ? 'oe_bold' : ''}">
|
||||
<th><t t-esc="goal.rank" /></th>
|
||||
<td class="col1"><t t-esc="goal.user_name" /></td>
|
||||
<td class="col2"><progress class="oe_goal_progress" t-att-value="goal.completeness" max="100" /></td>
|
||||
<td class="col2">
|
||||
<span class="oe_goal_sparkline_piechart" t-att-data-completeness="goal.completeness"></span>
|
||||
<span t-attf-class="#{planline.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.current" /></span><t t-if="planline.type_unit"> <t t-esc="planline.type_unit"/></t>
|
||||
</td>
|
||||
<!-- <progress class="oe_goal_progress" t-att-value="goal.completeness" max="100" /></td>
|
||||
<td class="col3">
|
||||
<t t-esc="goal.current" />/<span t-attf-class="#{planline.type_monetary ? 'oe_goal_field_monetary' : ''}"><t t-esc="goal.target_goal"/></span>
|
||||
<t t-if="planline.type_unit"><t t-esc="planline.type_unit"/></t>
|
||||
</td>
|
||||
</td> -->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
openerp.hr_gamification = function(instance) {
|
||||
instance.web_kanban.KanbanRecord.include({
|
||||
on_card_clicked: function() {
|
||||
if (this.view.dataset.model === 'gamification.badge') {
|
||||
if (this.record.stat_count.raw_value > 0) {
|
||||
this.$('.oe_kanban_badge_avatars a').first().click();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (this.view.dataset.model === 'gamification.badge.user') {
|
||||
var action = {
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'gamification.badge',
|
||||
view_mode: 'form',
|
||||
view_type: 'form,kanban,tree',
|
||||
views: [[false, 'form']],
|
||||
res_id: this.record.badge_id.raw_value[0]
|
||||
};
|
||||
this.do_action(action);
|
||||
} else {
|
||||
this._super.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user