[FIX] Fixed on_mode_switch.

bzr revid: vta@openerp.com-20121010093737-0kheus1v0kdj5tk7
This commit is contained in:
vta vta@openerp.com 2012-10-10 11:37:37 +02:00
parent fe07dc2e6d
commit 12c35d031d
3 changed files with 14 additions and 16 deletions

View File

@ -3370,7 +3370,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
}
def.resolve();
});
this.viewmanager.on("on_mode_switch", self, function(n_mode, b, c, d, e) {
this.viewmanager.on("switch_mode", self, function(n_mode, b, c, d, e) {
$.when(self.save_any_view()).then(function() {
if (n_mode === "list") {
$.async_when().then(function() {

View File

@ -417,7 +417,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
this._super();
var self = this;
this.$el.find('.oe_view_manager_switch a').click(function() {
self.trigger('on_mode_switch', $(this).data('view-type'));
self.trigger('switch_mode', $(this).data('view-type'));
}).tipsy();
var views_ids = {};
_.each(this.views_src, function(view) {
@ -439,10 +439,8 @@ instance.web.ViewManager = instance.web.Widget.extend({
}
// If no default view defined, switch to the first one in sequence
var default_view = this.flags.default_view || this.views_src[0].view_type;
this.on('on_mode_switch', self, function(view_type, no_store, view_options) {
self.switch_mode(view_type, no_store, view_options);
});
return this.trigger('on_mode_switch', default_view);
this.on('switch_mode', self, self.switch_mode);
return this.trigger('switch_mode', default_view);
},
switch_mode: function(view_type, no_store, view_options) {
var self = this;
@ -548,7 +546,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
add_breadcrumb: function(on_reverse_breadcrumb) {
var self = this;
var views = [this.active_view || this.views_src[0].view_type];
this.on('on_mode_switch',self,function(mode) {
this.on('switch_mode', self, function(mode) {
var last = views.slice(-1)[0];
if (mode !== last) {
if (mode !== 'form') {
@ -564,7 +562,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
var view_to_select = views[index];
self.$el.show();
if (self.active_view !== view_to_select) {
self.trigger('on_mode_switch', view_to_select);
self.trigger('switch_mode', view_to_select);
}
},
get_title: function() {
@ -600,12 +598,12 @@ instance.web.ViewManager = instance.web.Widget.extend({
* consist to switch to the asked view.
*/
switch_view: function(view_type, no_store, options) {
return this.trigger('on_mode_switch', view_type, no_store, options);
return this.trigger('switch_mode', view_type, no_store, options);
},
/**
* Returns to the view preceding the caller view in this manager's
* navigation history (the navigation history is appended to via
* on_mode_switch)
* switch_mode)
*
* @param {Object} [options]
* @param {Boolean} [options.created=false] resource was created
@ -619,12 +617,12 @@ instance.web.ViewManager = instance.web.Widget.extend({
if (options.created && current_view === 'form' && previous_view === 'list') {
// APR special case: "If creation mode from list (and only from a list),
// after saving, go to page view (don't come back in list)"
return this.trigger('on_mode_switch', 'form');
return this.trigger('switch_mode', 'form');
} else if (options.created && !previous_view && this.action && this.action.flags.default_view === 'form') {
// APR special case: "If creation from dashboard, we have no previous view
return this.trigger('on_mode_switch', 'form');
return this.trigger('switch_mode', 'form');
}
return this.trigger('on_mode_switch', previous_view, true);
return this.trigger('switch_mode', previous_view, true);
},
/**
* Sets up the current viewmanager's search view.
@ -928,7 +926,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
if (state.view_type && state.view_type !== this.active_view) {
defs.push(
this.views[this.active_view].deferred.pipe(function() {
return self.trigger('on_mode_switch', state.view_type, true)
return self.trigger('switch_mode', state.view_type, true)
})
);
}

View File

@ -194,7 +194,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
});
var am = instance.webclient.action_manager;
var form = am.dialog_widget.views.form.controller;
form.on("on_button_cancel",self,am.dialog.on_close);
form.on("on_button_cancel", self, am.dialog.on_close);
form.on_created.add_last(function(r) {
(new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r.result]).then(function(new_record) {
am.dialog.on_close();
@ -672,7 +672,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
});
var am = instance.webclient.action_manager;
var form = am.dialog_widget.views.form.controller;
form.on("on_button_cancel",self,am.dialog.on_close);
form.on("on_button_cancel", self, am.dialog.on_close);
form.on_saved.add_last(function() {
am.dialog.on_close();
self.view.do_reload();