diff options
| author | Simon Lejeune <sle@openerp.com> | 2015-07-17 14:51:33 +0200 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2015-07-23 14:02:40 +0200 |
| commit | 5666cd3643941bbf0b998ec5fe0b65b82ff29932 (patch) | |
| tree | 9ef9b52e4a27c759151c0f4d26fa78f182267661 /addons/web_planner/static/src/js/web_planner_backend.js | |
| parent | 2de2a8064ceb0b5ec7bda1c6e00209c461a981fe (diff) | |
[REF] web_planner: javascript & dom cleaning
* Correct inheritance of async method
* Correct calls to do_hide/show
* Fetch the template in `willStart`
* Correct bootstrap structure for the layout, remove useless branding
and dom depth
* Each planner page is now in its own bootstrap grid
* Compatibility between both webclients
Diffstat (limited to 'addons/web_planner/static/src/js/web_planner_backend.js')
| -rw-r--r-- | addons/web_planner/static/src/js/web_planner_backend.js | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/addons/web_planner/static/src/js/web_planner_backend.js b/addons/web_planner/static/src/js/web_planner_backend.js index 6a4e3a35825..01fdfbe1631 100644 --- a/addons/web_planner/static/src/js/web_planner_backend.js +++ b/addons/web_planner/static/src/js/web_planner_backend.js @@ -6,7 +6,7 @@ var Model = require('web.Model'); var SystrayMenu = require('web.SystrayMenu'); var Widget = require('web.Widget'); var planner = require('web.planner.common'); -var WebClient = require('web.WebClient'); +var webclient = require('web.web_client'); var PlannerDialog = planner.PlannerDialog; @@ -18,19 +18,19 @@ var PlannerLauncher = Widget.extend({ init: function(parent) { this._super(parent); this.planner_by_menu = {}; - this.webclient = parent.getParent(); this.need_reflow = false; }, start: function() { var self = this; - self._super(); - - self.webclient.menu.on("open_menu", self, self.on_menu_clicked); - self.$el.hide(); // hidden by default - return self.fetch_application_planner().done(function(apps) { + core.bus.on("change_menu_section", self, self.on_menu_clicked); + var res = self._super.apply(this, arguments).then(function() { + return self.fetch_application_planner(); + }).then(function(apps) { + self.do_hide(); // hidden by default self.planner_apps = apps; return apps; }); + return res; }, fetch_application_planner: function() { var self = this; @@ -48,13 +48,12 @@ var PlannerLauncher = Widget.extend({ } return def; }, - on_menu_clicked: function(id, $clicked_menu) { - var menu_id = $clicked_menu.parents('.oe_secondary_menu').data('menu-parent') || 0; // find top menu id + on_menu_clicked: function(menu_id) { if (_.contains(_.keys(this.planner_apps), menu_id.toString())) { this.setup(this.planner_apps[menu_id]); this.need_reflow = true; } else { - this.$el.hide(); + this.do_hide(); this.hide_dialog(); this.need_reflow = true; } @@ -65,9 +64,6 @@ var PlannerLauncher = Widget.extend({ }, setup: function(planner){ var self = this; - var webclient = this.findAncestor(function (a) { - return a instanceof WebClient; - }); this.planner = planner; if (this.dialog) { @@ -81,30 +77,25 @@ var PlannerLauncher = Widget.extend({ self.update_parent_progress_bar(percent); }); }, - // event update_parent_progress_bar: function(percent) { if (percent == 100) { this.$(".progress").hide(); } else { this.$(".progress").show(); } - this.$el.show(); + this.do_show(); this.$(".progress-bar").css('width', percent+"%"); }, hide_dialog: function() { if (this.dialog) { - this.dialog.$el.hide(); + this.dialog.do_hide(); } }, toggle_dialog: function() { - this.dialog.$el.toggle(); + this.dialog.do_toggle(); } }); -// add planner launcher to the systray -// if it is empty, it won't be display. Then, each time a top menu is clicked -// a planner will be given to the launcher. The launcher will appears if the -// given planner is not null. SystrayMenu.Items.push(PlannerLauncher); return { @@ -112,3 +103,4 @@ return { }; }); + |
