summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome/apps_menu.js7
-rw-r--r--addons/web/static/src/js/chrome/menu.js6
-rw-r--r--addons/web/static/src/js/chrome/web_client.js51
3 files changed, 32 insertions, 32 deletions
diff --git a/addons/web/static/src/js/chrome/apps_menu.js b/addons/web/static/src/js/chrome/apps_menu.js
index eb7faaa971b..b7e057f80fb 100644
--- a/addons/web/static/src/js/chrome/apps_menu.js
+++ b/addons/web/static/src/js/chrome/apps_menu.js
@@ -38,14 +38,17 @@ var AppsMenu = Widget.extend({
return this._apps;
},
/**
- * Open the first app in the list of apps
+ * Open the first app in the list of apps. Returns whether one was found.
+ *
+ * @returns {Boolean}
*/
openFirstApp: function () {
if (!this._apps.length) {
- return
+ return false;
}
var firstApp = this._apps[0];
this._openApp(firstApp);
+ return true;
},
//--------------------------------------------------------------------------
diff --git a/addons/web/static/src/js/chrome/menu.js b/addons/web/static/src/js/chrome/menu.js
index 4f6ba3bd5f9..28585aa1df7 100644
--- a/addons/web/static/src/js/chrome/menu.js
+++ b/addons/web/static/src/js/chrome/menu.js
@@ -197,10 +197,12 @@ var Menu = Widget.extend({
return this.current_primary_menu;
},
/**
- * Open the first app
+ * Open the first app, returns whether an application was found.
+ *
+ * @returns {Boolean}
*/
openFirstApp: function () {
- this._appsMenu.openFirstApp();
+ return this._appsMenu.openFirstApp();
},
//--------------------------------------------------------------------------
diff --git a/addons/web/static/src/js/chrome/web_client.js b/addons/web/static/src/js/chrome/web_client.js
index e12f22fcf05..3522a7fc109 100644
--- a/addons/web/static/src/js/chrome/web_client.js
+++ b/addons/web/static/src/js/chrome/web_client.js
@@ -74,36 +74,31 @@ return AbstractWebClient.extend({
return menuData;
});
},
- show_application: function () {
- var self = this;
+ async show_application() {
this.set_title();
- return this.menu_dp.add(this.instanciate_menu_widgets()).then(function () {
- $(window).bind('hashchange', self.on_hashchange);
-
- // If the url's state is empty, we execute the user's home action if there is one (we
- // show the first app if not)
- var state = $.bbq.getState(true);
- if (_.keys(state).length === 1 && _.keys(state)[0] === "cids") {
- return self.menu_dp.add(self._rpc({
- model: 'res.users',
- method: 'read',
- args: [session.uid, ["action_id"]],
- }))
- .then(function (result) {
- var data = result[0];
- if (data.action_id) {
- return self.do_action(data.action_id[0]).then(function () {
- self.menu.change_menu_section(self.menu.action_id_to_primary_menu_id(data.action_id[0]));
- });
- } else {
- self.menu.openFirstApp();
- }
- });
- } else {
- return self.on_hashchange();
- }
- });
+ await this.menu_dp.add(this.instanciate_menu_widgets());
+ $(window).bind('hashchange', this.on_hashchange);
+
+ const state = $.bbq.getState(true);
+ if (!_.isEqual(_.keys(state), ["cids"])) {
+ return this.on_hashchange();
+ }
+
+ const [data] = await this.menu_dp.add(this._rpc({
+ model: 'res.users',
+ method: 'read',
+ args: [session.uid, ["action_id"]],
+ }));
+ if (data.action_id) {
+ await this.do_action(data.action_id[0]);
+ this.menu.change_menu_section(this.menu.action_id_to_primary_menu_id(data.action_id[0]));
+ return;
+ }
+
+ if (!this.menu.openFirstApp()) {
+ this.trigger_up('webclient_started');
+ }
},
instanciate_menu_widgets: function () {