summaryrefslogtreecommitdiff
path: root/addons/web/static
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
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')
-rw-r--r--addons/web/static/src/js/chrome.js19
-rw-r--r--addons/web/static/src/xml/base.xml12
2 files changed, 26 insertions, 5 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') {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index e742f336dc0..5ad24a43a6a 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -388,14 +388,16 @@
t-att-data-action-model="menu.action ? menu.action.split(',')[0] : ''"
t-att-data-action-id="menu.action ? menu.action.split(',')[1] : ''">
<t t-esc="menu.name"/>
- <t t-if="menu.needaction_enabled and menu.needaction_counter">
- <div class="oe_tag oe_tag_dark oe_menu_counter">
- <t t-if="menu.needaction_counter &gt; 99"> 99+ </t><t t-if="menu.needaction_counter &lt;= 99"> <t t-esc="menu.needaction_counter"/> </t>
- </div>
- </t>
</a>
</t>
+<t t-name="Menu.needaction_counter">
+ <div class="oe_tag oe_tag_dark oe_menu_counter">
+ <t t-if="widget.needaction_counter &gt; 99"> 99+ </t>
+ <t t-if="widget.needaction_counter &lt;= 99"> <t t-esc="widget.needaction_counter"/> </t>
+ </div>
+</t>
+
<t t-name="UserMenu">
<span class="oe_user_menu oe_topbar_item oe_dropdown_toggle oe_dropdown_arrow">
<img class="oe_topbar_avatar" t-att-data-default-src="_s + '/web/static/src/img/user_menu_avatar.png'"/>