@odoo/o-spreadsheet 14.0.1 → 15.0.0
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 +31302 -0
- package/dist/o_spreadsheet.d.ts +6604 -0
- package/dist/o_spreadsheet.esm.js +31257 -0
- package/dist/o_spreadsheet.iife.js +31304 -0
- package/dist/o_spreadsheet.iife.min.js +3071 -0
- package/package.json +57 -15
- 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,396 +0,0 @@
|
|
|
1
|
-
import * as owl from "@odoo/owl";
|
|
2
|
-
import { colorNumberString, uuidv4 } from "../../helpers/index";
|
|
3
|
-
import {
|
|
4
|
-
ColorScaleRule,
|
|
5
|
-
ConditionalFormat,
|
|
6
|
-
SingleColorRules,
|
|
7
|
-
SpreadsheetEnv,
|
|
8
|
-
UID,
|
|
9
|
-
Zone,
|
|
10
|
-
} from "../../types";
|
|
11
|
-
import { SelectionInput } from "../selection_input";
|
|
12
|
-
import { CellIsRuleEditor } from "./cell_is_rule_editor";
|
|
13
|
-
import { ColorScaleRuleEditor } from "./color_scale_rule_editor";
|
|
14
|
-
import { cellIsOperators } from "./translations_terms";
|
|
15
|
-
|
|
16
|
-
const { Component, useState } = owl;
|
|
17
|
-
const { xml, css } = owl.tags;
|
|
18
|
-
|
|
19
|
-
// TODO vsc: add ordering of rules
|
|
20
|
-
const PREVIEW_TEMPLATE = xml/* xml */ `
|
|
21
|
-
<div class="o-cf-preview">
|
|
22
|
-
<div t-att-style="getStyle(cf.rule)" class="o-cf-preview-image">
|
|
23
|
-
123
|
|
24
|
-
</div>
|
|
25
|
-
<div class="o-cf-preview-description">
|
|
26
|
-
<div class="o-cf-preview-ruletype">
|
|
27
|
-
<div class="o-cf-preview-description-rule">
|
|
28
|
-
<t t-esc="getDescription(cf)" />
|
|
29
|
-
</div>
|
|
30
|
-
<div class="o-cf-preview-description-values">
|
|
31
|
-
<t t-if="cf.rule.values">
|
|
32
|
-
<t t-esc="cf.rule.values[0]" />
|
|
33
|
-
<t t-if="cf.rule.values[1]">
|
|
34
|
-
and <t t-esc="cf.rule.values[1]"/>
|
|
35
|
-
</t>
|
|
36
|
-
</t>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="o-cf-preview-range" t-esc="cf.ranges"/>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="o-cf-delete">
|
|
42
|
-
<div class="o-cf-delete-button" t-on-click.stop="onDeleteClick(cf)" aria-label="Remove rule">
|
|
43
|
-
x
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>`;
|
|
47
|
-
|
|
48
|
-
const TEMPLATE = xml/* xml */ `
|
|
49
|
-
<div class="o-cf">
|
|
50
|
-
<t t-if="state.mode === 'list'">
|
|
51
|
-
<div class="o-cf-preview-list" >
|
|
52
|
-
<div t-on-click="onRuleClick(cf)" t-foreach="getters.getConditionalFormats()" t-as="cf" t-key="cf.id">
|
|
53
|
-
<t t-call="${PREVIEW_TEMPLATE}"/>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</t>
|
|
57
|
-
<t t-if="state.mode === 'edit' || state.mode === 'add'" t-key="state.currentCF.id">
|
|
58
|
-
<div class="o-cf-type-selector">
|
|
59
|
-
<div class="o-cf-type-tab" t-att-class="{'o-cf-tab-selected': state.toRuleType === 'CellIsRule'}" t-on-click="setRuleType('CellIsRule')">Single Color</div>
|
|
60
|
-
<div class="o-cf-type-tab" t-att-class="{'o-cf-tab-selected': state.toRuleType === 'ColorScaleRule'}" t-on-click="setRuleType('ColorScaleRule')">Color Scale</div>
|
|
61
|
-
</div>
|
|
62
|
-
<div class="o-cf-ruleEditor">
|
|
63
|
-
<div class="o-section o-cf-range">
|
|
64
|
-
<div class="o-section-title">Apply to range</div>
|
|
65
|
-
<SelectionInput ranges="state.currentRanges" class="o-range" t-on-selection-changed="onRangesChanged"/>
|
|
66
|
-
</div>
|
|
67
|
-
<div class="o-cf-editor o-section">
|
|
68
|
-
<t t-component="editors[state.currentCF.rule.type]"
|
|
69
|
-
t-key="state.currentCF.id"
|
|
70
|
-
conditionalFormat="state.currentCF"
|
|
71
|
-
t-on-cancel-edit="onCancel"
|
|
72
|
-
t-on-modify-rule="onSave" />
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</t>
|
|
76
|
-
<div class="o-cf-add" t-if="state.mode === 'list'" t-on-click.prevent.stop="onAdd">
|
|
77
|
-
+ Add another rule
|
|
78
|
-
</div>
|
|
79
|
-
</div>`;
|
|
80
|
-
|
|
81
|
-
const CSS = css/* scss */ `
|
|
82
|
-
.o-cf {
|
|
83
|
-
min-width: 350px;
|
|
84
|
-
.o-cf-type-selector {
|
|
85
|
-
margin-top: 20px;
|
|
86
|
-
display: flex;
|
|
87
|
-
.o-cf-type-tab {
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
flex-grow: 1;
|
|
90
|
-
text-align: center;
|
|
91
|
-
}
|
|
92
|
-
.o-cf-tab-selected {
|
|
93
|
-
text-decoration: underline;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
.o-cf-preview {
|
|
97
|
-
background-color: #fff;
|
|
98
|
-
border-bottom: 1px solid #ccc;
|
|
99
|
-
cursor: pointer;
|
|
100
|
-
display: flex;
|
|
101
|
-
height: 60px;
|
|
102
|
-
padding: 10px;
|
|
103
|
-
position: relative;
|
|
104
|
-
&:hover {
|
|
105
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
106
|
-
}
|
|
107
|
-
&:not(:hover) .o-cf-delete-button {
|
|
108
|
-
display: none;
|
|
109
|
-
}
|
|
110
|
-
.o-cf-preview-image {
|
|
111
|
-
border: 1px solid lightgrey;
|
|
112
|
-
height: 50px;
|
|
113
|
-
line-height: 50px;
|
|
114
|
-
margin-right: 15px;
|
|
115
|
-
position: absolute;
|
|
116
|
-
text-align: center;
|
|
117
|
-
width: 50px;
|
|
118
|
-
}
|
|
119
|
-
.o-cf-preview-description {
|
|
120
|
-
left: 65px;
|
|
121
|
-
margin-bottom: auto;
|
|
122
|
-
margin-right: 8px;
|
|
123
|
-
margin-top: auto;
|
|
124
|
-
position: relative;
|
|
125
|
-
width: 142px;
|
|
126
|
-
.o-cf-preview-description-rule {
|
|
127
|
-
margin-bottom: 4px;
|
|
128
|
-
overflow: hidden;
|
|
129
|
-
}
|
|
130
|
-
.o-cf-preview-description-values {
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
}
|
|
133
|
-
.o-cf-preview-range {
|
|
134
|
-
text-overflow: ellipsis;
|
|
135
|
-
font-size: 12px;
|
|
136
|
-
overflow: hidden;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
.o-cf-delete {
|
|
140
|
-
height: 56px;
|
|
141
|
-
left: 90%;
|
|
142
|
-
line-height: 56px;
|
|
143
|
-
position: absolute;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
.o-cf-ruleEditor {
|
|
147
|
-
.o-dropdown {
|
|
148
|
-
position: relative;
|
|
149
|
-
.o-dropdown-content {
|
|
150
|
-
position: absolute;
|
|
151
|
-
top: calc(100% + 5px);
|
|
152
|
-
left: 0;
|
|
153
|
-
z-index: 10;
|
|
154
|
-
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
155
|
-
background-color: #f6f6f6;
|
|
156
|
-
|
|
157
|
-
.o-dropdown-item {
|
|
158
|
-
padding: 7px 10px;
|
|
159
|
-
}
|
|
160
|
-
.o-dropdown-item:hover {
|
|
161
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
162
|
-
}
|
|
163
|
-
.o-dropdown-line {
|
|
164
|
-
display: flex;
|
|
165
|
-
padding: 3px 6px;
|
|
166
|
-
.o-line-item {
|
|
167
|
-
width: 16px;
|
|
168
|
-
height: 16px;
|
|
169
|
-
margin: 1px 3px;
|
|
170
|
-
&:hover {
|
|
171
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.o-tools {
|
|
179
|
-
color: #333;
|
|
180
|
-
font-size: 13px;
|
|
181
|
-
cursor: default;
|
|
182
|
-
display: flex;
|
|
183
|
-
|
|
184
|
-
.o-tool {
|
|
185
|
-
display: flex;
|
|
186
|
-
align-items: center;
|
|
187
|
-
margin: 2px;
|
|
188
|
-
padding: 0 3px;
|
|
189
|
-
border-radius: 2px;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.o-tool.active,
|
|
193
|
-
.o-tool:not(.o-disabled):hover {
|
|
194
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.o-with-color > span {
|
|
198
|
-
border-bottom: 4px solid;
|
|
199
|
-
height: 16px;
|
|
200
|
-
margin-top: 2px;
|
|
201
|
-
}
|
|
202
|
-
.o-with-color {
|
|
203
|
-
.o-line-item:hover {
|
|
204
|
-
outline: 1px solid gray;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
.o-border {
|
|
208
|
-
.o-line-item {
|
|
209
|
-
padding: 4px;
|
|
210
|
-
margin: 1px;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
.o-cell-content {
|
|
215
|
-
font-size: 12px;
|
|
216
|
-
font-weight: 500;
|
|
217
|
-
padding: 0 12px;
|
|
218
|
-
margin: 0;
|
|
219
|
-
line-height: 35px;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
.o-cf-add {
|
|
223
|
-
font-size: 14px;
|
|
224
|
-
height: 36px;
|
|
225
|
-
padding: 20px 24px 11px 24px;
|
|
226
|
-
height: 44px;
|
|
227
|
-
cursor: pointer;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
`;
|
|
231
|
-
interface Props {
|
|
232
|
-
selection?: [Zone];
|
|
233
|
-
}
|
|
234
|
-
export class ConditionalFormattingPanel extends Component<Props, SpreadsheetEnv> {
|
|
235
|
-
static template = TEMPLATE;
|
|
236
|
-
static style = CSS;
|
|
237
|
-
static components = { CellIsRuleEditor, ColorScaleRuleEditor, SelectionInput };
|
|
238
|
-
colorNumberString = colorNumberString;
|
|
239
|
-
getters = this.env.getters;
|
|
240
|
-
private activeSheetId: UID;
|
|
241
|
-
|
|
242
|
-
//@ts-ignore --> used in XML template
|
|
243
|
-
private cellIsOperators = cellIsOperators;
|
|
244
|
-
state = useState({
|
|
245
|
-
currentCF: undefined as undefined | ConditionalFormat,
|
|
246
|
-
currentRanges: [] as string[],
|
|
247
|
-
mode: "list" as "list" | "edit" | "add",
|
|
248
|
-
toRuleType: "CellIsRule",
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
editors = {
|
|
252
|
-
CellIsRule: CellIsRuleEditor,
|
|
253
|
-
ColorScaleRule: ColorScaleRuleEditor,
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
constructor(parent, props: Props) {
|
|
257
|
-
super(parent, props);
|
|
258
|
-
this.activeSheetId = this.getters.getActiveSheet();
|
|
259
|
-
if (props.selection && this.getters.getRulesSelection(props.selection).length === 1) {
|
|
260
|
-
this.openCf(this.getters.getRulesSelection(props.selection)[0]);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
async willUpdateProps(nextProps: Props) {
|
|
264
|
-
const newActiveSheetId = this.getters.getActiveSheet();
|
|
265
|
-
if (newActiveSheetId !== this.activeSheetId) {
|
|
266
|
-
this.activeSheetId = newActiveSheetId;
|
|
267
|
-
this.resetState();
|
|
268
|
-
} else if (nextProps.selection && nextProps.selection !== this.props.selection)
|
|
269
|
-
if (nextProps.selection && this.getters.getRulesSelection(nextProps.selection).length === 1) {
|
|
270
|
-
this.openCf(this.getters.getRulesSelection(nextProps.selection)[0]);
|
|
271
|
-
} else {
|
|
272
|
-
this.resetState();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
resetState() {
|
|
277
|
-
this.state.currentCF = undefined;
|
|
278
|
-
this.state.currentRanges = [];
|
|
279
|
-
this.state.mode = "list";
|
|
280
|
-
this.state.toRuleType = "CellIsRule";
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
getStyle(rule: SingleColorRules | ColorScaleRule): string {
|
|
284
|
-
if (rule.type === "CellIsRule") {
|
|
285
|
-
const cellRule = rule as SingleColorRules;
|
|
286
|
-
const fontWeight = cellRule.style.bold ? "bold" : "normal";
|
|
287
|
-
const fontDecoration = cellRule.style.strikethrough ? "line-through" : "none";
|
|
288
|
-
const fontStyle = cellRule.style.italic ? "italic" : "normal";
|
|
289
|
-
const color = cellRule.style.textColor || "none";
|
|
290
|
-
const backgroundColor = cellRule.style.fillColor || "none";
|
|
291
|
-
return `font-weight:${fontWeight};
|
|
292
|
-
text-decoration:${fontDecoration};
|
|
293
|
-
font-style:${fontStyle};
|
|
294
|
-
color:${color};
|
|
295
|
-
background-color:${backgroundColor};`;
|
|
296
|
-
} else {
|
|
297
|
-
const colorScale = rule as ColorScaleRule;
|
|
298
|
-
return `background-image: linear-gradient(to right, #${colorNumberString(
|
|
299
|
-
colorScale.minimum.color
|
|
300
|
-
)}, #${colorNumberString(colorScale.maximum.color)})`;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
getDescription(cf: ConditionalFormat): string {
|
|
305
|
-
return cf.rule.type === "CellIsRule" ? cellIsOperators[cf.rule.operator] : "Color scale";
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
onSave(ev: CustomEvent) {
|
|
309
|
-
if (this.state.currentCF) {
|
|
310
|
-
this.env.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
311
|
-
cf: {
|
|
312
|
-
rule: ev.detail.rule,
|
|
313
|
-
ranges: this.state.currentRanges,
|
|
314
|
-
id: this.state.mode === "edit" ? this.state.currentCF.id : uuidv4(),
|
|
315
|
-
},
|
|
316
|
-
sheet: this.getters.getActiveSheet(),
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
this.state.mode = "list";
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
onCancel() {
|
|
323
|
-
this.state.mode = "list";
|
|
324
|
-
this.state.currentCF = undefined;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
onDeleteClick(cf: ConditionalFormat) {
|
|
328
|
-
this.env.dispatch("REMOVE_CONDITIONAL_FORMAT", {
|
|
329
|
-
id: cf.id,
|
|
330
|
-
sheet: this.getters.getActiveSheet(),
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
onRuleClick(cf) {
|
|
334
|
-
this.state.mode = "edit";
|
|
335
|
-
this.state.currentCF = cf;
|
|
336
|
-
this.state.toRuleType = cf.rule.type === "CellIsRule" ? "CellIsRule" : "ColorScaleRule";
|
|
337
|
-
this.state.currentRanges = this.state.currentCF!.ranges;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
openCf(cfId) {
|
|
341
|
-
const rules = this.getters.getConditionalFormats();
|
|
342
|
-
const cfIndex = rules.findIndex((c) => c.id === cfId);
|
|
343
|
-
const cf = rules[cfIndex];
|
|
344
|
-
if (cf) {
|
|
345
|
-
this.state.mode = "edit";
|
|
346
|
-
this.state.currentCF = cf;
|
|
347
|
-
this.state.toRuleType = cf.rule.type === "CellIsRule" ? "CellIsRule" : "ColorScaleRule";
|
|
348
|
-
this.state.currentRanges = this.state.currentCF!.ranges;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
defaultCellIsRule(): ConditionalFormat {
|
|
353
|
-
return {
|
|
354
|
-
rule: {
|
|
355
|
-
type: "CellIsRule",
|
|
356
|
-
operator: "Equal",
|
|
357
|
-
values: [],
|
|
358
|
-
style: { fillColor: "#FF0000" },
|
|
359
|
-
},
|
|
360
|
-
ranges: this.getters.getSelectedZones().map(this.getters.zoneToXC),
|
|
361
|
-
id: uuidv4(),
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
defaultColorScaleRule(): ConditionalFormat {
|
|
366
|
-
return {
|
|
367
|
-
rule: {
|
|
368
|
-
minimum: { type: "value", color: 0 },
|
|
369
|
-
maximum: { type: "value", color: 0xeeffee },
|
|
370
|
-
type: "ColorScaleRule",
|
|
371
|
-
},
|
|
372
|
-
ranges: this.getters.getSelectedZones().map(this.getters.zoneToXC),
|
|
373
|
-
id: uuidv4(),
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
onAdd() {
|
|
378
|
-
this.state.mode = "add";
|
|
379
|
-
this.state.currentCF = this.defaultCellIsRule();
|
|
380
|
-
this.state.currentRanges = this.state.currentCF!.ranges;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
setRuleType(ruleType: string) {
|
|
384
|
-
if (ruleType === "ColorScaleRule") {
|
|
385
|
-
this.state.currentCF = this.defaultColorScaleRule();
|
|
386
|
-
}
|
|
387
|
-
if (ruleType === "CellIsRule") {
|
|
388
|
-
this.state.currentCF = this.defaultCellIsRule();
|
|
389
|
-
}
|
|
390
|
-
this.state.toRuleType = ruleType;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
onRangesChanged({ detail }: { detail: { ranges: string[] } }) {
|
|
394
|
-
this.state.currentRanges = detail.ranges;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import * as owl from "@odoo/owl";
|
|
2
|
-
import { SidePanelContent, sidePanelRegistry } from "../../registries/side_panel_registry";
|
|
3
|
-
import { SpreadsheetEnv } from "../../types";
|
|
4
|
-
|
|
5
|
-
const { Component } = owl;
|
|
6
|
-
const { xml, css } = owl.tags;
|
|
7
|
-
const { useState } = owl.hooks;
|
|
8
|
-
|
|
9
|
-
const TEMPLATE = xml/* xml */ `
|
|
10
|
-
<div class="o-sidePanel" >
|
|
11
|
-
<div class="o-sidePanelHeader">
|
|
12
|
-
<div class="o-sidePanelTitle" t-esc="getTitle()"/>
|
|
13
|
-
<div class="o-sidePanelClose" t-on-click="trigger('close-side-panel')">×</div>
|
|
14
|
-
</div>
|
|
15
|
-
<div class="o-sidePanelBody">
|
|
16
|
-
<t t-component="state.panel.Body" t-props="props.panelProps" t-key="'Body_' + props.component"/>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="o-sidePanelFooter" t-if="state.panel.Footer">
|
|
19
|
-
<t t-component="state.panel.Footer" t-props="props.panelProps" t-key="'Footer_' + props.component"/>
|
|
20
|
-
</div>
|
|
21
|
-
</div>`;
|
|
22
|
-
|
|
23
|
-
const CSS = css/* scss */ `
|
|
24
|
-
.o-sidePanel {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
overflow-x: hidden;
|
|
28
|
-
background-color: white;
|
|
29
|
-
border: 1px solid darkgray;
|
|
30
|
-
.o-sidePanelHeader {
|
|
31
|
-
padding: 6px;
|
|
32
|
-
height: 30px;
|
|
33
|
-
background-color: #f8f9fa;
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
justify-content: space-between;
|
|
37
|
-
border-bottom: 1px solid darkgray;
|
|
38
|
-
font-weight: bold;
|
|
39
|
-
.o-sidePanelTitle {
|
|
40
|
-
font-weight: bold;
|
|
41
|
-
padding: 5px 10px;
|
|
42
|
-
font-size: 1.2rem;
|
|
43
|
-
}
|
|
44
|
-
.o-sidePanelClose {
|
|
45
|
-
font-size: 1.5rem;
|
|
46
|
-
padding: 5px 10px;
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
&:hover {
|
|
49
|
-
background-color: WhiteSmoke;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
.o-sidePanelBody {
|
|
54
|
-
overflow: auto;
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.o-sidePanelButtons {
|
|
60
|
-
padding: 5px 16px;
|
|
61
|
-
text-align: right;
|
|
62
|
-
.o-sidePanelButton {
|
|
63
|
-
border: 1px solid lightgrey;
|
|
64
|
-
padding: 0px 20px 0px 20px;
|
|
65
|
-
border-radius: 4px;
|
|
66
|
-
font-weight: 500;
|
|
67
|
-
font-size: 14px;
|
|
68
|
-
height: 30px;
|
|
69
|
-
line-height: 16px;
|
|
70
|
-
background: white;
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
margin-right: 8px;
|
|
73
|
-
&:hover {
|
|
74
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
.o-sidePanelButton:last-child {
|
|
78
|
-
margin-right: 0px;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
.o-input {
|
|
82
|
-
border-radius: 4px;
|
|
83
|
-
border: 1px solid lightgrey;
|
|
84
|
-
padding: 4px 6px;
|
|
85
|
-
width: 96%;
|
|
86
|
-
.o-type-selector {
|
|
87
|
-
background-position: right 5px top 11px;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
select.o-input {
|
|
91
|
-
background-color: white;
|
|
92
|
-
text-align: left;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.o-section {
|
|
96
|
-
padding: 16px;
|
|
97
|
-
.o-section-title {
|
|
98
|
-
font-weight: bold;
|
|
99
|
-
margin-bottom: 5px;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`;
|
|
104
|
-
|
|
105
|
-
interface Props {
|
|
106
|
-
component: string;
|
|
107
|
-
panelProps: any;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class SidePanel extends Component<Props, SpreadsheetEnv> {
|
|
111
|
-
static template = TEMPLATE;
|
|
112
|
-
static style = CSS;
|
|
113
|
-
|
|
114
|
-
state: { panel: SidePanelContent } = useState({
|
|
115
|
-
panel: sidePanelRegistry.get(this.props.component),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
async willUpdateProps(nextProps: Props) {
|
|
119
|
-
this.state.panel = sidePanelRegistry.get(nextProps.component);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
getTitle() {
|
|
123
|
-
return typeof this.state.panel.title === "function"
|
|
124
|
-
? this.state.panel.title(this.env)
|
|
125
|
-
: this.state.panel.title;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { _lt } from "../../translation";
|
|
2
|
-
|
|
3
|
-
export const terms = {
|
|
4
|
-
CF_TITLE: _lt("Format rules"),
|
|
5
|
-
IS_RULE: _lt("Format cells if..."),
|
|
6
|
-
FORMATTING_STYLE: _lt("Formatting style"),
|
|
7
|
-
BOLD: _lt("Bold"),
|
|
8
|
-
ITALIC: _lt("Italic"),
|
|
9
|
-
STRIKETHROUGH: _lt("Strikethrough"),
|
|
10
|
-
TEXTCOLOR: _lt("Text Color"),
|
|
11
|
-
FILLCOLOR: _lt("Fill Color"),
|
|
12
|
-
CANCEL: _lt("Cancel"),
|
|
13
|
-
SAVE: _lt("Save"),
|
|
14
|
-
PREVIEWTEXT: _lt("Preview text"),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const cellIsOperators = {
|
|
18
|
-
BeginsWith: _lt("Begins with"),
|
|
19
|
-
Between: _lt("Between"),
|
|
20
|
-
ContainsText: _lt("Contains text"),
|
|
21
|
-
EndsWith: _lt("Ends with"),
|
|
22
|
-
Equal: _lt("Is equal to"),
|
|
23
|
-
GreaterThan: _lt("Greater than"),
|
|
24
|
-
GreaterThanOrEqual: _lt("Greater than or equal"),
|
|
25
|
-
LessThan: _lt("Less than"),
|
|
26
|
-
LessThanOrEqual: _lt("Less than or equal"),
|
|
27
|
-
NotBetween: _lt("Not between"),
|
|
28
|
-
NotContains: _lt("Not contains"),
|
|
29
|
-
NotEqual: _lt("Not equal"),
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const chartTerms = {
|
|
33
|
-
ChartType: _lt("Chart type"),
|
|
34
|
-
Line: _lt("Line"),
|
|
35
|
-
Bar: _lt("Bar"),
|
|
36
|
-
Pie: _lt("Pie"),
|
|
37
|
-
Title: _lt("Title"),
|
|
38
|
-
Series: _lt("Series"),
|
|
39
|
-
DataSeries: _lt("Data Series"),
|
|
40
|
-
MyDataHasTitle: _lt("My data has title"),
|
|
41
|
-
DataCategories: _lt("Data categories (labels)"),
|
|
42
|
-
UpdateChart: _lt("Update chart"),
|
|
43
|
-
CreateChart: _lt("Create chart"),
|
|
44
|
-
TitlePlaceholder: _lt("New Chart"),
|
|
45
|
-
};
|