diff options
| author | Simon Lejeune <sle@openerp.com> | 2015-06-24 16:37:52 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-07-29 08:39:38 +0200 |
| commit | 4e24b81616dda662e5d2ae1e68d7fb53dc72c1e1 (patch) | |
| tree | 2fc17253c68f56552a1e2f40488f37e85d30ace1 /addons | |
| parent | c8b1f0d678d9521e545f57c4e06f6c2d44433627 (diff) | |
[REF] web: action manager: wrap the client actions in a div
this way we can style the div and use the trick to have the child of a
flex-item filling 100% of its parent (flex item in relative position and
flex child in an absolute position). It is needed to have a consistent
look betwenn Odoo enterprise and Odoo community.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/css/base.css | 4 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/action_manager.js | 37 |
3 files changed, 43 insertions, 2 deletions
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 @@ -22,6 +22,13 @@ var Action = core.Class.extend({ 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 * @return {Deferred} resolved when widget is enabled @@ -97,6 +104,17 @@ var WidgetAction = Action.extend({ } }, /** + * 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 */ restore: function() { @@ -106,8 +124,9 @@ var WidgetAction = Action.extend({ /** * Destroys the widget */ - destroy: function() { + destroy: function() { this.widget.destroy(); + this.client_action_container.remove(); }, }); /** @@ -115,6 +134,14 @@ var WidgetAction = Action.extend({ */ 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 * @param {int} [view_index] the index of the view to select @@ -134,6 +161,12 @@ var ViewManagerAction = WidgetAction.extend({ 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 */ get_breadcrumbs: function() { @@ -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()); |
