diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 65bd414cefa..f1b279fd061 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -919,6 +919,10 @@ .openerp .oe_application .oe_application { width: 100%; } +.openerp .oe_application .oe_client_action { + height: 100%; + position: relative; +} .openerp .oe-view-manager { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index b844f1a8929..db6f463ac43 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -808,6 +808,10 @@ $sheet-padding: 16px flex-direction: column .oe_application width: 100% + + .oe_client_action + height: 100% + position: relative // }}} // ViewManager common {{{ .oe-view-manager diff --git a/addons/web/static/src/js/action_manager.js b/addons/web/static/src/js/action_manager.js index 0d0fa6f4201..7d9f84a24f8 100644 --- a/addons/web/static/src/js/action_manager.js +++ b/addons/web/static/src/js/action_manager.js @@ -21,6 +21,13 @@ var Action = core.Class.extend({ this.action_descr = action; this.title = action.display_name || action.name; }, + /** + * Not implemented for client actions + * @return {Deferred} a rejected Deferred + */ + appendTo: function() { + return $.Deferred().reject(); + }, /** * This method should restore this previously loaded action * Calls on_reverse_breadcrumb callback if defined @@ -96,6 +103,17 @@ var WidgetAction = Action.extend({ this.widget.set('title', this.title); } }, + /** + * Wraps the action's widget in a container and appends it to el + * @param {DocumentFragment} [el] where to append the widget + * @return {Deferred} resolved when the widget is appended + */ + appendTo: function(el) { + this.client_action_container = document.createElement('div'); + this.client_action_container.className = 'oe_client_action'; + el.appendChild(this.client_action_container); + return this.widget.appendTo(this.client_action_container); + }, /** * Restores WidgetAction by calling do_show on its widget */ @@ -106,14 +124,23 @@ var WidgetAction = Action.extend({ /** * Destroys the widget */ - destroy: function() { + destroy: function() { this.widget.destroy(); + this.client_action_container.remove(); }, }); /** * Specialization of WidgetAction for window actions (i.e. ViewManagers) */ var ViewManagerAction = WidgetAction.extend({ + /** + * Appends the action's widget to el + * @param {DocumentFragment} [el] where to append the widget + * @return {Deferred} resolved when the widget is appended + */ + appendTo: function(el) { + return this.widget.appendTo(el); + }, /** * Restores a ViewManagerAction * Switches to the requested view by calling select_view on the ViewManager @@ -133,6 +160,12 @@ var ViewManagerAction = WidgetAction.extend({ set_is_in_DOM: function(is_in_DOM) { this.widget.is_in_DOM = is_in_DOM; }, + /** + * Destroys the widget + */ + destroy: function() { + this.widget.destroy(); + }, /** * @return {Array} array of Objects that will be interpreted to display the breadcrumbs */ @@ -239,7 +272,7 @@ var ActionManager = Widget.extend({ // render the inner_widget in a fragment, and append it to the // document only when it's ready var new_widget_fragment = document.createDocumentFragment(); - return $.when(this.inner_widget.appendTo(new_widget_fragment)).done(function() { + return $.when(this.inner_action.appendTo(new_widget_fragment)).done(function() { // Detach the fragment of the previous action and store it within the action if (old_action) { old_action.set_fragment(old_widget.$el.detach());