summaryrefslogtreecommitdiff
path: root/addons/web_planner/static/src
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2016-01-08 16:05:42 +0100
committerSimon Lejeune <sle@openerp.com>2016-01-11 14:27:30 +0100
commit7d30769980cae022184b56b455e3a95c11f6ccae (patch)
tree737668c9bf8ce1b07b6222cf5249456c7bd0359a /addons/web_planner/static/src
parentdd67cb1f235a50593a986f2a94f0511406092359 (diff)
[FIX] web_planner: cleaner way to handle initial percentage
Instead of using a default value of 5%, we now add a fictive first step and consider it as done. this is related to 9a8153ee553f3585b41845217c85df6d061dd418 (fp is watching my ugly commits)
Diffstat (limited to 'addons/web_planner/static/src')
-rw-r--r--addons/web_planner/static/src/js/web_planner_common.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/addons/web_planner/static/src/js/web_planner_common.js b/addons/web_planner/static/src/js/web_planner_common.js
index e18378337ae..90e8afd6dcd 100644
--- a/addons/web_planner/static/src/js/web_planner_common.js
+++ b/addons/web_planner/static/src/js/web_planner_common.js
@@ -56,7 +56,6 @@ var PlannerDialog = Widget.extend({
this._super(parent);
this.planner = planner;
this.cookie_name = this.planner.planner_application + '_last_page';
- this.set('progress', 0);
this.pages = [];
this.menu_items = [];
},
@@ -116,14 +115,18 @@ var PlannerDialog = Widget.extend({
self.trigger('planner_progress_changed', self.get('progress'));
});
this.on('planner_progress_changed', this, this.update_ui_progress_bar);
-
- // re-apply the minimal value of 5 percent if the user manually undid every page
- if (this.planner.progress === 0 && this.get('progress') === 0) {
- this.planner.progress = 5;
- this.set('progress', 5);
+ // set progress to trigger initial UI update
+ var initial_progress = false;
+ if (!this.planner.progress) {
+ var total_pages = 0;
+ this.pages.forEach(function(page) {
+ if (! page.hide_mark_as_done) {
+ total_pages++;
+ }
+ });
+ initial_progress = parseInt(( 1 / (total_pages + 1)) * 100, 10);
}
-
- this.set('progress', this.planner.progress); // set progress to trigger initial UI update
+ this.set('progress', initial_progress || this.planner.progress);
},
_render_done_page: function (page) {
var mark_as_done_button = this.$('.mark_as_done')
@@ -393,11 +396,7 @@ var PlannerDialog = Widget.extend({
done_pages++;
}
});
-
- var percent = parseInt((done_pages / total_pages) * 100, 10);
- if (percent === 0) {
- percent = 5;
- }
+ var percent = parseInt(( (done_pages + 1) / (total_pages + 1)) * 100, 10);
this.set('progress', percent);
this.planner.progress = percent;