Skip to content

Commit

Permalink
[IMP] figure_chart: Double click on chart open the sidepanel
Browse files Browse the repository at this point in the history
Added a feature which allow to open the side panel, when double
clicking on the chart.

Task id: 3205620

closes #2143

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
jash-odoo committed Mar 20, 2023
1 parent 9781b7e commit 308e5d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/figures/figure_chart/figure_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export class ChartFigure extends Component<Props, SpreadsheetChildEnv> {
static template = "o-spreadsheet-ChartFigure";
static components = {};

onDoubleClick() {
this.env.model.dispatch("SELECT_FIGURE", { id: this.props.figure.id });
this.env.openSidePanel("ChartPanel");
}

get chartType(): ChartType {
return this.env.model.getters.getChartType(this.props.figure.id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/figures/figure_chart/figure_chart.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<templates>
<t t-name="o-spreadsheet-ChartFigure" owl="1">
<div class="o-chart-container w-100 h-100">
<div class="o-chart-container w-100 h-100" t-on-dblclick="onDoubleClick">
<t
t-component="chartComponent"
figure="this.props.figure"
Expand Down
13 changes: 13 additions & 0 deletions tests/components/charts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ describe("figures", () => {
}
);

test.each(["scorecard", "basicChart", "gauge"])(
"Double click on graph will open sidepanel",
async (chartType: string) => {
createTestChart(chartType);
await nextTick();
expect(document.querySelector(".o-chart-container")).toBeTruthy();
triggerMouseEvent(".o-chart-container", "dblclick");
await nextTick();
expect(model.getters.getSelectedFigureId()).toBe("someuuid");
expect(document.querySelector(".o-sidePanel")).toBeTruthy();
}
);

test.each(["basicChart", "scorecard", "gauge"])(
"can edit charts %s",
async (chartType: string) => {
Expand Down

0 comments on commit 308e5d6

Please sign in to comment.