summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/abstract_controller.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-03-08 10:02:45 +0100
committerGéry Debongnie <ged@odoo.com>2018-03-08 16:48:54 +0100
commitb17ba359db785899d8a219b480f3209a5a2147f4 (patch)
tree2768621aee2662adcddd130aa3d0dfdb6a522c18 /addons/web/static/src/js/views/abstract_controller.js
parent7ca93cd916a13ee8d46c1685454ae63b606ab547 (diff)
[REF] web,*: introduce the concept of AbstractAction
Before this commit, a client action was simply a subclass of Widget. This is quite simple, but not really enough for the ActionManager. The ActionManager needs to handle client actions in a different way that view actions. Sometimes, it needs to check if a method exists before calling it. With this commit, we introduce a new abstraction: the AbstractAction class, which defines a common API for all actions managed by the web client. Note that the API proposed in this commit is just the beginning. We will introduce other methods in the future, to manage the focus, or the scroll position, for example.
Diffstat (limited to 'addons/web/static/src/js/views/abstract_controller.js')
-rw-r--r--addons/web/static/src/js/views/abstract_controller.js20
1 files changed, 9 insertions, 11 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js
index f1356f72a81..995a5102c37 100644
--- a/addons/web/static/src/js/views/abstract_controller.js
+++ b/addons/web/static/src/js/views/abstract_controller.js
@@ -14,11 +14,11 @@ odoo.define('web.AbstractController', function (require) {
var ControlPanelMixin = require('web.ControlPanelMixin');
var core = require('web.core');
-var Widget = require('web.Widget');
+var AbstractAction = require('web.AbstractAction');
var QWeb = core.qweb;
-var AbstractController = Widget.extend(ControlPanelMixin, {
+var AbstractController = AbstractAction.extend(ControlPanelMixin, {
custom_events: {
open_record: '_onOpenRecord',
switch_view: '_onSwitchView',
@@ -108,6 +108,13 @@ var AbstractController = Widget.extend(ControlPanelMixin, {
//--------------------------------------------------------------------------
/**
+ * @override
+ */
+ canBeRemoved: function () {
+ // AAB: get rid of this option when on_hashchange mechanism is improved
+ return this.discardChanges(undefined, {readonlyIfRealDiscard: true});
+ },
+ /**
* Discards the changes made on the record associated to the given ID, or
* all changes made by the current controller if no recordID is given. For
* example, when the user opens the 'home' screen, the action manager calls
@@ -168,15 +175,6 @@ var AbstractController = Widget.extend(ControlPanelMixin, {
return this.update(params || {});
},
/**
- * Renders the buttons to append, in most cases, to the control panel (in
- * the bottom left corner). When the view is rendered in a dialog, those
- * buttons might be moved to the dialog's footer.
- *
- * @param {jQuery Node} $node
- */
- renderButtons: function ($node) {
- },
- /**
* For views that require a pager, this method will be called to allow the
* controller to instantiate and render a pager. Note that in theory, the
* controller can actually render whatever he wants in the pager zone. If