diff options
Diffstat (limited to 'addons/web/static/src/js/action_manager.js')
| -rw-r--r-- | addons/web/static/src/js/action_manager.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/addons/web/static/src/js/action_manager.js b/addons/web/static/src/js/action_manager.js index fe50fb65e90..b6a33e443d1 100644 --- a/addons/web/static/src/js/action_manager.js +++ b/addons/web/static/src/js/action_manager.js @@ -93,6 +93,12 @@ var Action = core.Class.extend({ get_fragment: function() { return this.$fragment; }, + /** + * @return {string} the active view, i.e. empty for client actions + */ + get_active_view: function() { + return ''; + }, }); /** * Specialization of Action for client actions that are Widgets @@ -196,6 +202,12 @@ var ViewManagerAction = WidgetAction.extend({ get_nb_views: function() { return this.widget.view_stack.length; }, + /** + * @return {string} the active view of the ViewManager + */ + get_active_view: function() { + return this.widget.active_view.type; + } }); var ActionManager = Widget.extend({ @@ -269,11 +281,15 @@ var ActionManager = Widget.extend({ var old_action_stack = this.action_stack; var old_action = this.inner_action; var old_widget = this.inner_widget; + var actions_to_destroy; options = options || {}; - // Empty action_stack if requested + // Empty action_stack or replace last action if requested if (options.clear_breadcrumbs) { + actions_to_destroy = this.action_stack; this.action_stack = []; + } else if (options.replace_last_action && this.action_stack.length > 0) { + actions_to_destroy = [this.action_stack.pop()]; } // Instantiate the new action @@ -318,10 +334,11 @@ var ActionManager = Widget.extend({ in_DOM: self.is_in_DOM, callbacks: [{widget: self.inner_widget}], }); - if (options.clear_breadcrumbs) { - self.clear_action_stack(old_action_stack); + if (actions_to_destroy) { + self.clear_action_stack(actions_to_destroy); } self.toggle_fullscreen(); + self.trigger_up('current_action_updated', {action: new_action}); }).fail(function () { // Destroy failed action and restore internal state new_action.destroy(); @@ -404,6 +421,7 @@ var ActionManager = Widget.extend({ callbacks: [{widget: action.widget}], }); } + self.trigger_up('current_action_updated', {action: action}); }); }).fail(function() { return $.Deferred().reject(); @@ -561,6 +579,7 @@ var ActionManager = Widget.extend({ do_action: function(action, options) { options = _.defaults(options || {}, { clear_breadcrumbs: false, + replace_last_action: false, on_reverse_breadcrumb: function() {}, hide_breadcrumb: false, on_close: function() {}, |
