[IMP] mail & web menu: code review for reload menu
bzr revid: chm@openerp.com-20121113160248-1p2003uc9f5nnxnm
This commit is contained in:
parent
fa8f27307a
commit
0cf93f912b
|
@ -1002,8 +1002,8 @@ class Menu(openerpweb.Controller):
|
|||
_cp_path = "/web/menu"
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def load(self, req):
|
||||
return {'data': self.do_load(req)}
|
||||
def load(self, req, menu_id=None):
|
||||
return {'data': self.do_load(req=req, menu_id=menu_id)}
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_user_roots(self, req):
|
||||
|
@ -1031,7 +1031,7 @@ class Menu(openerpweb.Controller):
|
|||
|
||||
return Menus.search(menu_domain, 0, False, False, context)
|
||||
|
||||
def do_load(self, req):
|
||||
def do_load(self, req, menu_id=None):
|
||||
""" Loads all menu items (all applications and their sub-menus).
|
||||
|
||||
:param req: A request object, with an OpenERP session attribute
|
||||
|
@ -1047,9 +1047,9 @@ class Menu(openerpweb.Controller):
|
|||
|
||||
# menus are loaded fully unlike a regular tree view, cause there are a
|
||||
# limited number of items (752 when all 6.1 addons are installed)
|
||||
if req.context and 'default_menu' in req.context and int(req.context['default_menu']):
|
||||
if menu_id:
|
||||
# for load only one sub menu
|
||||
menu_ids = Menus.search([['id', 'child_of', req.context['default_menu']]], 0, False, False, context)
|
||||
menu_ids = Menus.search([['id', 'child_of', menu_id]], 0, False, False, context)
|
||||
else:
|
||||
menu_ids = Menus.search([], 0, False, False, context)
|
||||
menu_items = Menus.read(menu_ids, ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled', 'needaction_counter'], context)
|
||||
|
|
|
@ -708,17 +708,9 @@ instance.web.Menu = instance.web.Widget.extend({
|
|||
this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
|
||||
return this.do_reload();
|
||||
},
|
||||
do_reload: function(id) {
|
||||
do_reload: function() {
|
||||
var self = this;
|
||||
return this.rpc("/web/menu/load", id ? {'context': {'default_menu': id}} : {}).done(function(r) {
|
||||
if (id) {
|
||||
_.each(self.data.data.children, function (val) {
|
||||
if (val.id == id) {
|
||||
val.children = _.find(r.data.children, function (r_val) {return r_val.id == id;}).children;
|
||||
}
|
||||
});
|
||||
var r = self.data;
|
||||
}
|
||||
return this.rpc("/web/menu/load", {}).done(function(r) {
|
||||
self.menu_loaded(r);
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue