From 56b3db82192d6ed2dad45982ebce9f471cf7c0cf Mon Sep 17 00:00:00 2001 From: Martin Trigaux <mat@openerp.com> Date: Fri, 12 Sep 2014 10:37:14 +0200 Subject: [PATCH] [IMP] gamification: usability and shit Challenge - 'Reward as soon as every goal is reached' box checked by default (most of the time people want this behaviour, few special cases were do not) - Click on challenge kanban opens goal list instead of challenge form - Add button 'Start Challenge' clicking on statusbar is not intuitive Badge - When creates a challenge from badge view, set by default badge to 'For Every Succeding User' field - replace filter 'Current' vs 'Passed' by 'Running' (in progress and done with not reached end date) vs 'Done' (done & failed without end date or end date passed) Goal - list of badge on employee form not the first tab --- addons/gamification/models/challenge.py | 6 +++++- .../gamification/static/src/js/gamification.js | 11 ----------- addons/gamification/views/badge.xml | 2 +- addons/gamification/views/challenge.xml | 9 ++------- addons/gamification/views/goal.xml | 16 ++++++++++++---- addons/hr_gamification/views/gamification.xml | 4 +--- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 2a1c6d5b0a5b..4e128fc8f12b 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -204,6 +204,7 @@ class gamification_challenge(osv.Model): 'category': 'hr', 'reward_failure': False, 'report_template_id': lambda s, *a, **k: s._get_report_template(*a, **k), + 'reward_realtime': True, } @@ -361,6 +362,9 @@ class gamification_challenge(osv.Model): return True + def action_start(self, cr, uid, ids, context=None): + """Start a challenge""" + return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) def action_check(self, cr, uid, ids, context=None): """Check a challenge @@ -707,7 +711,7 @@ class gamification_challenge(osv.Model): rewarded_users = [] challenge_ended = end_date == yesterday.strftime(DF) or force - if challenge.reward_id and challenge_ended or challenge.reward_realtime: + if challenge.reward_id and (challenge_ended or challenge.reward_realtime): # not using start_date as intemportal goals have a start date but no end_date reached_goals = self.pool.get('gamification.goal').read_group(cr, uid, [ ('challenge_id', '=', challenge.id), diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 6e2e52019689..0c02162e59fb 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -125,16 +125,5 @@ openerp.gamification = function(instance) { sidebar.appendTo($('.oe_mail_wall_aside')); }, }); - - instance.web_kanban.KanbanRecord.include({ - // open related goals when clicking on challenge kanban view - on_card_clicked: function() { - if (this.view.dataset.model === 'gamification.challenge') { - this.$('.oe_kanban_project_list a').first().click(); - } else { - this._super.apply(this, arguments); - } - }, - }); }; diff --git a/addons/gamification/views/badge.xml b/addons/gamification/views/badge.xml index 302ad66caf02..315ccd683084 100644 --- a/addons/gamification/views/badge.xml +++ b/addons/gamification/views/badge.xml @@ -75,7 +75,7 @@ </div> </group> <group string="Rewards for challenges"> - <field name="challenge_ids" widget="many2many_kanban" nolabel="1" /> + <field name="challenge_ids" widget="many2many_kanban" nolabel="1" context="{'default_reward_id': active_id}" /> </group> <group string="Statistics"> <group> diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml index 9c76b73bdae4..75515c421831 100644 --- a/addons/gamification/views/challenge.xml +++ b/addons/gamification/views/challenge.xml @@ -34,6 +34,7 @@ <field name="arch" type="xml"> <form string="Goal definitions"> <header> + <button string="Start Challenge" type="object" name="action_start" states="draft" class="oe_highlight"/> <button string="Refresh Challenge" type="object" name="action_check" states="inprogress"/> <button string="Send Report" type="object" name="action_report_progress" states="inprogress,done" groups="base.group_no_one"/> <field name="state" widget="statusbar" clickable="True"/> @@ -48,7 +49,7 @@ <label for="user_domain" class="oe_edit_only" string="Assign Challenge To"/> <div> <field name="user_domain" widget="char_domain" options="{'model': 'res.users'}" /> - <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" /> + <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" readonly="True" /> </div> </div> @@ -142,12 +143,6 @@ <templates> <t t-name="kanban-box"> <div t-attf-class="oe_kanban_card oe_kanban_goal oe_kanban_global_click"> - <div class="oe_dropdown_toggle oe_dropdown_kanban"> - <span class="oe_e">Ã</span> - <ul class="oe_dropdown_menu"> - <li><a type="edit">Configure Challenge</a></li> - </ul> - </div> <div class="oe_kanban_content"> <strong> <h4 class="text-center"><field name="name"/></h4> diff --git a/addons/gamification/views/goal.xml b/addons/gamification/views/goal.xml index ed0702f9a525..e8081f4bc21c 100644 --- a/addons/gamification/views/goal.xml +++ b/addons/gamification/views/goal.xml @@ -98,13 +98,21 @@ <filter name="my" string="My Goals" domain="[('user_id', '=', uid)]"/> <separator/> <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]"/> - <filter name="inprogress" string="Current" + <filter name="inprogress" string="Running" domain="[ '|', ('state', '=', 'inprogress'), - ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d')) - ]"/> - <filter name="closed" string="Passed" domain="[('state', 'in', ('reached', 'failed'))]"/> + '&', + ('state', 'in', ('done', 'failed')), + ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d')) + ]"/> + <filter name="closed" string="Done" + domain="[ + ('state', 'in', ('reached', 'failed')), + '|', + ('end_date', '=', False), + ('end_date', '<', context_today().strftime('%%Y-%%m-%%d')) + ]"/> <separator/> <field name="user_id"/> diff --git a/addons/hr_gamification/views/gamification.xml b/addons/hr_gamification/views/gamification.xml index 60c758a717d6..1c95fef53d51 100644 --- a/addons/hr_gamification/views/gamification.xml +++ b/addons/hr_gamification/views/gamification.xml @@ -21,7 +21,7 @@ <field name="inherit_id" ref="hr.view_employee_form"/> <field name="arch" type="xml"> - <xpath expr="//page[@string='Public Information']" position="before"> + <xpath expr="//page[@string='Public Information']" position="after"> <page string="Received Badges" attrs="{'invisible': [('user_id', '=', False)]}"> <field name="has_badges" invisible="1"/> <button string="Grant a Badge" type="action" name="%(action_reward_wizard)d"/> to reward this employee for a good action @@ -34,8 +34,6 @@ </div> <field name="badge_ids" widget="many2many_kanban" /> </page> - </xpath> - <xpath expr="//page[@string='Public Information']" position="after"> <page string="Goals"> <field name="goal_ids" widget="many2many_kanban" /> </page> -- GitLab