summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_controller.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-11-17 13:14:02 +0100
committerAaron Bohy <aab@odoo.com>2018-01-16 20:49:19 +0100
commit32b8cec5361174c92c45a4975d4e02f1fb448aa2 (patch)
tree110bd6986c2da1ed5047002b7ea40c91ea9fa5ed /addons/web/static/src/js/views/basic/basic_controller.js
parent9bee25a9df65f657fef0f2f32a7ad823fdc7d4e1 (diff)
[REF] web,*: ActionManager/ViewManager refactoring
This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js22
1 files changed, 8 insertions, 14 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js
index 1c8060a6fe1..2c7c1c40210 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -200,7 +200,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
_abandonRecord: function (recordID) {
recordID = recordID || this.handle;
if (recordID === this.handle) {
- this.trigger_up('switch_to_previous_view');
+ this.trigger_up('history_back');
} else {
this.model.removeLine(recordID);
}
@@ -244,17 +244,11 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
model: record.model,
resIDs: record.res_ids,
},
- on_closed: function (reason) {
- if (!_.isObject(reason)) {
- reload(reason);
- }
- },
- on_fail: function (reason) {
- reload().always(function() {
- def.reject(reason);
- });
- },
on_success: def.resolve.bind(def),
+ on_fail: function () {
+ reload().always(def.reject.bind(def));
+ },
+ on_closed: reload,
});
return this.alive(def);
},
@@ -313,13 +307,13 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
* @param {Object} [options]
* @param {boolean} [options.readonlyIfRealDiscard=false]
* After discarding record changes, the usual option is to make the
- * record readonly. However, the view manager calls this function
+ * record readonly. However, the action manager calls this function
* at inappropriate times in the current code and in that case, we
* don't want to go back to readonly if there is nothing to discard
* (e.g. when switching record in edit mode in form view, we expect
* the new record to be in edit mode too, but the view manager calls
* this function as the URL changes...) @todo get rid of this when
- * the view manager is improved.
+ * the webclient/action_manager's hashchange mechanism is improved.
* @returns {Deferred}
*/
_discardChanges: function (recordID, options) {
@@ -467,7 +461,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
var sidebarEnv = this._getSidebarEnv();
this.sidebar.updateEnv(sidebarEnv);
}
- this.trigger_up('env_updated', env);
+ this.trigger_up('env_updated', {controllerID: this.controllerID, env: env});
},
/**
* Helper method, to make sure the information displayed by the pager is up