Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/components/figures/figure_carousel/figure_carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ export class CarouselFigure extends Component<Props, SpreadsheetChildEnv> {
this.env.openSidePanel("CarouselPanel", { figureId: this.props.figureUI.id });
}

onCarouselChartDoubleClick() {
if (this.selectedCarouselItem?.type !== "chart") {
return;
}
const chartId = this.selectedCarouselItem.chartId;
this.env.model.dispatch("SELECT_FIGURE", { figureId: this.props.figureUI.id });
this.env.openSidePanel("ChartPanel", { chartId });
}

isItemSelected(item: CarouselItem): boolean {
const selectedItem = this.selectedCarouselItem;
return deepEquals(selectedItem, item);
Expand Down
4 changes: 3 additions & 1 deletion src/components/figures/figure_carousel/figure_carousel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
<div
t-elif="selectedItem.type === 'chart'"
class="o-carousel-content w-100 flex-fill position-relative">
<div class="o-chart-container w-100 h-100">
<div
class="o-chart-container w-100 h-100"
t-on-dblclick.stop="this.onCarouselChartDoubleClick">
<t
t-component="this.chartComponent"
chartId="selectedItem.chartId"
Expand Down
22 changes: 21 additions & 1 deletion tests/figures/carousel/carousel_figure_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
selectFigure,
updateCarousel,
} from "../../test_helpers/commands_helpers";
import { click, clickAndDrag, getElStyle, triggerMouseEvent } from "../../test_helpers/dom_helper";
import {
click,
clickAndDrag,
doubleClick,
getElStyle,
triggerMouseEvent,
} from "../../test_helpers/dom_helper";
import { makeTestEnv, mockChart, mountSpreadsheet, nextTick } from "../../test_helpers/helpers";
import { extendMockGetBoundingClientRect } from "../../test_helpers/mock_helpers";

Expand Down Expand Up @@ -328,6 +334,20 @@ describe("Carousel figure component", () => {
expect(".o-popover .o-menu").toHaveCount(1);
});

test("Double Click opens either the carousel or the chart side panel", async () => {
createCarousel(model, { items: [] }, "carouselId");
const chartId = addNewChartToCarousel(model, "carouselId", { type: "radar" });

const { fixture, env } = await mountSpreadsheet({ model }, {});
const openSidePanel = jest.spyOn(env, "openSidePanel");

await doubleClick(fixture, ".o-chart-container");
expect(openSidePanel).toHaveBeenLastCalledWith("ChartPanel", { chartId });

await doubleClick(fixture, ".o-carousel-header");
expect(openSidePanel).toHaveBeenLastCalledWith("CarouselPanel", { figureId: "carouselId" });
});

describe("Carousel menu items", () => {
let env: SpreadsheetChildEnv;
let openSidePanel: jest.Mock;
Expand Down