From 3c0ef4085728d934bc2d4e04fb15bc9b81ecd16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre=20=28lul=29?= Date: Tue, 8 Oct 2024 17:11:34 +0200 Subject: [PATCH] [IMP] pivot: allow to open side panel in readonly mode In read-only mode, you can't open the pivots/lists/charts side panels. It's useful to know what you're looking at (range, domain, sorting, etc.), even if you can't edit anything. Task: 4187705 --- .../pivot_dimension/pivot_dimension.xml | 3 +- .../pivot_layout_configurator.xml | 10 +- .../pivot_measure/pivot_measure.xml | 1 + .../pivot_spreadsheet_side_panel.xml | 4 +- .../pivot_title_section.xml | 5 +- src/helpers/pivot/pivot_menu_items.ts | 1 + src/registries/menus/topbar_menu_registry.ts | 1 + .../pivot_side_panel.test.ts.snap | 159 ++++++++++++++++++ tests/pivots/pivot_side_panel.test.ts | 7 + 9 files changed, 185 insertions(+), 6 deletions(-) create mode 100644 tests/pivots/__snapshots__/pivot_side_panel.test.ts.snap diff --git a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_dimension/pivot_dimension.xml b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_dimension/pivot_dimension.xml index 9d5c33a91f..d3fe20f8b5 100644 --- a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_dimension/pivot_dimension.xml +++ b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_dimension/pivot_dimension.xml @@ -1,5 +1,6 @@ +
@@ -20,7 +21,7 @@
diff --git a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_layout_configurator.xml b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_layout_configurator.xml index b1836d99b6..011691e155 100644 --- a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_layout_configurator.xml +++ b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_layout_configurator.xml @@ -1,10 +1,12 @@ -
+ +
Columns @@ -31,6 +33,7 @@ t-att-style="dragAndDrop.itemsStyle['__rows_title__']"> Rows @@ -55,7 +58,10 @@
Measures - +
diff --git a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_measure/pivot_measure.xml b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_measure/pivot_measure.xml index 3576d3ca1e..777f141e86 100644 --- a/src/components/side_panel/pivot/pivot_layout_configurator/pivot_measure/pivot_measure.xml +++ b/src/components/side_panel/pivot/pivot_layout_configurator/pivot_measure/pivot_measure.xml @@ -12,6 +12,7 @@ t-on-click="toggleMeasureVisibility" /> +
-
+
-
+ +
Name - +
diff --git a/src/helpers/pivot/pivot_menu_items.ts b/src/helpers/pivot/pivot_menu_items.ts index d4e9f40bab..6825f00f63 100644 --- a/src/helpers/pivot/pivot_menu_items.ts +++ b/src/helpers/pivot/pivot_menu_items.ts @@ -14,6 +14,7 @@ export const pivotProperties: ActionSpec = { const pivotId = env.model.getters.getPivotIdFromPosition(position); return (pivotId && env.model.getters.isExistingPivot(pivotId)) || false; }, + isReadonlyAllowed: true, icon: "o-spreadsheet-Icon.PIVOT", }; diff --git a/src/registries/menus/topbar_menu_registry.ts b/src/registries/menus/topbar_menu_registry.ts index 2324d4cd1d..7010c86716 100644 --- a/src/registries/menus/topbar_menu_registry.ts +++ b/src/registries/menus/topbar_menu_registry.ts @@ -473,6 +473,7 @@ topbarMenuRegistry id: `item_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`, name: env.model.getters.getPivotDisplayName(pivotId), sequence: sequence + index, + isReadonlyAllowed: true, execute: (env) => env.openSidePanel("PivotSidePanel", { pivotId }), onStartHover: (env) => env.getStore(HighlightStore).register(highlightProvider), onStopHover: (env) => env.getStore(HighlightStore).unRegister(highlightProvider), diff --git a/tests/pivots/__snapshots__/pivot_side_panel.test.ts.snap b/tests/pivots/__snapshots__/pivot_side_panel.test.ts.snap new file mode 100644 index 0000000000..20aefdc3fd --- /dev/null +++ b/tests/pivots/__snapshots__/pivot_side_panel.test.ts.snap @@ -0,0 +1,159 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Pivot side panel readonly panel snapshot 1`] = ` +
+
+
+ Pivot #2 +
+
+ ✕ +
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
+ Name + +
+
+ +
+ +
+ +
+ +
+
+ Range +
+ +
+
+
+ + +
+ +
+
+ +
+ +
+ + +
+ + +
+
+ + The pivot cannot be created because cell A1 is empty + + +
+ + +
+ +
+
+ +
+
+`; diff --git a/tests/pivots/pivot_side_panel.test.ts b/tests/pivots/pivot_side_panel.test.ts index 4a0a76ec9f..8c230f5901 100644 --- a/tests/pivots/pivot_side_panel.test.ts +++ b/tests/pivots/pivot_side_panel.test.ts @@ -19,6 +19,13 @@ describe("Pivot side panel", () => { addPivot(model, "A1:D5", {}, "2"); }); + test("readonly panel snapshot", async () => { + model.updateMode("readonly"); + env.openSidePanel("PivotSidePanel", { pivotId: "2" }); + await nextTick(); + expect(fixture.querySelector(".o-sidePanel")).toMatchSnapshot(); + }); + test("It should open the pivot editor when pivotId is provided", async () => { env.openSidePanel("PivotSidePanel", { pivotId: "2" }); await nextTick();