Skip to content

Commit

Permalink
[FIX]base_geoengine: remove non-existent Sidebar and related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Jun 26, 2024
1 parent d9d9a3b commit 4836e55
Showing 1 changed file with 1 addition and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,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'.
* Its role is to allow these two components to communicate properly.
*/

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

var _t = core._t;

var GeoengineController = BasicController.extend({
custom_events: _.extend({}, BasicController.prototype.custom_events, {
selection_changed: "_onSelectionChanged",
Expand All @@ -31,13 +26,11 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
* @override
* @param {Object} parent node
* @param {Boolean} params.editable
* @param {Boolean} params.hasSidebar
* @param {Object} params.toolbarActions
* @param {Boolean} params.noLeaf
*/
init: function (parent, model, renderer, params) {
this._super.apply(this, arguments);
this.hasSidebar = params.hasSidebar;
this.toolbarActions = params.toolbarActions || {};
this.noLeaf = params.noLeaf;
this.selectedRecords = params.selectedRecords || [];
Expand Down Expand Up @@ -106,55 +99,6 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
});
},

/**
* Render the sidebar (the 'action' menu in the control panel, right of
* the main buttons)
*
* @param {jQuery.Element} $node
*/
renderSidebar: function ($node) {
if (this.hasSidebar && !this.sidebar) {
var other = [
{
label: _t("Export"),
callback: this._onExportData.bind(this),
},
];
if (this.archiveEnabled) {
other.push({
label: _t("Archive"),
callback: this._onToggleArchiveState.bind(this, true),
});
other.push({
label: _t("Unarchive"),
callback: this._onToggleArchiveState.bind(this, false),
});
}
if (this.is_action_enabled("delete")) {
other.push({
label: _t("Delete"),
callback: this._onDeleteSelectedRecords.bind(this),
});
}
this.sidebar = new Sidebar(this, {
editable: this.is_action_enabled("edit"),
env: {
context: this.model
.get(this.handle, {
raw: true,
})
.getContext(),
activeIds: this.getSelectedIds(),
model: this.modelName,
},
actions: _.extend(this.toolbarActions, {other: other}),
});
this.sidebar.appendTo($node);

this._toggleSidebar();
}
},

/**
* Overrides to update the list of selected records
*
Expand Down Expand Up @@ -244,51 +188,10 @@ odoo.define("base_geoengine.GeoengineController", function (require) {
.then(this.update.bind(this, {}, {reload: false}));
},

/**
* @override
* @private
*/
_getSidebarEnv: 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)
* if we have some selected records.
*/
_toggleSidebar: function () {
if (this.sidebar) {
this.sidebar.do_toggle(this.selectedRecords.length > 0);
}
},

/**
* @override
* @returns {Deferred}
*/
_update: function () {
this._toggleSidebar();
return this._super.apply(this, arguments);
},

// --------------------------------------------------------------------
// Handlers
// --------------------------------------------------------------------

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

/**
* Called when clicking on 'Archive' or 'Unarchive' in the sidebar.
*
Expand Down

0 comments on commit 4836e55

Please sign in to comment.