diff options
| author | Joren Van Onder <jov@odoo.com> | 2015-07-02 11:43:49 +0200 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2015-07-23 13:56:07 +0200 |
| commit | b2eafca067b71f45864d543d0ebede37e2c25e26 (patch) | |
| tree | 9233c152c5a0a650e32aa3627a04f41bdf8c8384 /addons/web_planner/static/src/js/web_planner_backend.js | |
| parent | c505f00c3e726369ce3fbc54d8a3cc625eda5764 (diff) | |
[REF] web_planner: refactor to make less brittle and reliant on layout
This introduces a new way to define web_planners. They now take the
following form:
<template id="project_planner">
<t t-call="web_planner.pages">
<t t-call="web_planner.category">
<t t-set="menu_categorytitle" t-value="'Prepare'"/>
<t t-set="menu_categoryclasses" t-value="'fa-flag-checkered'"/>
<t t-call="web_planner.page">
<t t-set="page_title" t-value="'Welcome'"/>
<t t-set="hide_mark_as_done" t-value="True"/>
<t t-set="hide_from_menu" t-value="True"/>
<!-- content here -->
</t>
</t>
</template>
The menu is not manually created anymore, it is automatically generated.
Pages do not have to be part of a category and can just be defined as
children of web_planner.pages. A page can have hide_mark_as_done and
hide_from_menu, these are optional and will both default to False when
omitted.
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 | 30 |
1 files changed, 21 insertions, 9 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 b66abf2b414..6a4e3a35825 100644 --- a/addons/web_planner/static/src/js/web_planner_backend.js +++ b/addons/web_planner/static/src/js/web_planner_backend.js @@ -1,10 +1,12 @@ odoo.define('web.planner', function (require) { "use strict"; +var core = require('web.core'); 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 PlannerDialog = planner.PlannerDialog; @@ -52,26 +54,32 @@ var PlannerLauncher = Widget.extend({ this.setup(this.planner_apps[menu_id]); this.need_reflow = true; } else { - if (this.$el.is(":visible")) { - this.$el.hide(); - this.need_reflow = true; - } + this.$el.hide(); + this.hide_dialog(); + this.need_reflow = true; } if (this.need_reflow) { - this.webclient.menu.reflow(); + core.bus.trigger('resize'); this.need_reflow = false; } }, setup: function(planner){ var self = this; + var webclient = this.findAncestor(function (a) { + return a instanceof WebClient; + }); + this.planner = planner; - this.dialog && this.dialog.destroy(); + if (this.dialog) { + this.dialog.destroy(); + } this.dialog = new PlannerDialog(this, planner); + this.dialog.$el.remove(); + this.dialog.appendTo(webclient.$el); this.$(".o_planner_progress").tooltip({html: true, title: this.planner.tooltip_planner, placement: 'bottom', delay: {'show': 500}}); this.dialog.on("planner_progress_changed", this, function(percent){ self.update_parent_progress_bar(percent); }); - this.dialog.appendTo(document.body); }, // event update_parent_progress_bar: function(percent) { @@ -83,8 +91,13 @@ var PlannerLauncher = Widget.extend({ this.$el.show(); this.$(".progress-bar").css('width', percent+"%"); }, + hide_dialog: function() { + if (this.dialog) { + this.dialog.$el.hide(); + } + }, toggle_dialog: function() { - this.dialog.$('#PlannerModal').modal('toggle'); + this.dialog.$el.toggle(); } }); @@ -99,4 +112,3 @@ return { }; }); - |
