Skip to content
Snippets Groups Projects
Commit bcca4a44 authored by qsm-odoo's avatar qsm-odoo
Browse files

[IMP] web(_planner),website: navbars & menus merge

Merge appswitcher navbar and app navbar.
Merge planner menu and user menu.
parent 615ff654
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ var Widget = require('web.Widget');
var _t = core._t;
var QWeb = core.qweb;
var SystrayMenu = Widget.extend({
var UserMenu = Widget.extend({
template: "UserMenu",
init: function(parent) {
this._super(parent);
......@@ -55,8 +55,33 @@ var SystrayMenu = Widget.extend({
};
this.update_promise = this.update_promise.then(fct, fct);
},
on_menu_logout: function() {
this.trigger('user_logout');
on_menu_documentation: function () {
window.open('https://www.odoo.com/documentation/user', '_blank');
},
on_menu_support: function () {
window.open('https://www.odoo.com/buy', '_blank');
},
on_menu_about: function () {
var self = this;
if (odoo.db_info) {
menu_help_about(odoo.db_info);
} else {
this.rpc("/web/webclient/version_info", {}).done(menu_help_about);
}
function menu_help_about(db_info) {
var $help = $(QWeb.render("UserMenu.about", {db_info: db_info}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
window.location = $.param.querystring(window.location.href, 'debug');
});
new Dialog(self, {
size: 'medium',
dialogClass: 'o_act_window',
title: _t("About"),
$content: $help
}).open();
}
},
on_menu_settings: function() {
var self = this;
......@@ -88,7 +113,10 @@ var SystrayMenu = Widget.extend({
});
});
},
on_menu_logout: function() {
this.trigger('user_logout');
},
});
return SystrayMenu;
return UserMenu;
});
......@@ -79,6 +79,10 @@
<span class="oe_topbar_name"/> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="#" data-menu="documentation">Documentation</a></li>
<li><a href="#" data-menu="support">Support</a></li>
<li><a href="#" data-menu="about">About</a></li>
<li class="divider"/>
<li><a href="#" data-menu="settings">Preferences</a></li>
<li><a href="#" data-menu="account">My Odoo.com account</a></li>
<li><a href="#" data-menu="logout">Log out</a></li>
......@@ -86,6 +90,48 @@
</li>
</t>
<div t-name="UserMenu.about" class="oe_about">
<div class="container-fluid">
<div class="row">
<a class="oe_activate_debug_mode oe_right label label-primary" href="?debug" >Activate the developer mode</a>
</div>
<div class="row">
<div class="col-sm-offset-2 col-md-offset-2 col-sm-8 col-md-8 user-details">
<div class="user-image">
<img src="/web/static/src/img/logo2.png" alt="Odoo (Formerly OpenERP)" title="Odoo (Formerly OpenERP)" class="img-circle"/>
</div>
<div class="user-info-block">
<div class="user-heading">
<h3>
Version <t t-esc="db_info.server_version"/>
(Community Edition)
</h3>
<t t-if="db_info.expiration_date">
<h5>Database expiration: <t t-esc="new moment(db_info.expiration_date).format('LL')"/></h5>
</t>
</div>
<div class="user-body">
<div class="tab-content">
<div id="settings" class="tab-pane active">
<h4>Copyright © 2004-2015 Odoo S.A.</h4>
<p>Odoo is a trademark of <a target="_blank" href="https://www.odoo.com" style="text-decoration: underline;">Odoo S.A.</a></p>
<p>Licenced under the terms of <a target="_blank" href="http://www.gnu.org/licenses/lgpl.html" style="text-decoration: underline;">GNU Lesser General Public License</a></p>
<p>For more information visit <a target="_blank" href="https://www.odoo.com" style="text-decoration: underline;">Odoo.com</a></p>
<p>
<a href="https://www.odoo.com/web/about/facebook"><i class="fa fa-facebook-square fa-3x social-fb"></i></a>
<a href="https://www.odoo.com/web/about/twitter"><i class="fa fa-twitter-square fa-3x social-tw"></i></a>
<a href="https://www.odoo.com/web/about/googleplus"><i class="fa fa-google-plus-square fa-3x social-gp"></i></a>
<a href="https://www.odoo.com/web/about/linkedin"><i class="fa fa-linkedin-square fa-3x social-lk"></i></a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<t t-name="WebClient.timezone_warning">
<i class="fa fa-exclamation-triangle oe_tz_warning"></i>
</t>
......
......@@ -13,7 +13,7 @@ var QWeb = core.qweb;
var _t = core._t;
var PlannerDialog = planner.PlannerDialog;
var PlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
var PlannerLauncher = Widget.extend({
template: "PlannerLauncher",
init: function(parent) {
this._super(parent);
......@@ -25,12 +25,10 @@ var PlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
core.bus.on("change_menu_section", self, self.on_menu_clicked);
var res = self._super.apply(this, arguments).then(function() {
self.$el.filter('.o_planner_systray').on('click', self, self.show_dialog.bind(self));
self.$el.filter('.o_planner_help').on('click', '.dropdown-menu li a[data-menu]', self.on_menu_help);
self.$el.on('click', self, self.show_dialog.bind(self));
return self.fetch_application_planner();
}).then(function(apps) {
self.$el.filter('.o_planner_systray').hide(); // hidden by default
self.$el.filter('.o_planner_help').find('.o_planner_link').hide();
self.$el.hide(); // hidden by default
self.$('.progress').tooltip({html: true, placement: 'bottom', delay: {'show': 500}});
self.planner_apps = apps;
return apps;
......@@ -58,8 +56,7 @@ var PlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
this.setup(this.planner_apps[menu_id]);
this.need_reflow = true;
} else {
this.$el.filter('.o_planner_systray').hide();
this.$el.filter('.o_planner_help').find('.o_planner_link').hide();
this.$el.hide();
this.need_reflow = true;
}
if (this.need_reflow) {
......@@ -96,7 +93,7 @@ var PlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
} else {
this.$(".progress").show();
}
this.$el.filter('.o_planner_systray').show();
this.$el.show();
this.$(".progress-bar").css('width', percent+"%");
},
show_dialog: function() {
......
......@@ -413,52 +413,8 @@ var PlannerDialog = Widget.extend({
}
});
var PlannerHelpMixin = {
on_menu_help: function(ev) {
ev.preventDefault();
var menu = $(ev.currentTarget).data('menu');
if (menu === 'about') {
if (!odoo.db_info) {
var self = this;
this.rpc("/web/webclient/version_info", {}).done(function(db_info) {
self.on_menu_help_about(db_info);
});
} else {
this.on_menu_help_about(odoo.db_info);
}
} else if (menu === 'documentation') {
window.open('https://www.odoo.com/documentation/user', '_blank');
} else if (menu === 'planner') {
if (this.dialog) this.show_dialog();
} else if (menu === 'support') {
if (odoo.db_info && odoo.db_info.server_version_info[5] === 'c') {
window.open('https://www.odoo.com/buy', '_blank');
} else {
window.location.href = 'mailto:help@odoo.com';
}
}
},
on_menu_help_about: function(db_info) {
var $help = $(QWeb.render("PlannerLauncher.about", {db_info: db_info}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
window.location = $.param.querystring( window.location.href, 'debug');
});
new Dialog(this, {
size: 'medium',
dialogClass: 'o_act_window',
title: _t("About"),
$content: $help
}).open();
},
};
return {
PlannerDialog: PlannerDialog,
PlannerHelpMixin: PlannerHelpMixin,
};
});
......
......@@ -29,9 +29,8 @@
/**************** MENU PROGRESS BAR ****************/
.o_planner_systray {
width: 100px;
> .progress {
width: 70px;
height: 13px;
cursor: pointer;
......
......@@ -5,63 +5,6 @@
<li class="o_planner_systray hidden-xs">
<div class="progress"><div class="progress-bar"/></div>
</li>
<li class="o_planner_help">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="Open Help Menu" aria-expanded="false">
<span class="fa fa-question-circle"/>
<b class="caret"/>
</a>
<ul class="dropdown-menu" role="menu">
<li class="o_planner_link"><a href="#" data-menu="planner">Planner</a></li>
<li><a href="#" data-menu="documentation">Documentation</a></li>
<li><a href="#" data-menu="support">Support</a></li>
<li><a href="#" data-menu="about">About</a></li>
</ul>
</li>
</t>
<t t-name="PlannerLauncher.about">
<div class="oe_about">
<div class="container-fluid">
<div class="row">
<a class="oe_activate_debug_mode oe_right label label-primary" href="?debug" >Activate the developer mode</a>
</div>
<div class="row">
<div class="col-sm-offset-2 col-md-offset-2 col-sm-8 col-md-8 user-details">
<div class="user-image">
<img src="/web/static/src/img/logo2.png" alt="Odoo (Formerly OpenERP)" title="Odoo (Formerly OpenERP)" class="img-circle"/>
</div>
<div class="user-info-block">
<div class="user-heading">
<h3>
Version <t t-esc="db_info.server_version"/>
(<span t-esc="db_info.server_version_info[5] == 'e'?'Enterprise':'Community'"/> Edition)
</h3>
<t t-if="db_info.expiration_date">
<h5>Database expiration: <t t-esc="new moment(db_info.expiration_date).format('LL')"/></h5>
</t>
</div>
<div class="user-body">
<div class="tab-content">
<div id="settings" class="tab-pane active">
<h4>Copyright © 2004-2015 Odoo S.A.</h4>
<p>Odoo is a trademark of <a target="_blank" href="https://www.odoo.com" style="text-decoration: underline;">Odoo S.A.</a></p>
<p>Licenced under the terms of <a target="_blank" href="http://www.gnu.org/licenses/lgpl.html" style="text-decoration: underline;">GNU Lesser General Public License</a></p>
<p>For more information visit <a target="_blank" href="https://www.odoo.com" style="text-decoration: underline;">Odoo.com</a></p>
<p>
<a href="https://www.odoo.com/web/about/facebook"><i class="fa fa-facebook-square fa-3x social-fb"></i></a>
<a href="https://www.odoo.com/web/about/twitter"><i class="fa fa-twitter-square fa-3x social-tw"></i></a>
<a href="https://www.odoo.com/web/about/googleplus"><i class="fa fa-google-plus-square fa-3x social-gp"></i></a>
<a href="https://www.odoo.com/web/about/linkedin"><i class="fa fa-linkedin-square fa-3x social-lk"></i></a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</t>
<div t-name="PlannerDialog" class="modal" id="PlannerDialog" tabindex="-1" role="dialog" aria-labelledby="PlannerDialogLabel" aria-hidden="true">
......@@ -98,7 +41,6 @@
</div>
</div>
<t t-name="PlannerMenu">
<li t-foreach="orphan_pages" t-as="orphan_page">
<a t-att-href="'#' + menu_item_page_map[orphan_page]"><span class="fa fa-fw"/><t t-esc="orphan_page"/></a>
......@@ -110,5 +52,4 @@
</li>
</t>
</t>
</templates>
......@@ -14,14 +14,13 @@ if(!$('#oe_systray').length) {
return $.Deferred().reject("DOM doesn't contain '#oe_systray'");
}
var WebsitePlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
var WebsitePlannerLauncher = Widget.extend({
template: "PlannerLauncher",
start: function() {
var self = this;
var res = this._super.apply(this, arguments);
return res.then(this.get_website_planner.bind(this)).then(function(planner) {
self.$el.filter('.o_planner_systray').on('click', self, self.show_dialog.bind(self));
self.$el.filter('.o_planner_help').on('click', '.dropdown-menu li a[data-menu]', self.on_menu_help);
self.$el.on('click', self, self.show_dialog.bind(self));
if (planner.length) {
self.planner = planner[0];
self.planner.data = $.parseJSON(planner[0].data) || {};
......@@ -51,9 +50,9 @@ var WebsitePlannerLauncher = Widget.extend(planner.PlannerHelpMixin, {
});
return ajax.loadXML('/web_planner/static/src/xml/web_planner.xml', qweb).then(function() {
var websitePlannerLauncher = new WebsitePlannerLauncher();
websitePlannerLauncher.prependTo($('#oe_systray'));
});
var websitePlannerLauncher = new WebsitePlannerLauncher();
websitePlannerLauncher.prependTo($('#oe_systray'));
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment