[IMP] ir_ui_menu: trunk to 7.0 dynamic counters
bzr revid: chm@openerp.com-20130417133438-1g8h8hezbn1vtjj1
This commit is contained in:
parent
56b5446431
commit
027bf19a7a
|
@ -861,9 +861,7 @@ instance.web.Menu = instance.web.Widget.extend({
|
|||
self.reflow();
|
||||
// launch the fetch of needaction counters, asynchronous
|
||||
if (!_.isEmpty(menu_data.all_menu_ids)) {
|
||||
this.rpc("/web/menu/load_needaction", {menu_ids: menu_data.all_menu_ids}).done(function(r) {
|
||||
self.on_needaction_loaded(r);
|
||||
});
|
||||
this.do_load_needaction(menu_data.all_menu_ids);
|
||||
}
|
||||
});
|
||||
var lazyreflow = _.debounce(this.reflow.bind(this), 200);
|
||||
|
@ -885,19 +883,24 @@ instance.web.Menu = instance.web.Widget.extend({
|
|||
});
|
||||
},
|
||||
menu_loaded: function(data) {
|
||||
var self = this;
|
||||
this.data = {data: data};
|
||||
this.renderElement();
|
||||
this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
|
||||
this.$el.on('click', 'a[data-menu]', this.on_menu_click);
|
||||
this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);
|
||||
// Hide second level submenus
|
||||
this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
|
||||
if (self.current_menu) {
|
||||
self.open_menu(self.current_menu);
|
||||
if (this.current_menu) {
|
||||
this.open_menu(this.current_menu);
|
||||
}
|
||||
this.trigger('menu_loaded', data);
|
||||
this.has_been_loaded.resolve();
|
||||
},
|
||||
do_load_needaction: function (menu_ids) {
|
||||
var self = this;
|
||||
return this.rpc("/web/menu/load_needaction", {'menu_ids': menu_ids}).done(function(r) {
|
||||
self.on_needaction_loaded(r);
|
||||
});
|
||||
},
|
||||
on_needaction_loaded: function(data) {
|
||||
var self = this;
|
||||
this.needaction_data = data;
|
||||
|
@ -1029,11 +1032,36 @@ instance.web.Menu = instance.web.Widget.extend({
|
|||
}
|
||||
this.open_menu(id);
|
||||
},
|
||||
do_reload_needaction: function () {
|
||||
var self = this;
|
||||
self.do_load_needaction([self.current_menu]).then(function () {
|
||||
self.trigger("need_action_reloaded");
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Jquery event handler for menu click
|
||||
*
|
||||
* @param {Event} ev the jquery event
|
||||
*/
|
||||
on_top_menu_click: function(ev) {
|
||||
var self = this;
|
||||
var id = $(ev.currentTarget).data('menu');
|
||||
var menu_ids = [id];
|
||||
var menu = _.filter(this.data.data.children, function (menu) {return menu.id == id;})[0];
|
||||
function add_menu_ids (menu) {
|
||||
if (menu.children) {
|
||||
_.each(menu.children, function (menu) {
|
||||
menu_ids.push(menu.id);
|
||||
add_menu_ids(menu);
|
||||
});
|
||||
}
|
||||
};
|
||||
add_menu_ids(menu);
|
||||
self.do_load_needaction(menu_ids).then(function () {
|
||||
self.trigger("need_action_reloaded");
|
||||
});
|
||||
this.on_menu_click(ev);
|
||||
},
|
||||
on_menu_click: function(ev) {
|
||||
ev.preventDefault();
|
||||
var needaction = $(ev.target).is('div.oe_menu_counter');
|
||||
|
|
|
@ -91,6 +91,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
init: function(parent, dataset, view_id, options) {
|
||||
var self = this;
|
||||
this._super(parent);
|
||||
this.ViewManager = parent;
|
||||
this.set_default_options(options);
|
||||
this.dataset = dataset;
|
||||
this.model = dataset.model;
|
||||
|
@ -720,6 +721,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
return this.save().done(function(result) {
|
||||
self.trigger("save", result);
|
||||
self.to_view_mode();
|
||||
}).then(function(result) {
|
||||
self.ViewManager.ActionManager.__parentedParent.menu.do_reload_needaction();
|
||||
});
|
||||
},
|
||||
on_button_cancel: function(event) {
|
||||
|
|
|
@ -521,6 +521,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
|
|||
return x;
|
||||
}
|
||||
});
|
||||
this.ActionManager = parent;
|
||||
this.views = {};
|
||||
this.flags = flags || {};
|
||||
this.registry = instance.web.views;
|
||||
|
@ -1259,6 +1260,7 @@ instance.web.View = instance.web.Widget.extend({
|
|||
view_type: undefined,
|
||||
init: function(parent, dataset, view_id, options) {
|
||||
this._super(parent);
|
||||
this.ViewManager = parent;
|
||||
this.dataset = dataset;
|
||||
this.view_id = view_id;
|
||||
this.set_default_options(options);
|
||||
|
@ -1330,7 +1332,6 @@ instance.web.View = instance.web.Widget.extend({
|
|||
}
|
||||
};
|
||||
var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {});
|
||||
|
||||
var handler = function (action) {
|
||||
if (action && action.constructor == Object) {
|
||||
var ncontext = new instance.web.CompoundContext(context);
|
||||
|
@ -1367,7 +1368,11 @@ instance.web.View = instance.web.Widget.extend({
|
|||
}
|
||||
}
|
||||
args.push(context);
|
||||
return dataset.call_button(action_data.name, args).then(handler);
|
||||
return dataset.call_button(action_data.name, args).then(handler).then(function () {
|
||||
if (self.ViewManager.ActionManager) {
|
||||
self.ViewManager.ActionManager.__parentedParent.menu.do_reload_needaction();
|
||||
}
|
||||
});
|
||||
} else if (action_data.type=="action") {
|
||||
return this.rpc('/web/action/load', {
|
||||
action_id: action_data.name,
|
||||
|
|
Loading…
Reference in New Issue