@seafile/sdoc-editor 0.3.25 → 0.3.26-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/api/seafile-api.js +20 -0
- package/dist/basic-sdk/constants/index.js +2 -1
- package/dist/basic-sdk/editor/sdoc-editor.js +20 -2
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/constants/menus-config.js +6 -1
- package/dist/basic-sdk/extension/plugins/chart/chart-components/base-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/column-setting.js +119 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/data-sort-setting.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/date-granularities.js +55 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/dtable-select-setting.js +86 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/geolocation-granularities.js +97 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-item.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-items.js +87 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/include-empty-setting.js +35 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-field-setting.js +64 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-method-setting.js +61 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-type-setting.js +74 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/x-axis-group-setting.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/y-axis-group-settings.js +182 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/common-add-tool.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/common-hooks.js +15 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/constants.js +10 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/index.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/option-group.js +236 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/option.js +40 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/select.css +135 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/date-translate.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/department-multiple-select.js +146 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/department-single-select.js +272 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/index.css +209 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/index.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/selected-departments.js +85 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/dtable-search-input.js +127 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/collaborator-filter.js +106 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/department-multiple-select-filter.js +86 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/department-single-select-filter.js +85 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-calendar.js +166 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-item-utils.js +144 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-item.js +679 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filters-list.css +320 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filters-list.js +121 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/rate-item.js +72 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover.js +208 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filters-popover.css +30 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/index.css +18 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/index.js +79 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/utils.js +531 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/index.js +28 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/style.css +52 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/table-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/index.js +27 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/style.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.css +22 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.js +111 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.css +24 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.js +120 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/base-utils.js +430 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/dtable-utils.js +144 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/histogram-bar-utils.js +83 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/date-constants.js +9 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/geolocation-constants.js +11 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/index.js +109 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/special-column-types.js +7 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/summary-constants.js +18 -0
- package/dist/basic-sdk/extension/plugins/chart/helpers.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.css +55 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/index.js +12 -0
- package/dist/basic-sdk/extension/plugins/chart/menu/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/model.js +34 -0
- package/dist/basic-sdk/extension/plugins/chart/plugin.js +20 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.css +26 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.js +229 -0
- package/dist/basic-sdk/extension/plugins/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/link/hover/index.js +3 -1
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +4 -3
- package/dist/basic-sdk/extension/render/custom-element.js +10 -4
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +2 -1
- package/dist/components/doc-operations/more-operations.js +21 -12
- package/dist/constants/index.js +3 -0
- package/dist/context.js +44 -0
- package/package.json +9 -1
- package/public/locales/en/sdoc-editor.json +34 -1
- package/public/locales/zh_CN/sdoc-editor.json +35 -1
- package/public/media/{sdoc-editor-font.css → iconfont.css} +10 -10
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -2
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
.filters-list {
|
|
2
|
+
min-height: 120px;
|
|
3
|
+
max-height: 100%;
|
|
4
|
+
padding: 15px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.filters-list.empty-filters-container {
|
|
8
|
+
min-height: 80px;
|
|
9
|
+
padding: 16px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.filters-list.empty-filters-container .empty-filters-list {
|
|
13
|
+
padding-left: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.filters-list .empty-filters-list {
|
|
17
|
+
padding: .25rem;
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
opacity: .5;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.filters-list .filter-item {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
padding: .25rem 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.filters-list .filter-item .condition {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.filters-list .filter-item .condition>div {
|
|
34
|
+
height: 38px;
|
|
35
|
+
line-height: 38px;
|
|
36
|
+
margin-left: .5rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.filters-list .filter-item .condition>div:first-child {
|
|
40
|
+
margin-left: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.filters-list .filter-item .filter-term {
|
|
44
|
+
max-width: 300px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.filters-list .filter-item .filter-term .option-group-content .option.option-active .dtable-font {
|
|
48
|
+
color: #798d99;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.filters-list .filter-conjunction {
|
|
52
|
+
width: 72px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.filters-list .filter-conjunction-readonly {
|
|
56
|
+
width: 52px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.filters-list .filter-container {
|
|
60
|
+
width : calc(100% - 72px);
|
|
61
|
+
display: flex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.filters-list .dtable-select .selected-option-show {
|
|
65
|
+
width: calc(100% - 20px);
|
|
66
|
+
height: 20px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.filters-list .dtable-select .selected-option {
|
|
70
|
+
width: auto;
|
|
71
|
+
overflow-x: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.filters-list .dtable-select .dtable-icon-drop-down {
|
|
75
|
+
margin-left: .5rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.filters-list .selected-conjunction-show {
|
|
79
|
+
padding: 0 10px;
|
|
80
|
+
color: #999;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.filters-list .filter-column {
|
|
84
|
+
max-width: 150px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.filter-term .selector-multiple-select .option,
|
|
88
|
+
.filter-term .selector-single-select .option {
|
|
89
|
+
height: 30px;
|
|
90
|
+
padding: 0 10px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.filter-term .selector-multiple-select .select-option-name,
|
|
94
|
+
.filter-term .selector-single-select .select-option-name {
|
|
95
|
+
margin-top: 5px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.filter-term .selector-single-select .option:hover {
|
|
99
|
+
color: #212529;
|
|
100
|
+
background-color: #f7f7f7;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.filter-term .selector-single-select .option:hover .select-option-name,
|
|
104
|
+
.filter-term .selector-multiple-select .option:hover .select-option-name,
|
|
105
|
+
.filter-term .selector-collaborator .option:hover .select-option-name {
|
|
106
|
+
color: unset;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.filter-term .selector-collaborator .dtable-icon-drop-down {
|
|
110
|
+
padding-left: 5px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.filters-list .selector-collaborator .selected-option-show {
|
|
114
|
+
text-overflow: unset;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.filters-list .selector-multiple-select .option:hover,
|
|
118
|
+
.filters-list .selector-multiple-select .option.option-active,
|
|
119
|
+
.filters-list .selector-collaborator .option:hover,
|
|
120
|
+
.filters-list .selector-collaborator .option.option-active {
|
|
121
|
+
color: #212529;
|
|
122
|
+
background-color: #f7f7f7;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.filters-list .selector-multiple-select .option.option-active .select-option-name,
|
|
126
|
+
.filters-list .selector-collaborator .option.option-active .select-option-name {
|
|
127
|
+
color: #212529;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.filters-list .selected-option .multiple-select-option,
|
|
131
|
+
.filters-list .selected-option .single-select-option {
|
|
132
|
+
margin: 0;
|
|
133
|
+
display: inline-block;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.filters-list .filter-term input {
|
|
137
|
+
display: flex;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 38px;
|
|
140
|
+
background-color: #ffffff;
|
|
141
|
+
padding-left: 8px;
|
|
142
|
+
padding-right: 8px;
|
|
143
|
+
outline: none;
|
|
144
|
+
border-radius: 3px;
|
|
145
|
+
font-size: 0.875rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.filters-list .filter-term input:hover {
|
|
149
|
+
border-color: rgb(179, 179, 179);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.filters-list .filter-term input.disabled:hover {
|
|
153
|
+
border-color: rgba(0, 40, 100, 0.12);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.filters-list .filter-term input:hover:focus {
|
|
157
|
+
border-color: #1991eb;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.filters-list .filter-term input:focus {
|
|
161
|
+
color: #495057;
|
|
162
|
+
background-color: #fff;
|
|
163
|
+
border-color: #1991eb;
|
|
164
|
+
outline: 0;
|
|
165
|
+
box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.filters-list .filter-term .date-picker-container input:focus {
|
|
169
|
+
color: #495057;
|
|
170
|
+
background-color: #fff;
|
|
171
|
+
border: 1px solid #fff;
|
|
172
|
+
outline: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.filters-list .filter-term .date-picker-container table tr {
|
|
176
|
+
height: 30px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.filters-list .filter-term input[type='checkbox'] {
|
|
180
|
+
width: inherit;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.filters-list .filter-term input[type='checkbox']:focus {
|
|
184
|
+
border: 0;
|
|
185
|
+
box-shadow: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.filter-term .filter-rate-list {
|
|
189
|
+
display: flex;
|
|
190
|
+
padding: 0 5px;
|
|
191
|
+
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.filters-list .delete-filter {
|
|
195
|
+
width: 12px;
|
|
196
|
+
height: 20px;
|
|
197
|
+
margin-right: 14px;
|
|
198
|
+
text-align: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.filters-list .delete-filter:hover {
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.filters-list .delete-filter .dtable-icon-fork-number {
|
|
206
|
+
display: inline-block;
|
|
207
|
+
font-size: 12px;
|
|
208
|
+
color: #949494;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.filters-list .multiple-option-name {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.filters-list .multiple-check-icon,
|
|
217
|
+
.filters-list .collaborator-check-icon {
|
|
218
|
+
display: inline-flex;
|
|
219
|
+
width: 20px;
|
|
220
|
+
height: 20px;
|
|
221
|
+
align-items: center;
|
|
222
|
+
text-align: center;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.filters-list .multiple-check-icon .dtable-icon-check-mark,
|
|
226
|
+
.filters-list .collaborator-check-icon .dtable-icon-check-mark {
|
|
227
|
+
font-size: 12px;
|
|
228
|
+
color: #798d99;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.user-select-item, .collaborator {
|
|
232
|
+
display: inline-flex;
|
|
233
|
+
align-items: center;
|
|
234
|
+
height: 20px;
|
|
235
|
+
margin-right: 10px;
|
|
236
|
+
padding: 0 8px 0 2px;
|
|
237
|
+
font-size: 13px;
|
|
238
|
+
border-radius: 10px;
|
|
239
|
+
background: #eaeaea;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.filters-list .collaborator-show {
|
|
243
|
+
flex: 1;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.filters-list .collaborator-avatar-container {
|
|
247
|
+
width: 16px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.filters-list .collaborator-avatar {
|
|
251
|
+
width: 16px;
|
|
252
|
+
height: 16px;
|
|
253
|
+
transform: translateY(-1px);
|
|
254
|
+
border-radius: 50%;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.filters-list .option .collaborator-avatar {
|
|
258
|
+
transform: translateY(-2px);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.filters-list .collaborator-name {
|
|
262
|
+
margin-left: 5px;
|
|
263
|
+
max-width: 200px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.filters-list .option-collaborator {
|
|
267
|
+
display: flex;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.filters-list .collaborator-container {
|
|
271
|
+
flex: 1;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.filters-list .popover-add-tool {
|
|
275
|
+
border-top: none;
|
|
276
|
+
color: #555555;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.filters-list .popover-add-tool .popover-add-icon {
|
|
280
|
+
margin-right: 14px;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.filters-list .option-group {
|
|
284
|
+
max-height: 360px;
|
|
285
|
+
overflow: auto;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.filters-list .filter-item .dtable-icon-fork-number:hover {
|
|
289
|
+
color: #5a5a5a;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.filters-list .filter-container-readonly .dtable-select .selected-option-show,
|
|
293
|
+
.filters-list .filter-conjunction-readonly .dtable-select .selected-option-show {
|
|
294
|
+
width: 100%;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.filters-list .filter-checkbox-predicate .dtable-select .selected-option-show {
|
|
298
|
+
width: 100%;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.dropdown-item .collaborator,
|
|
302
|
+
.filters-list .option-group .option-group-content .collaborator {
|
|
303
|
+
background-color: unset;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.filters-list .dtable-select .selected-option-show .remove-container {
|
|
307
|
+
display: none;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.filter-header-icon {
|
|
311
|
+
display: inline-block;
|
|
312
|
+
padding: 0 0.3125rem;
|
|
313
|
+
margin-left: -0.3125rem;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.filter-header-icon .dtable-font {
|
|
317
|
+
font-size: 14px;
|
|
318
|
+
color: #aaa;
|
|
319
|
+
cursor: default;
|
|
320
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { CellType, FILTER_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, ValidateFilter } from 'dtable-utils';
|
|
5
|
+
import FilterItemUtils from './filter-item-utils';
|
|
6
|
+
import FilterItem from './filter-item';
|
|
7
|
+
import { getColumnByKey } from '../utils';
|
|
8
|
+
import './filters-list.css';
|
|
9
|
+
class FiltersList extends Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.updateFilter = (filterIndex, updatedFilter) => {
|
|
13
|
+
if (!updatedFilter) return;
|
|
14
|
+
this.props.updateFilter(filterIndex, updatedFilter);
|
|
15
|
+
};
|
|
16
|
+
this.deleteFilter = index => {
|
|
17
|
+
const {
|
|
18
|
+
scheduleUpdate
|
|
19
|
+
} = this.props;
|
|
20
|
+
this.props.deleteFilter(index, scheduleUpdate);
|
|
21
|
+
};
|
|
22
|
+
this.updateConjunction = filterConjunction => {
|
|
23
|
+
this.props.updateFilterConjunction(filterConjunction);
|
|
24
|
+
};
|
|
25
|
+
this.getConjunctionOptions = () => {
|
|
26
|
+
const {
|
|
27
|
+
t
|
|
28
|
+
} = this.props;
|
|
29
|
+
if (!this.conjunctionOptions) {
|
|
30
|
+
this.conjunctionOptions = FilterItemUtils.generatorConjunctionOptions(t);
|
|
31
|
+
}
|
|
32
|
+
return this.conjunctionOptions;
|
|
33
|
+
};
|
|
34
|
+
this.getFilterColumns = () => {
|
|
35
|
+
const {
|
|
36
|
+
columns
|
|
37
|
+
} = this.props;
|
|
38
|
+
return columns.filter(column => {
|
|
39
|
+
const {
|
|
40
|
+
data
|
|
41
|
+
} = column;
|
|
42
|
+
let {
|
|
43
|
+
type
|
|
44
|
+
} = column;
|
|
45
|
+
if (data && (type === CellType.LINK || FORMULA_COLUMN_TYPES_MAP[type] && data.result_type === FORMULA_RESULT_TYPE.ARRAY)) {
|
|
46
|
+
type = data.array_type;
|
|
47
|
+
}
|
|
48
|
+
return Object.prototype.hasOwnProperty.call(FILTER_COLUMN_OPTIONS, type);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
this.getColumnOptions = () => {
|
|
52
|
+
if (!this.columnOptions) {
|
|
53
|
+
const filterColumns = this.getFilterColumns();
|
|
54
|
+
this.columnOptions = filterColumns.map(column => {
|
|
55
|
+
return FilterItemUtils.generatorColumnOption(column);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return this.columnOptions;
|
|
59
|
+
};
|
|
60
|
+
this.renderFilterItem = (filter, index, errMsg, filterColumn) => {
|
|
61
|
+
const {
|
|
62
|
+
filterConjunction,
|
|
63
|
+
value
|
|
64
|
+
} = this.props;
|
|
65
|
+
const conjunctionOptions = this.getConjunctionOptions();
|
|
66
|
+
const columnOptions = this.getColumnOptions();
|
|
67
|
+
return /*#__PURE__*/React.createElement(FilterItem, {
|
|
68
|
+
key: index,
|
|
69
|
+
isLocked: this.props.isLocked,
|
|
70
|
+
index: index,
|
|
71
|
+
filter: filter,
|
|
72
|
+
errMsg: errMsg,
|
|
73
|
+
filterColumn: filterColumn,
|
|
74
|
+
filterConjunction: filterConjunction,
|
|
75
|
+
conjunctionOptions: conjunctionOptions,
|
|
76
|
+
filterColumnOptions: columnOptions,
|
|
77
|
+
value: value,
|
|
78
|
+
deleteFilter: this.deleteFilter,
|
|
79
|
+
updateFilter: this.updateFilter,
|
|
80
|
+
updateConjunction: this.updateConjunction,
|
|
81
|
+
collaborators: this.props.collaborators,
|
|
82
|
+
isPre: this.props.isPre
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
this.conjunctionOptions = null;
|
|
86
|
+
this.columnOptions = null;
|
|
87
|
+
}
|
|
88
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
89
|
+
if (nextProps.columns !== this.props.columns) {
|
|
90
|
+
this.columnOptions = null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
let {
|
|
95
|
+
filters,
|
|
96
|
+
className,
|
|
97
|
+
emptyPlaceholder,
|
|
98
|
+
columns
|
|
99
|
+
} = this.props;
|
|
100
|
+
const isEmpty = filters.length === 0;
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: classnames('filters-list', {
|
|
103
|
+
'empty-filters-container': isEmpty
|
|
104
|
+
}, {
|
|
105
|
+
[className]: className
|
|
106
|
+
})
|
|
107
|
+
}, isEmpty && /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "empty-filters-list"
|
|
109
|
+
}, emptyPlaceholder), !isEmpty && filters.map((filter, index) => {
|
|
110
|
+
const {
|
|
111
|
+
column_key
|
|
112
|
+
} = filter;
|
|
113
|
+
const {
|
|
114
|
+
error_message
|
|
115
|
+
} = ValidateFilter.validateColumn(column_key, columns);
|
|
116
|
+
const filterColumn = getColumnByKey(column_key, columns) || {};
|
|
117
|
+
return this.renderFilterItem(filter, index, error_message, filterColumn);
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export default withTranslation('sdoc-editor')(FiltersList);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { UncontrolledTooltip } from 'reactstrap';
|
|
4
|
+
class RateItem extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.onMouseEnterRateItem = () => {
|
|
8
|
+
const {
|
|
9
|
+
rateItemIndex
|
|
10
|
+
} = this.props;
|
|
11
|
+
this.props.onMouseEnterRateItem(rateItemIndex);
|
|
12
|
+
};
|
|
13
|
+
this.onMouseLeaveRateItem = () => {
|
|
14
|
+
this.props.onMouseLeaveRateItem();
|
|
15
|
+
};
|
|
16
|
+
this.onChangeRateNumber = () => {
|
|
17
|
+
const {
|
|
18
|
+
onChangeRateNumber,
|
|
19
|
+
rateItemIndex,
|
|
20
|
+
editable
|
|
21
|
+
} = this.props;
|
|
22
|
+
if (onChangeRateNumber && editable) {
|
|
23
|
+
onChangeRateNumber(rateItemIndex);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.tooltipRef = React.createRef();
|
|
27
|
+
this.state = {
|
|
28
|
+
isOpen: false
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
const {
|
|
33
|
+
enterRateItemIndex,
|
|
34
|
+
rateItemIndex,
|
|
35
|
+
value,
|
|
36
|
+
column,
|
|
37
|
+
isShowRateItem,
|
|
38
|
+
editable
|
|
39
|
+
} = this.props;
|
|
40
|
+
const {
|
|
41
|
+
rate_style_color,
|
|
42
|
+
rate_style_type
|
|
43
|
+
} = column.data || {};
|
|
44
|
+
const rateShowType = rate_style_type ? rate_style_type : 'dtable-icon-rate';
|
|
45
|
+
if (!isShowRateItem && rateItemIndex > value) return null;
|
|
46
|
+
let itemStyle = {
|
|
47
|
+
cursor: editable ? 'pointer' : 'default',
|
|
48
|
+
color: value >= rateItemIndex ? rate_style_color : '#e5e5e5'
|
|
49
|
+
};
|
|
50
|
+
let style = itemStyle;
|
|
51
|
+
if (enterRateItemIndex >= rateItemIndex) {
|
|
52
|
+
style = _objectSpread(_objectSpread({}, itemStyle), {}, {
|
|
53
|
+
color: rate_style_color,
|
|
54
|
+
opacity: 0.4
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
onMouseEnter: this.onMouseEnterRateItem,
|
|
59
|
+
onMouseLeave: this.onMouseLeaveRateItem,
|
|
60
|
+
style: style,
|
|
61
|
+
onClick: this.onChangeRateNumber,
|
|
62
|
+
className: "rate-item ".concat(value >= rateItemIndex ? 'rate-item-active' : '')
|
|
63
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
64
|
+
className: "dtable-font ".concat(rateShowType),
|
|
65
|
+
ref: this.tooltipRef
|
|
66
|
+
}), editable && /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
67
|
+
placement: "bottom",
|
|
68
|
+
target: this.tooltipRef
|
|
69
|
+
}, rateItemIndex));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export default RateItem;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import { Button, UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
import isHotkey from 'is-hotkey';
|
|
5
|
+
import { FILTER_COLUMN_OPTIONS, getValidFilters } from 'dtable-utils';
|
|
6
|
+
import CommonAddTool from './common-add-tool';
|
|
7
|
+
import { getEventClassName } from './utils';
|
|
8
|
+
import { getFilterByColumn } from './utils';
|
|
9
|
+
import FiltersList from './filter-popover-widgets/filters-list';
|
|
10
|
+
import EventBus from '../../../../../utils/event-bus';
|
|
11
|
+
import { INTERNAL_EVENT } from '../../../../../../basic-sdk/constants';
|
|
12
|
+
import './filters-popover.css';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* filter = {
|
|
16
|
+
* column_key: '',
|
|
17
|
+
* filter_predicate: '',
|
|
18
|
+
* filter_term: '',
|
|
19
|
+
* filter_term_modifier: '',
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
class FilterPopover extends Component {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.onHotKey = e => {
|
|
26
|
+
if (isHotkey('esc', e) && !this.isSelectOpen) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
this.props.hidePopover();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
this.setSelectStatus = status => {
|
|
32
|
+
this.isSelectOpen = status;
|
|
33
|
+
};
|
|
34
|
+
this.hideDTablePopover = e => {
|
|
35
|
+
if (this.dtablePopoverRef && !getEventClassName(e).includes('popover') && !this.dtablePopoverRef.contains(e.target)) {
|
|
36
|
+
this.props.hidePopover(e);
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.isNeedSubmit = () => {
|
|
43
|
+
return this.props.isNeedSubmit;
|
|
44
|
+
};
|
|
45
|
+
this.update = filters => {
|
|
46
|
+
if (this.isNeedSubmit()) {
|
|
47
|
+
const isSubmitDisabled = false;
|
|
48
|
+
this.setState({
|
|
49
|
+
filters,
|
|
50
|
+
isSubmitDisabled
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.setState({
|
|
55
|
+
filters
|
|
56
|
+
}, () => {
|
|
57
|
+
const update = {
|
|
58
|
+
filters,
|
|
59
|
+
filter_conjunction: this.state.filterConjunction
|
|
60
|
+
};
|
|
61
|
+
this.props.update(update);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
this.deleteFilter = (filterIndex, scheduleUpdate) => {
|
|
65
|
+
const filters = this.state.filters.slice(0);
|
|
66
|
+
filters.splice(filterIndex, 1);
|
|
67
|
+
if (filters.length === 0) {
|
|
68
|
+
scheduleUpdate();
|
|
69
|
+
}
|
|
70
|
+
this.update(filters);
|
|
71
|
+
};
|
|
72
|
+
this.updateFilter = (filterIndex, updated) => {
|
|
73
|
+
const filters = this.state.filters.slice(0);
|
|
74
|
+
filters[filterIndex] = updated;
|
|
75
|
+
this.update(filters);
|
|
76
|
+
};
|
|
77
|
+
this.updateFilterConjunction = conjunction => {
|
|
78
|
+
if (this.isNeedSubmit()) {
|
|
79
|
+
const isSubmitDisabled = false;
|
|
80
|
+
this.setState({
|
|
81
|
+
filterConjunction: conjunction,
|
|
82
|
+
isSubmitDisabled
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.setState({
|
|
87
|
+
filterConjunction: conjunction
|
|
88
|
+
}, () => {
|
|
89
|
+
const update = {
|
|
90
|
+
filters: this.state.filters,
|
|
91
|
+
filter_conjunction: conjunction
|
|
92
|
+
};
|
|
93
|
+
this.props.update(update);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
this.addFilter = scheduleUpdate => {
|
|
97
|
+
let {
|
|
98
|
+
columns
|
|
99
|
+
} = this.props;
|
|
100
|
+
let defaultColumn = columns[0];
|
|
101
|
+
if (!FILTER_COLUMN_OPTIONS[defaultColumn.type]) {
|
|
102
|
+
defaultColumn = columns.find(c => FILTER_COLUMN_OPTIONS[c.type]);
|
|
103
|
+
}
|
|
104
|
+
if (!defaultColumn) return;
|
|
105
|
+
let filter = getFilterByColumn(defaultColumn);
|
|
106
|
+
const filters = this.state.filters.slice(0);
|
|
107
|
+
if (filters.length === 0) {
|
|
108
|
+
scheduleUpdate();
|
|
109
|
+
}
|
|
110
|
+
filters.push(filter);
|
|
111
|
+
this.update(filters);
|
|
112
|
+
};
|
|
113
|
+
this.onClosePopover = () => {
|
|
114
|
+
this.props.hidePopover();
|
|
115
|
+
};
|
|
116
|
+
this.onSubmitFilters = () => {
|
|
117
|
+
const {
|
|
118
|
+
filters,
|
|
119
|
+
filterConjunction
|
|
120
|
+
} = this.state;
|
|
121
|
+
const update = {
|
|
122
|
+
filters,
|
|
123
|
+
filter_conjunction: filterConjunction
|
|
124
|
+
};
|
|
125
|
+
this.props.update(update);
|
|
126
|
+
this.props.hidePopover();
|
|
127
|
+
};
|
|
128
|
+
this.onPopoverInsideClick = e => {
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
};
|
|
131
|
+
this.state = {
|
|
132
|
+
filters: getValidFilters(props.filters, props.columns),
|
|
133
|
+
filterConjunction: props.filterConjunction || 'And'
|
|
134
|
+
};
|
|
135
|
+
this.isSelectOpen = false;
|
|
136
|
+
}
|
|
137
|
+
componentDidMount() {
|
|
138
|
+
document.addEventListener('mousedown', this.hideDTablePopover, true);
|
|
139
|
+
document.addEventListener('keydown', this.onHotKey);
|
|
140
|
+
const eventBus = EventBus.getInstance();
|
|
141
|
+
this.unsubscribeOpenSelect = eventBus.subscribe(INTERNAL_EVENT.OPEN_SELECT, this.setSelectStatus);
|
|
142
|
+
}
|
|
143
|
+
componentWillUnmount() {
|
|
144
|
+
document.removeEventListener('mousedown', this.hideDTablePopover, true);
|
|
145
|
+
document.removeEventListener('keydown', this.onHotKey);
|
|
146
|
+
this.unsubscribeOpenSelect();
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
const {
|
|
150
|
+
target,
|
|
151
|
+
columns,
|
|
152
|
+
t
|
|
153
|
+
} = this.props;
|
|
154
|
+
const {
|
|
155
|
+
filters,
|
|
156
|
+
filterConjunction
|
|
157
|
+
} = this.state;
|
|
158
|
+
const canAddFilter = columns.length > 0;
|
|
159
|
+
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
160
|
+
placement: "auto-start",
|
|
161
|
+
isOpen: true,
|
|
162
|
+
target: target,
|
|
163
|
+
fade: false,
|
|
164
|
+
hideArrow: true,
|
|
165
|
+
className: "filter-popover",
|
|
166
|
+
boundariesElement: document.body
|
|
167
|
+
}, _ref => {
|
|
168
|
+
let {
|
|
169
|
+
scheduleUpdate
|
|
170
|
+
} = _ref;
|
|
171
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
ref: ref => this.dtablePopoverRef = ref,
|
|
173
|
+
onClick: this.onPopoverInsideClick,
|
|
174
|
+
className: this.props.filtersClassName
|
|
175
|
+
}, /*#__PURE__*/React.createElement(FiltersList, {
|
|
176
|
+
filterConjunction: filterConjunction,
|
|
177
|
+
filters: filters,
|
|
178
|
+
columns: columns,
|
|
179
|
+
emptyPlaceholder: t('No_filters'),
|
|
180
|
+
updateFilter: this.updateFilter,
|
|
181
|
+
deleteFilter: this.deleteFilter,
|
|
182
|
+
updateFilterConjunction: this.updateFilterConjunction,
|
|
183
|
+
collaborators: this.props.collaborators,
|
|
184
|
+
readOnly: false,
|
|
185
|
+
scheduleUpdate: scheduleUpdate,
|
|
186
|
+
isPre: this.props.isPre
|
|
187
|
+
}), /*#__PURE__*/React.createElement(CommonAddTool, {
|
|
188
|
+
className: "popover-add-tool ".concat(canAddFilter ? '' : 'disabled'),
|
|
189
|
+
callBack: canAddFilter ? () => this.addFilter(scheduleUpdate) : () => {},
|
|
190
|
+
footerName: t('Add_filter'),
|
|
191
|
+
addIconClassName: "popover-add-icon"
|
|
192
|
+
}), this.isNeedSubmit() && /*#__PURE__*/React.createElement("div", {
|
|
193
|
+
className: "filter-popover-footer"
|
|
194
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
195
|
+
className: "mr-2",
|
|
196
|
+
onClick: this.onClosePopover
|
|
197
|
+
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
198
|
+
color: "primary",
|
|
199
|
+
disabled: this.state.isSubmitDisabled,
|
|
200
|
+
onClick: this.onSubmitFilters
|
|
201
|
+
}, t('Submit'))));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
FilterPopover.defaultProps = {
|
|
206
|
+
filtersClassName: ''
|
|
207
|
+
};
|
|
208
|
+
export default withTranslation('sdoc-editor')(FilterPopover);
|