Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX]base_geoengine: missing sidebar #375

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading