summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-12-10 14:16:58 +0100
committerThibault Delavallée <tde@openerp.com>2012-12-10 14:16:58 +0100
commit5d2d4dea2cae780f1b42718170b3aedeb2f0df73 (patch)
treebb98ec7f4822b39d19590386e36941213a06d3ae /addons/web/static/src/js
parent70f8f99b35c93a880cf15a1f21b7f88aef5a8d36 (diff)
parent1ca5e68b1f3ddb440b104c6c47ea35e8d26a1eed (diff)
[MERGE] Needaction loading update.
This web revision modifies the way needaction are loaded. Now they are loaded independently of the menus. After having loaded and displayed the various menus, a call to the server is done to avoid a long latency between the login and the display of menus. Needaction counter will be displayed as soon as they are available. bzr revid: tde@openerp.com-20121210131658-pgy3t9t71f0z2yd5
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 5783afb987a..55e14d6d783 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -799,10 +799,18 @@ instance.web.client_actions.add("change_password", "instance.web.ChangePassword"
instance.web.Menu = instance.web.Widget.extend({
template: 'Menu',
init: function() {
+ var self = this;
this._super.apply(this, arguments);
this.has_been_loaded = $.Deferred();
this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
this.data = {data:{children:[]}};
+ this.on("menu_loaded", this, function (e) {
+ // launch the fetch of needaction counters, asynchronous
+ this.rpc("/web/menu/load_needaction", {menu_ids: false}).done(function(r) {
+ self.on_needaction_loaded(r);
+ });
+ });
+
},
start: function() {
this._super.apply(this, arguments);
@@ -836,6 +844,17 @@ instance.web.Menu = instance.web.Widget.extend({
this.trigger('menu_loaded', data);
this.has_been_loaded.resolve();
},
+ on_needaction_loaded: function(data) {
+ var self = this;
+ this.needaction_data = data;
+ _.each(this.needaction_data.data, function (item, menu_id) {
+ var $item = self.$secondary_menus.find('a[data-menu="' + menu_id + '"]');
+ $item.remove('oe_menu_counter');
+ if (item.needaction_counter && item.needaction_counter > 0) {
+ $item.append(QWeb.render("Menu.needaction_counter", { widget : item }));
+ }
+ });
+ },
limit_entries: function() {
var maximum_visible_links = this.maximum_visible_links;
if (maximum_visible_links === 'auto') {