diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-01-27 12:24:04 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-01-27 12:24:04 +0100 |
| commit | 78d20b552b4374b94aec7097c0e6a48a3dd2d961 (patch) | |
| tree | 5acd7cbf1cc9e2f277034f44fc0ebebaa3a1a79c /addons/web/static/src/js/view_manager.js | |
| parent | 740a6eadd379cc3fa26aefb9350f1c95b3e05ebd (diff) | |
| parent | 7e44ddcda3f21c7e6401173539dc0fe93f9a7dd2 (diff) | |
[MERGE] forward port of branch saas-8 up to 7e44ddc
Diffstat (limited to 'addons/web/static/src/js/view_manager.js')
| -rw-r--r-- | addons/web/static/src/js/view_manager.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/addons/web/static/src/js/view_manager.js b/addons/web/static/src/js/view_manager.js index c5db4b954ca..2ae53aabb22 100644 --- a/addons/web/static/src/js/view_manager.js +++ b/addons/web/static/src/js/view_manager.js @@ -130,8 +130,10 @@ var ViewManager = Widget.extend(ControlPanelMixin, { var view = this.views[view_type]; var old_view = this.active_view; - if (!view) { + if (!view || this.currently_switching) { return $.Deferred().reject(); + } else { + this.currently_switching = true; // prevent overlapping switches } if (view.multi_record) { @@ -156,11 +158,23 @@ var ViewManager = Widget.extend(ControlPanelMixin, { self.searchview.do_search(); }); } - return $.when(view.created, this.active_search).then(function () { + var switched = $.when(view.created, this.active_search).then(function () { return self._display_view(view_options, old_view).then(function () { self.trigger('switch_mode', view_type, no_store, view_options); }); }); + switched.fail(function(e) { + if (!(e && e.code === 200 && e.data.exception_type)) { + self.do_warn(_t("Error"), view.controller.display_name + _t(" view couldn't be loaded")); + } + // Restore internal state + self.active_view = old_view; + self.view_stack.pop(); + }); + switched.always(function () { + self.currently_switching = false; + }); + return switched; }, _display_view: function (view_options, old_view) { var self = this; @@ -239,7 +253,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }, select_view: function (index) { var view_type = this.view_stack[index].type; - this.view_stack.splice(index); return this.switch_mode(view_type); }, /** @@ -262,10 +275,10 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }); // Add onclick event listener - this.control_elements.$switch_buttons.siblings('button').click(function(event) { + this.control_elements.$switch_buttons.siblings('button').click(_.debounce(function(event) { var view_type = $(event.target).data('view-type'); self.switch_mode(view_type); - }); + }, 200, true)); } }, /** |
