summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/action_manager.js
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2015-06-24 16:37:52 +0200
committerAaron Bohy <aab@odoo.com>2015-07-29 08:39:38 +0200
commit4e24b81616dda662e5d2ae1e68d7fb53dc72c1e1 (patch)
tree2fc17253c68f56552a1e2f40488f37e85d30ace1 /addons/web/static/src/js/action_manager.js
parentc8b1f0d678d9521e545f57c4e06f6c2d44433627 (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/web/static/src/js/action_manager.js')
-rw-r--r--addons/web/static/src/js/action_manager.js37
1 files changed, 35 insertions, 2 deletions
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());