[FIX] spreadsheet_dashboard: prevent crash on chart double click
Steps to reproduce ================== - Use a mobile viewport / device (small window) - Go to Dashboard - Double click on a chart => `this.env.openSidePanel is not a function` Cause of the issue ================== On mobile, the MobileFigureContainer is used instead of the Spreadsheet component. The both use `useSubEnv` but the mobile one was missing the openSidePanel function. Solution ======== Add an empty `openSidePanel` function that does nothing. opw-3677552 closes odoo/odoo#150702 X-original-commit: 990452ad985b1515ba565ff1fe8c6bbaa14fb031 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit is contained in:
+1
@@ -11,6 +11,7 @@ export class MobileFigureContainer extends Component {
|
||||
useSubEnv({
|
||||
model: this.props.spreadsheetModel,
|
||||
isDashboard: () => this.props.spreadsheetModel.getters.isDashboard(),
|
||||
openSidePanel: () => {},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { click, getFixture } from "@web/../tests/helpers/utils";
|
||||
import { click, getFixture, triggerEvent } from "@web/../tests/helpers/utils";
|
||||
import { createSpreadsheetDashboard } from "../utils/dashboard_action";
|
||||
import { getDashboardServerData } from "../utils/data";
|
||||
|
||||
@@ -77,6 +77,55 @@ QUnit.test("displays figures in first sheet", async (assert) => {
|
||||
assert.containsOnce(fixture, ".o-chart-container");
|
||||
});
|
||||
|
||||
QUnit.test("double clicking on a figure doesn't open the side panel", async (assert) => {
|
||||
const figure = {
|
||||
tag: "chart",
|
||||
height: 500,
|
||||
width: 500,
|
||||
x: 100,
|
||||
y: 100,
|
||||
data: {
|
||||
type: "line",
|
||||
dataSetsHaveTitle: false,
|
||||
dataSets: ["A1"],
|
||||
legendPosition: "top",
|
||||
verticalAxisPosition: "left",
|
||||
title: "",
|
||||
},
|
||||
};
|
||||
const spreadsheetData = {
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet1",
|
||||
figures: [{ ...figure, id: "figure1" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const serverData = getDashboardServerData();
|
||||
serverData.models["spreadsheet.dashboard.group"].records = [
|
||||
{
|
||||
dashboard_ids: [789],
|
||||
id: 1,
|
||||
name: "Chart",
|
||||
},
|
||||
];
|
||||
serverData.models["spreadsheet.dashboard"].records = [
|
||||
{
|
||||
id: 789,
|
||||
name: "Spreadsheet with chart figure",
|
||||
json_data: JSON.stringify(spreadsheetData),
|
||||
spreadsheet_data: JSON.stringify(spreadsheetData),
|
||||
dashboard_group_id: 1,
|
||||
},
|
||||
];
|
||||
const fixture = getFixture();
|
||||
await createSpreadsheetDashboard({ serverData });
|
||||
await triggerEvent(fixture, ".o-chart-container", "focus");
|
||||
await triggerEvent(fixture, ".o-chart-container", "dblclick");
|
||||
assert.containsOnce(fixture, ".o-chart-container");
|
||||
assert.containsNone(fixture, ".o-sidePanel");
|
||||
});
|
||||
|
||||
QUnit.test("can switch dashboard", async (assert) => {
|
||||
await createSpreadsheetDashboard();
|
||||
const fixture = getFixture();
|
||||
|
||||
Reference in New Issue
Block a user