Skip to content

Commit

Permalink
[FIX]base_geoengine: replace old web.Sidebar w/ web.ActionMenus
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Jun 20, 2024
1 parent d9d9a3b commit 4dd2881
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
/**
* The Geoengine Controller controls the geo renderer and the geo model.
* Its role is to allow these two components to communicate properly, and
* also, to render and bind all extra actions in the 'Sidebar'.
* also, to render and bind all extra actions in the 'ActionMenus'.
*/

var core = require("web.core");
var BasicController = require("web.BasicController");
var pyUtils = require("web.py_utils");
var Sidebar = require("web.Sidebar");
var ActionMenus = require("web.ActionMenus");
var DataExport = require("web.DataExport");

var _t = core._t;
Expand All @@ -31,13 +31,13 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
* @override
* @param {Object} parent node
* @param {Boolean} params.editable
* @param {Boolean} params.hasSidebar
* @param {Boolean} params.hasActionMenus
* @param {Object} params.toolbarActions
* @param {Boolean} params.noLeaf
*/
init: function (parent, model, renderer, params) {
this._super.apply(this, arguments);
this.hasSidebar = params.hasSidebar;
this.hasActionMenus = params.hasActionMenus;
this.toolbarActions = params.toolbarActions || {};
this.noLeaf = params.noLeaf;
this.selectedRecords = params.selectedRecords || [];
Expand All @@ -55,7 +55,7 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
*
* @todo This is done only for the data export. The full mechanism is
* wrong, this method should be private, most of the code in the
* sidebar should be moved to the controller, and we should not use the
* actionMenus should be moved to the controller, and we should not use the
* getParent method...
*
* @returns {Deferred<Array[]>} a deferred that resolve to the active
Expand Down Expand Up @@ -107,13 +107,13 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
},

/**
* Render the sidebar (the 'action' menu in the control panel, right of
* Render the actionMenus (the 'action' menu in the control panel, right of
* the main buttons)
*
* @param {jQuery.Element} $node
*/
renderSidebar: function ($node) {
if (this.hasSidebar && !this.sidebar) {
renderActionMenus: function ($node) {
if (this.hasActionMenus && !this.actionMenus) {
var other = [
{
label: _t("Export"),
Expand All @@ -136,7 +136,7 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
callback: this._onDeleteSelectedRecords.bind(this),
});
}
this.sidebar = new Sidebar(this, {
this.actionMenus = new ActionMenus(this, {
editable: this.is_action_enabled("edit"),
env: {
context: this.model
Expand All @@ -149,9 +149,9 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
},
actions: _.extend(this.toolbarActions, {other: other}),
});
this.sidebar.appendTo($node);
this.actionMenus.appendTo($node);

this._toggleSidebar();
this._toggleActionMenus();
}
},

Expand Down Expand Up @@ -248,19 +248,19 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
* @override
* @private
*/
_getSidebarEnv: function () {
_getActionMenusEnv: function () {
var env = this._super.apply(this, arguments);
var record = this.model.get(this.handle);
return _.extend(env, {domain: record.getDomain()});
},

/**
* Display the sidebar (the 'action' menu in the control panel)
* Display the actionMenus (the 'action' menu in the control panel)
* if we have some selected records.
*/
_toggleSidebar: function () {
if (this.sidebar) {
this.sidebar.do_toggle(this.selectedRecords.length > 0);
_toggleActionMenus: function () {
if (this.actionMenus) {
this.actionMenus.do_toggle(this.selectedRecords.length > 0);
}
},

Expand All @@ -269,7 +269,7 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
* @returns {Deferred}
*/
_update: function () {
this._toggleSidebar();
this._toggleActionMenus();
return this._super.apply(this, arguments);
},

Expand All @@ -279,18 +279,18 @@ odoo.define("base_geoengine.GeoengineController", function (require) {

/**
* When the current selection changes (by clicking on the checkboxes on
* the left), we need to display (or hide) the 'sidebar'.
* the left), we need to display (or hide) the 'actionMenus'.
*
* @private
* @param {OdooEvent} event
*/
_onSelectionChanged: function (event) {
this.selectedRecords = event.data.selection;
this._toggleSidebar();
this._toggleActionMenus();
},

/**
* Called when clicking on 'Archive' or 'Unarchive' in the sidebar.
* Called when clicking on 'Archive' or 'Unarchive' in the actionMenus.
*
* @private
* @param {Boolean} archive
Expand Down

0 comments on commit 4dd2881

Please sign in to comment.