summaryrefslogtreecommitdiff
path: root/addons/board/static/src
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/board/static/src
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/board/static/src')
-rw-r--r--addons/board/static/src/js/action_manager_board_action.js33
-rw-r--r--addons/board/static/src/js/dashboard.js20
-rw-r--r--addons/board/static/src/js/favorite_menu.js17
3 files changed, 58 insertions, 12 deletions
diff --git a/addons/board/static/src/js/action_manager_board_action.js b/addons/board/static/src/js/action_manager_board_action.js
new file mode 100644
index 00000000000..3036ac0f328
--- /dev/null
+++ b/addons/board/static/src/js/action_manager_board_action.js
@@ -0,0 +1,33 @@
+odoo.define('board.ActionManager', function (require) {
+"use strict";
+
+/**
+ * The purpose of this file is to patch the ActionManager to properly generate
+ * the flags for the 'ir.actions.act_window' of model 'board.board'.
+ */
+
+var ActionManager = require('web.ActionManager');
+
+ActionManager.include({
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ * @private
+ */
+ _executeWindowAction: function (action) {
+ if (action.res_model === 'board.board' && action.view_mode === 'form') {
+ action.target = 'inline';
+ _.extend(action.flags, {
+ hasSearchView: false,
+ hasSidebar: false,
+ headless: true,
+ });
+ }
+ return this._super.apply(this, arguments);
+ },
+});
+
+});
diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js
index 00b66c06312..e84529be83b 100644
--- a/addons/board/static/src/js/dashboard.js
+++ b/addons/board/static/src/js/dashboard.js
@@ -104,10 +104,9 @@ FormController.include({
},
/**
- * We need to intercept switch_view event coming from sub views, because
- * there is no view manager doing the job. Also, we don't actually want to
- * switch view in dashboard, we want to do a do_action (which will open the
- * record in a different breadcrumb)
+ * We need to intercept switch_view event coming from sub views, because we
+ * don't actually want to switch view in dashboard, we want to do a
+ * do_action (which will open the record in a different breadcrumb).
*
* @private
* @param {OdooEvent} event
@@ -126,6 +125,9 @@ FormController.include({
});
FormRenderer.include({
+ custom_events: _.extend({}, FormRenderer.prototype.custom_events, {
+ env_updated: '_onEnvUpdated',
+ }),
events: _.extend({}, FormRenderer.prototype.events, {
'click .oe_dashboard_column .oe_fold': '_onFoldClick',
'click .oe_dashboard_link_change_layout': '_onChangeLayout',
@@ -340,6 +342,16 @@ FormRenderer.include({
});
},
/**
+ * Stops the propagation of 'update_env' events triggered by the controllers
+ * instantiated by the dashboard.
+ *
+ * @override
+ * @private
+ */
+ _onEnvUpdated: function (event) {
+ event.stopPropagation();
+ },
+ /**
* @private
* @param {MouseEvent} event
*/
diff --git a/addons/board/static/src/js/favorite_menu.js b/addons/board/static/src/js/favorite_menu.js
index a4d7aa11022..77cd3df4967 100644
--- a/addons/board/static/src/js/favorite_menu.js
+++ b/addons/board/static/src/js/favorite_menu.js
@@ -7,7 +7,6 @@ var core = require('web.core');
var Domain = require('web.Domain');
var FavoriteMenu = require('web.FavoriteMenu');
var pyeval = require('web.pyeval');
-var ViewManager = require('web.ViewManager');
var _t = core._t;
var QWeb = core.qweb;
@@ -23,11 +22,7 @@ FavoriteMenu.include({
if(this.action_id === undefined) {
return this._super();
}
- var am = this.findAncestor(function (a) {
- return a instanceof ActionManager;
- });
- if (am && am.get_inner_widget() instanceof ViewManager) {
- this.view_manager = am.get_inner_widget();
+ if (this.action.type === 'ir.actions.act_window') {
this.add_to_dashboard_available = true;
this.$('.o_favorites_menu').append(QWeb.render('SearchView.addtodashboard'));
this.$add_to_dashboard = this.$('.o_add_to_dashboard');
@@ -71,7 +66,13 @@ FavoriteMenu.include({
context.add({
group_by: pyeval.eval('groupbys', search_data.groupbys || [])
});
- context.add(this.view_manager.active_view.controller.getContext());
+ // AAB: trigger_up an event that will be intercepted by the controller,
+ // as soon as the controller is the parent of the control panel
+ var am = this.findAncestor(function (a) {
+ return a instanceof ActionManager;
+ });
+ var controller = am.getCurrentController();
+ context.add(controller.widget.getContext());
var c = pyeval.eval('context', context);
for (var k in c) {
if (c.hasOwnProperty(k) && /^search_default_/.test(k)) {
@@ -88,7 +89,7 @@ FavoriteMenu.include({
action_id: self.action_id || false,
context_to_save: c,
domain: domain,
- view_mode: self.view_manager.active_view.type,
+ view_mode: controller.viewType,
name: name,
},
})