@odoo/o-spreadsheet 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/o_spreadsheet.cjs.js +17836 -0
- package/dist/o_spreadsheet.d.ts +4102 -0
- package/dist/o_spreadsheet.esm.js +17801 -0
- package/dist/o_spreadsheet.iife.js +17838 -0
- package/dist/o_spreadsheet.iife.min.js +1440 -0
- package/package.json +27 -7
- package/readme.md +10 -0
- package/.eslintrc.json +0 -20
- package/.husky/post-checkout +0 -9
- package/.husky/pre-commit +0 -39
- package/.prettierignore +0 -1
- package/astToFormula.patch +0 -0
- package/demo/data.js +0 -255
- package/demo/index.html +0 -9
- package/demo/libs/Chart.bundle.js +0 -20755
- package/demo/main.js +0 -101
- package/doc/readme.md +0 -46
- package/rollup.config.js +0 -23
- package/src/base_plugin.ts +0 -102
- package/src/components/autofill.ts +0 -146
- package/src/components/bottom_bar.ts +0 -199
- package/src/components/color_picker.ts +0 -150
- package/src/components/composer/autocomplete_dropdown.ts +0 -135
- package/src/components/composer/composer.ts +0 -487
- package/src/components/composer/content_editable_helper.ts +0 -146
- package/src/components/figures/chart.ts +0 -70
- package/src/components/figures/container.ts +0 -268
- package/src/components/figures/text_figure.ts +0 -36
- package/src/components/grid.ts +0 -635
- package/src/components/helpers/dom_helpers.ts +0 -7
- package/src/components/helpers/drag_and_drop.ts +0 -17
- package/src/components/icons.ts +0 -36
- package/src/components/index.ts +0 -1
- package/src/components/menu.ts +0 -288
- package/src/components/overlay.ts +0 -457
- package/src/components/scrollbar.ts +0 -22
- package/src/components/selection_input.ts +0 -168
- package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
- package/src/components/side_panel/chart_panel.ts +0 -104
- package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
- package/src/components/side_panel/conditional_formatting.ts +0 -396
- package/src/components/side_panel/side_panel.ts +0 -127
- package/src/components/side_panel/translations_terms.ts +0 -45
- package/src/components/spreadsheet.ts +0 -198
- package/src/components/top_bar.ts +0 -535
- package/src/constants.ts +0 -26
- package/src/data.ts +0 -149
- package/src/fonts.ts +0 -41
- package/src/formulas/compiler.ts +0 -258
- package/src/formulas/composer_tokenizer.ts +0 -70
- package/src/formulas/index.ts +0 -15
- package/src/formulas/normalize.ts +0 -52
- package/src/formulas/parser.ts +0 -280
- package/src/formulas/range_tokenizer.ts +0 -97
- package/src/formulas/tokenizer.ts +0 -242
- package/src/functions/arguments.ts +0 -114
- package/src/functions/dates.ts +0 -302
- package/src/functions/helpers.ts +0 -592
- package/src/functions/index.ts +0 -52
- package/src/functions/module_database.ts +0 -282
- package/src/functions/module_date.ts +0 -743
- package/src/functions/module_info.ts +0 -69
- package/src/functions/module_logical.ts +0 -208
- package/src/functions/module_lookup.ts +0 -185
- package/src/functions/module_math.ts +0 -1252
- package/src/functions/module_operators.ts +0 -291
- package/src/functions/module_statistical.ts +0 -882
- package/src/functions/module_text.ts +0 -370
- package/src/helpers/color.ts +0 -30
- package/src/helpers/coordinates.ts +0 -71
- package/src/helpers/grid_manipulation.ts +0 -68
- package/src/helpers/index.ts +0 -7
- package/src/helpers/misc.ts +0 -76
- package/src/helpers/numbers.ts +0 -117
- package/src/helpers/uuid.ts +0 -19
- package/src/helpers/zones.ts +0 -263
- package/src/history.ts +0 -186
- package/src/index.ts +0 -84
- package/src/model.ts +0 -261
- package/src/plugins/autofill.ts +0 -412
- package/src/plugins/chart.ts +0 -404
- package/src/plugins/clipboard.ts +0 -461
- package/src/plugins/conditional_format.ts +0 -445
- package/src/plugins/core.ts +0 -1502
- package/src/plugins/edition.ts +0 -157
- package/src/plugins/evaluation.ts +0 -428
- package/src/plugins/figures.ts +0 -123
- package/src/plugins/formatting.ts +0 -630
- package/src/plugins/highlight.ts +0 -187
- package/src/plugins/index.ts +0 -32
- package/src/plugins/merge.ts +0 -524
- package/src/plugins/renderer.ts +0 -571
- package/src/plugins/selection.ts +0 -562
- package/src/plugins/selection_inputs.ts +0 -326
- package/src/registries/autofill_modifiers.ts +0 -76
- package/src/registries/autofill_rules.ts +0 -98
- package/src/registries/figure_registry.ts +0 -30
- package/src/registries/index.ts +0 -7
- package/src/registries/menu_items_registry.ts +0 -110
- package/src/registries/menus/cell_menu_registry.ts +0 -79
- package/src/registries/menus/col_menu_registry.ts +0 -63
- package/src/registries/menus/index.ts +0 -6
- package/src/registries/menus/menu_items_actions.ts +0 -425
- package/src/registries/menus/row_menu_registry.ts +0 -63
- package/src/registries/menus/sheet_menu_registry.ts +0 -75
- package/src/registries/menus/topbar_menu_registry.ts +0 -204
- package/src/registries/side_panel_registry.ts +0 -26
- package/src/registries/topbar_component_registry.ts +0 -12
- package/src/registry.ts +0 -51
- package/src/translation.ts +0 -44
- package/src/types/autofill.ts +0 -48
- package/src/types/chart.ts +0 -26
- package/src/types/commands.ts +0 -716
- package/src/types/conditional_formatting.ts +0 -124
- package/src/types/env.ts +0 -13
- package/src/types/functions.ts +0 -35
- package/src/types/getters.ts +0 -103
- package/src/types/index.ts +0 -20
- package/src/types/misc.ts +0 -143
- package/src/types/rendering.ts +0 -41
- package/src/types/workbook_data.ts +0 -62
- package/tests/__mocks__/uuid.ts +0 -7
- package/tests/canvas.mock.ts +0 -34
- package/tests/components/__mocks__/content_editable_helper.ts +0 -79
- package/tests/components/__mocks__/scrollbar.ts +0 -18
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
- package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
- package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
- package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
- package/tests/components/autocomplete_dropdown_test.ts +0 -315
- package/tests/components/autofill_test.ts +0 -167
- package/tests/components/bottom_bar_test.ts +0 -262
- package/tests/components/chart_side_panel_test.ts +0 -123
- package/tests/components/composer_test.ts +0 -400
- package/tests/components/context_menu_test.ts +0 -825
- package/tests/components/grid_manipulation_test.ts +0 -163
- package/tests/components/grid_test.ts +0 -581
- package/tests/components/overlay_test.ts +0 -541
- package/tests/components/selection_input_test.ts +0 -259
- package/tests/components/side_panel_test.ts +0 -148
- package/tests/components/spreadsheet_test.ts +0 -194
- package/tests/components/top_bar_test.ts +0 -427
- package/tests/data_test.ts +0 -175
- package/tests/dom_helper.ts +0 -42
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
- package/tests/formulas/compiler_test.ts +0 -266
- package/tests/formulas/composer_tokenizer_test.ts +0 -137
- package/tests/formulas/expressions_test.ts +0 -57
- package/tests/formulas/formulas_test.ts +0 -80
- package/tests/formulas/normalize_test.ts +0 -82
- package/tests/formulas/parser_test.ts +0 -224
- package/tests/formulas/range_tokenizer_test.ts +0 -187
- package/tests/formulas/tokenizer_test.ts +0 -164
- package/tests/functions/arguments_test.ts +0 -141
- package/tests/functions/dates_test.ts +0 -1081
- package/tests/functions/functions_test.ts +0 -53
- package/tests/functions/helper_test.ts +0 -98
- package/tests/functions/module_database_test.ts +0 -311
- package/tests/functions/module_date_test.ts +0 -941
- package/tests/functions/module_info_test.ts +0 -139
- package/tests/functions/module_logical_test.ts +0 -369
- package/tests/functions/module_lookup_test.ts +0 -541
- package/tests/functions/module_math_test.ts +0 -2482
- package/tests/functions/module_operators_test.ts +0 -955
- package/tests/functions/module_statistical_test.ts +0 -2014
- package/tests/functions/module_text_test.ts +0 -667
- package/tests/helpers/coordinates_test.ts +0 -25
- package/tests/helpers/misc_test.ts +0 -95
- package/tests/helpers/numbers_test.ts +0 -196
- package/tests/helpers/zones_test.ts +0 -97
- package/tests/helpers.ts +0 -384
- package/tests/menu_items_registry_test.ts +0 -540
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
- package/tests/model/plugins/chart_test.ts +0 -562
- package/tests/model_test.ts +0 -82
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
- package/tests/plugins/autofill_test.ts +0 -457
- package/tests/plugins/borders_test.ts +0 -295
- package/tests/plugins/clipboard_test.ts +0 -1180
- package/tests/plugins/conditional_formatting_test.ts +0 -1253
- package/tests/plugins/core_test.ts +0 -614
- package/tests/plugins/edition_test.ts +0 -100
- package/tests/plugins/evaluation_async_test.ts +0 -332
- package/tests/plugins/evaluation_dates_test.ts +0 -79
- package/tests/plugins/evaluation_test.ts +0 -901
- package/tests/plugins/figures_test.ts +0 -327
- package/tests/plugins/formatting_test.ts +0 -391
- package/tests/plugins/grid_manipulation_test.ts +0 -1366
- package/tests/plugins/highlight_test.ts +0 -413
- package/tests/plugins/history_test.ts +0 -142
- package/tests/plugins/import_export_test.ts +0 -276
- package/tests/plugins/merges_test.ts +0 -490
- package/tests/plugins/navigation_test.ts +0 -181
- package/tests/plugins/plugins/evaluation_test.ts +0 -111
- package/tests/plugins/renderer_test.ts +0 -598
- package/tests/plugins/resizing_test.ts +0 -152
- package/tests/plugins/selection_input_test.ts +0 -409
- package/tests/plugins/selection_test.ts +0 -442
- package/tests/plugins/sheets_test.ts +0 -643
- package/tests/plugins/style_test.ts +0 -90
- package/tsconfig.json +0 -22
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { args, functionRegistry } from "../../src/functions/index";
|
|
2
|
-
import { Model } from "../../src/model";
|
|
3
|
-
import { getCell, GridParent, makeTestFixture, nextTick, resetFunctions } from "../helpers";
|
|
4
|
-
import { ContentEditableHelper } from "./__mocks__/content_editable_helper";
|
|
5
|
-
jest.mock("../../src/components/composer/content_editable_helper", () =>
|
|
6
|
-
require("./__mocks__/content_editable_helper")
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
let model: Model;
|
|
10
|
-
let composerEl: Element;
|
|
11
|
-
let fixture: HTMLElement;
|
|
12
|
-
let parent: any;
|
|
13
|
-
|
|
14
|
-
async function typeInComposer(text: string) {
|
|
15
|
-
const cehMock = parent.grid.comp.composer.comp.contentHelper as ContentEditableHelper;
|
|
16
|
-
cehMock.insertText(text, "#000");
|
|
17
|
-
composerEl.dispatchEvent(new Event("input"));
|
|
18
|
-
composerEl.dispatchEvent(new Event("keyup"));
|
|
19
|
-
await nextTick();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
fixture = makeTestFixture();
|
|
24
|
-
model = new Model();
|
|
25
|
-
parent = new GridParent(model);
|
|
26
|
-
await parent.mount(fixture);
|
|
27
|
-
|
|
28
|
-
// start composition
|
|
29
|
-
parent.grid.el.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
30
|
-
await nextTick();
|
|
31
|
-
composerEl = fixture.querySelector("div.o-composer")!;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
fixture.remove();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("Functions autocomplete", () => {
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
resetFunctions();
|
|
41
|
-
functionRegistry.add("IF", {
|
|
42
|
-
description: "do if",
|
|
43
|
-
args: args(``),
|
|
44
|
-
compute: () => 1,
|
|
45
|
-
returns: ["ANY"],
|
|
46
|
-
});
|
|
47
|
-
functionRegistry.add("SUM", {
|
|
48
|
-
description: "do sum",
|
|
49
|
-
args: args(``),
|
|
50
|
-
compute: () => 1,
|
|
51
|
-
returns: ["ANY"],
|
|
52
|
-
});
|
|
53
|
-
functionRegistry.add("SZZ", {
|
|
54
|
-
description: "do something",
|
|
55
|
-
args: args(``),
|
|
56
|
-
compute: () => 1,
|
|
57
|
-
returns: ["ANY"],
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("autocomplete", () => {
|
|
62
|
-
test("= do not show autocomplete", async () => {
|
|
63
|
-
await typeInComposer("=");
|
|
64
|
-
expect(document.activeElement).toBe(composerEl);
|
|
65
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("simple snapshot with =S", async () => {
|
|
69
|
-
await typeInComposer("=S");
|
|
70
|
-
expect(fixture.querySelector(".o-autocomplete-dropdown")).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("=S show autocomplete functions starting with S", async () => {
|
|
74
|
-
await typeInComposer("=S");
|
|
75
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(2);
|
|
76
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")[0].textContent).toBe("SUM");
|
|
77
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")[1].textContent).toBe("SZZ");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test("=S+TAB complete the function --> =sum(", async () => {
|
|
81
|
-
await typeInComposer("=S");
|
|
82
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Tab" }));
|
|
83
|
-
await nextTick();
|
|
84
|
-
expect(model.getters.getCurrentContent()).toBe("=SUM(");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test("=S+ENTER complete the function --> =sum(", async () => {
|
|
88
|
-
await typeInComposer("=S");
|
|
89
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
90
|
-
await nextTick();
|
|
91
|
-
expect(model.getters.getCurrentContent()).toBe("=SUM(");
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test("=SX not show autocomplete (nothing matches SX)", async () => {
|
|
95
|
-
await typeInComposer("=SX");
|
|
96
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("=SX+ENTER does not autocomplete anything and moves to the cell down", async () => {
|
|
100
|
-
await typeInComposer("=SX");
|
|
101
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Tab" }));
|
|
102
|
-
await nextTick();
|
|
103
|
-
expect(getCell(model, "A1")!.content).toBe("=SX");
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test("=S+UP cycle to the last item", async () => {
|
|
107
|
-
await typeInComposer("=S");
|
|
108
|
-
expect(
|
|
109
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
110
|
-
).toBe("SUM");
|
|
111
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowUp" }));
|
|
112
|
-
await nextTick();
|
|
113
|
-
expect(
|
|
114
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
115
|
-
).toBe("SZZ");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test("=+DOWN+UP move to next/previous autocomplete", async () => {
|
|
119
|
-
await typeInComposer("=S");
|
|
120
|
-
expect(
|
|
121
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
122
|
-
).toBe("SUM");
|
|
123
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown" }));
|
|
124
|
-
await nextTick();
|
|
125
|
-
expect(
|
|
126
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
127
|
-
).toBe("SZZ");
|
|
128
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowUp" }));
|
|
129
|
-
await nextTick();
|
|
130
|
-
expect(
|
|
131
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
132
|
-
).toBe("SUM");
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("=+DOWN+DOWN cycle to the first item", async () => {
|
|
136
|
-
await typeInComposer("=S");
|
|
137
|
-
expect(
|
|
138
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
139
|
-
).toBe("SUM");
|
|
140
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown" }));
|
|
141
|
-
await nextTick();
|
|
142
|
-
expect(
|
|
143
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
144
|
-
).toBe("SZZ");
|
|
145
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown" }));
|
|
146
|
-
await nextTick();
|
|
147
|
-
expect(
|
|
148
|
-
fixture.querySelector(".o-autocomplete-value-focus .o-autocomplete-value")!.textContent
|
|
149
|
-
).toBe("SUM");
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("autocomplete restrict number of proposition to 10", async () => {
|
|
153
|
-
for (let i = 0; i < 20; i++) {
|
|
154
|
-
functionRegistry.add(`SUM${i + 1}`, {
|
|
155
|
-
description: "do sum",
|
|
156
|
-
args: args(``),
|
|
157
|
-
compute: () => 1,
|
|
158
|
-
returns: ["ANY"],
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
await typeInComposer("=S");
|
|
163
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(10);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("click on a autocomplete does the autocomplete", async () => {
|
|
167
|
-
await typeInComposer("=S");
|
|
168
|
-
fixture
|
|
169
|
-
.querySelector(".o-autocomplete-dropdown")!
|
|
170
|
-
.children[1].dispatchEvent(new MouseEvent("click"));
|
|
171
|
-
await nextTick();
|
|
172
|
-
expect(composerEl.textContent).toBe("=SZZ(");
|
|
173
|
-
expect(document.activeElement).toBe(composerEl);
|
|
174
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe("autocomplete functions SUM IF", () => {
|
|
179
|
-
test("empty not show autocomplete", async () => {
|
|
180
|
-
await typeInComposer("");
|
|
181
|
-
expect(document.activeElement).toBe(composerEl);
|
|
182
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
183
|
-
});
|
|
184
|
-
test("=a3 not show autocomplete (its a ref)", async () => {
|
|
185
|
-
await typeInComposer("=a3");
|
|
186
|
-
expect(document.activeElement).toBe(composerEl);
|
|
187
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
188
|
-
});
|
|
189
|
-
test("=a3+ does not show autocomplete (we didn't start typing on the next token", async () => {
|
|
190
|
-
await typeInComposer("=a3+");
|
|
191
|
-
expect(document.activeElement).toBe(composerEl);
|
|
192
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(0);
|
|
193
|
-
});
|
|
194
|
-
test("=sum(s show autocomplete", async () => {
|
|
195
|
-
await typeInComposer("=sum(s");
|
|
196
|
-
expect(document.activeElement).toBe(composerEl);
|
|
197
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(2);
|
|
198
|
-
});
|
|
199
|
-
test("= and CTRL+Space show autocomplete", async () => {
|
|
200
|
-
await typeInComposer("=");
|
|
201
|
-
composerEl.dispatchEvent(new KeyboardEvent("keyup", { key: " ", ctrlKey: true }));
|
|
202
|
-
await nextTick();
|
|
203
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(3);
|
|
204
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Tab" }));
|
|
205
|
-
await nextTick();
|
|
206
|
-
expect(model.getters.getCurrentContent()).toBe("=IF(");
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe("Autocomplete parenthesis", () => {
|
|
212
|
-
beforeAll(() => {
|
|
213
|
-
resetFunctions();
|
|
214
|
-
functionRegistry.add("IF", {
|
|
215
|
-
description: "do if",
|
|
216
|
-
args: args(``),
|
|
217
|
-
compute: () => 1,
|
|
218
|
-
returns: ["ANY"],
|
|
219
|
-
});
|
|
220
|
-
functionRegistry.add("SUM", {
|
|
221
|
-
description: "do sum",
|
|
222
|
-
args: args(``),
|
|
223
|
-
compute: () => 1,
|
|
224
|
-
returns: ["ANY"],
|
|
225
|
-
});
|
|
226
|
-
functionRegistry.add("SZZ", {
|
|
227
|
-
description: "do something",
|
|
228
|
-
args: args(``),
|
|
229
|
-
compute: () => 1,
|
|
230
|
-
returns: ["ANY"],
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
test("=sum(1,2 + enter adds closing parenthesis", async () => {
|
|
235
|
-
await typeInComposer("=sum(1,2");
|
|
236
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
237
|
-
await nextTick();
|
|
238
|
-
expect(getCell(model, "A1")!.content).toBe("=sum(1,2)");
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test("=sum(1,2) + enter + edit sum does not add parenthesis", async () => {
|
|
242
|
-
await typeInComposer("=sum(1,2)");
|
|
243
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
244
|
-
await nextTick();
|
|
245
|
-
model.dispatch("SELECT_CELL", { col: 0, row: 0 });
|
|
246
|
-
//edit A1
|
|
247
|
-
model.dispatch("START_EDITION");
|
|
248
|
-
await nextTick();
|
|
249
|
-
const cehMock = parent.grid.comp.composer.comp.contentHelper as ContentEditableHelper;
|
|
250
|
-
// select SUM
|
|
251
|
-
cehMock.selectRange(1, 4);
|
|
252
|
-
// replace SUM with if
|
|
253
|
-
cehMock.insertText("if", "black");
|
|
254
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown"));
|
|
255
|
-
composerEl.dispatchEvent(new Event("input"));
|
|
256
|
-
composerEl.dispatchEvent(new KeyboardEvent("keyup"));
|
|
257
|
-
await nextTick();
|
|
258
|
-
expect(model.getters.getCurrentContent()).toBe("=if(1,2)");
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test("=S( + edit S with autocomplete does not add left parenthesis", async () => {
|
|
262
|
-
await typeInComposer("=S(");
|
|
263
|
-
// go behind the letter "S"
|
|
264
|
-
const cehMock = parent.grid.comp.composer.comp.contentHelper as ContentEditableHelper;
|
|
265
|
-
cehMock.selectRange(2, 2);
|
|
266
|
-
// type U to display the autocomplete-dropdown with the SUM function
|
|
267
|
-
await typeInComposer("U");
|
|
268
|
-
expect(model.getters.getCurrentContent()).toBe("=SU(");
|
|
269
|
-
expect(document.activeElement).toBe(composerEl);
|
|
270
|
-
expect(fixture.querySelectorAll(".o-autocomplete-value")).toHaveLength(1);
|
|
271
|
-
// select the SUM function
|
|
272
|
-
fixture.querySelector(".o-autocomplete-value-focus")!.dispatchEvent(new MouseEvent("click"));
|
|
273
|
-
await nextTick();
|
|
274
|
-
expect(model.getters.getCurrentContent()).toBe("=SUM(");
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
test("=sum(sum(1,2 + enter add 2 closing parenthesis", async () => {
|
|
278
|
-
await typeInComposer("=sum(sum(1,2");
|
|
279
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
280
|
-
await nextTick();
|
|
281
|
-
expect(getCell(model, "A1")!.content).toBe("=sum(sum(1,2))");
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
test("=sum(sum(1,2) + enter add 1 closing parenthesis", async () => {
|
|
285
|
-
await typeInComposer("=sum(sum(1,2");
|
|
286
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
287
|
-
await nextTick();
|
|
288
|
-
expect(getCell(model, "A1")!.content).toBe("=sum(sum(1,2))");
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test("=sum(sum(1,2) + click outside composer should add the missing parenthesis", async () => {
|
|
292
|
-
await typeInComposer("=sum(sum(1,2");
|
|
293
|
-
|
|
294
|
-
model.dispatch("SELECT_CELL", { col: 1, row: 1 });
|
|
295
|
-
await nextTick();
|
|
296
|
-
expect(getCell(model, "A1")!.content).toBe("=sum(sum(1,2))");
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test('=sum("((((((((") + enter should not complete the parenthesis in the string', async () => {
|
|
300
|
-
await typeInComposer('=sum("((((((((")');
|
|
301
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
302
|
-
await nextTick();
|
|
303
|
-
expect(getCell(model, "A1")!.content).toBe('=sum("((((((((")');
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
test("=s + tab should allow to select a ref", async () => {
|
|
307
|
-
await typeInComposer("=s");
|
|
308
|
-
composerEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Tab" }));
|
|
309
|
-
await nextTick();
|
|
310
|
-
expect(model.getters.getEditionMode()).toBe("selecting");
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
describe("autocomplete parameters", () => {});
|
|
315
|
-
describe("custom autocomplete", () => {});
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import * as owl from "@odoo/owl";
|
|
2
|
-
import { HEADER_HEIGHT, HEADER_WIDTH } from "../../src/constants";
|
|
3
|
-
import { Model } from "../../src/model";
|
|
4
|
-
import { CommandResult } from "../../src/types/commands";
|
|
5
|
-
import { triggerMouseEvent } from "../dom_helper";
|
|
6
|
-
import { GridParent, makeTestFixture, nextTick } from "../helpers";
|
|
7
|
-
|
|
8
|
-
const { Component } = owl;
|
|
9
|
-
const { xml } = owl.tags;
|
|
10
|
-
|
|
11
|
-
jest.spyOn(HTMLDivElement.prototype, "clientWidth", "get").mockImplementation(() => 1000);
|
|
12
|
-
jest.spyOn(HTMLDivElement.prototype, "clientHeight", "get").mockImplementation(() => 1000);
|
|
13
|
-
|
|
14
|
-
let fixture: HTMLElement;
|
|
15
|
-
let model: Model;
|
|
16
|
-
let parent: GridParent;
|
|
17
|
-
|
|
18
|
-
beforeEach(async () => {
|
|
19
|
-
fixture = makeTestFixture();
|
|
20
|
-
model = new Model();
|
|
21
|
-
parent = new GridParent(model);
|
|
22
|
-
await parent.mount(fixture);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
fixture.remove();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("Autofill component", () => {
|
|
30
|
-
test("Can drag and drop autofill on columns", async () => {
|
|
31
|
-
parent.env.dispatch = jest.fn((command) => ({ status: "SUCCESS" } as CommandResult));
|
|
32
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
33
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
34
|
-
await nextTick();
|
|
35
|
-
triggerMouseEvent(
|
|
36
|
-
autofill,
|
|
37
|
-
"mousemove",
|
|
38
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start + 10,
|
|
39
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 1).end + 10
|
|
40
|
-
);
|
|
41
|
-
await nextTick();
|
|
42
|
-
expect(parent.env.dispatch).toHaveBeenCalledWith("AUTOFILL_SELECT", { col: 0, row: 2 });
|
|
43
|
-
triggerMouseEvent(autofill, "mouseup");
|
|
44
|
-
await nextTick();
|
|
45
|
-
expect(parent.env.dispatch).toHaveBeenCalledWith("AUTOFILL");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("Can drag and drop autofill on rows", async () => {
|
|
49
|
-
parent.env.dispatch = jest.fn((command) => ({ status: "SUCCESS" } as CommandResult));
|
|
50
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
51
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
52
|
-
await nextTick();
|
|
53
|
-
triggerMouseEvent(
|
|
54
|
-
autofill,
|
|
55
|
-
"mousemove",
|
|
56
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 1).end + 10,
|
|
57
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 0).start + 10
|
|
58
|
-
);
|
|
59
|
-
await nextTick();
|
|
60
|
-
expect(parent.env.dispatch).toHaveBeenCalledWith("AUTOFILL_SELECT", { col: 2, row: 0 });
|
|
61
|
-
triggerMouseEvent(autofill, "mouseup");
|
|
62
|
-
await nextTick();
|
|
63
|
-
expect(parent.env.dispatch).toHaveBeenCalledWith("AUTOFILL");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("Can auto-autofill with dblclick", async () => {
|
|
67
|
-
parent.env.dispatch = jest.fn((command) => ({ status: "SUCCESS" } as CommandResult));
|
|
68
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
69
|
-
triggerMouseEvent(autofill, "dblclick", 4, 4);
|
|
70
|
-
await nextTick();
|
|
71
|
-
expect(parent.env.dispatch).toHaveBeenCalledWith("AUTOFILL_AUTO");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("Can display tooltip with autofill", async () => {
|
|
75
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
76
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeNull();
|
|
77
|
-
model.dispatch("SET_VALUE", { xc: "A1", text: "test" });
|
|
78
|
-
await nextTick();
|
|
79
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
80
|
-
await nextTick();
|
|
81
|
-
triggerMouseEvent(
|
|
82
|
-
autofill,
|
|
83
|
-
"mousemove",
|
|
84
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start + 10,
|
|
85
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 1).end + 10
|
|
86
|
-
);
|
|
87
|
-
await nextTick();
|
|
88
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeDefined();
|
|
89
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")!.textContent).toBe("test");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("Tooltip is removed when cancelling autofill", async () => {
|
|
93
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
94
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeNull();
|
|
95
|
-
model.dispatch("SET_VALUE", { xc: "A1", text: "test" });
|
|
96
|
-
await nextTick();
|
|
97
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
98
|
-
await nextTick();
|
|
99
|
-
triggerMouseEvent(
|
|
100
|
-
autofill,
|
|
101
|
-
"mousemove",
|
|
102
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start + 10,
|
|
103
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 1).end + 10
|
|
104
|
-
);
|
|
105
|
-
await nextTick();
|
|
106
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeDefined();
|
|
107
|
-
triggerMouseEvent(
|
|
108
|
-
autofill,
|
|
109
|
-
"mousemove",
|
|
110
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start + 10,
|
|
111
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 0).start + 10
|
|
112
|
-
);
|
|
113
|
-
await nextTick();
|
|
114
|
-
triggerMouseEvent(autofill, "mouseup");
|
|
115
|
-
await nextTick();
|
|
116
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeNull();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test("Can display tooltip with a custom component", async () => {
|
|
120
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
121
|
-
class CustomTooltip extends Component {
|
|
122
|
-
static template = xml/* xml */ `
|
|
123
|
-
<div class="custom_tooltip" t-esc="props.content"/>
|
|
124
|
-
`;
|
|
125
|
-
}
|
|
126
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeNull();
|
|
127
|
-
parent.env.getters.getAutofillTooltip = jest.fn(() => {
|
|
128
|
-
return {
|
|
129
|
-
props: { content: "blabla" },
|
|
130
|
-
component: CustomTooltip,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
model.dispatch("SET_VALUE", { xc: "A1", text: "test" });
|
|
134
|
-
await nextTick();
|
|
135
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
136
|
-
await nextTick();
|
|
137
|
-
triggerMouseEvent(
|
|
138
|
-
autofill,
|
|
139
|
-
"mousemove",
|
|
140
|
-
HEADER_WIDTH + parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start + 10,
|
|
141
|
-
HEADER_HEIGHT + parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 1).end + 10
|
|
142
|
-
);
|
|
143
|
-
await nextTick();
|
|
144
|
-
expect(fixture.querySelector(".o-autofill-nextvalue")).toBeDefined();
|
|
145
|
-
expect(fixture.querySelector(".custom_tooltip")).toBeDefined();
|
|
146
|
-
expect(fixture.querySelector(".custom_tooltip")!.textContent).toBe("blabla");
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("Autofill on the last col/row", async () => {
|
|
150
|
-
parent.env.dispatch = jest.fn((command) => ({ status: "SUCCESS" } as CommandResult));
|
|
151
|
-
const autofill = fixture.querySelector(".o-autofill");
|
|
152
|
-
triggerMouseEvent(autofill, "mousedown", 4, 4);
|
|
153
|
-
await nextTick();
|
|
154
|
-
triggerMouseEvent(
|
|
155
|
-
autofill,
|
|
156
|
-
"mousemove",
|
|
157
|
-
HEADER_WIDTH +
|
|
158
|
-
parent.env.getters.getCol(parent.env.getters.getActiveSheet(), 0).start +
|
|
159
|
-
10000,
|
|
160
|
-
HEADER_HEIGHT +
|
|
161
|
-
parent.env.getters.getRow(parent.env.getters.getActiveSheet(), 1).start +
|
|
162
|
-
10000
|
|
163
|
-
);
|
|
164
|
-
await nextTick();
|
|
165
|
-
expect(parent.env.dispatch).not.toHaveBeenCalled();
|
|
166
|
-
});
|
|
167
|
-
});
|