dtable-ui-component 6.0.37 → 6.0.38-alpha.1

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.
@@ -19,6 +19,87 @@
19
19
  color: #666666;
20
20
  }
21
21
 
22
+ /* ---- filter group start ---- */
23
+ .filters-list .filter-group {
24
+ display: flex;
25
+ align-items: center;
26
+ padding: 0.25rem 0;
27
+ }
28
+
29
+ .filters-list .filter-group .filter-group-wrapper {
30
+ flex: 1;
31
+ display: flex;
32
+ }
33
+
34
+ .filters-list .filter-group .delete-filter,
35
+ .filters-list .filter-group .filter-conjunction {
36
+ align-self: flex-start;
37
+ }
38
+
39
+ .filters-list .filter-group .delete-filter,
40
+ .filters-list .filter-group .filter-conjunction.conjunction-text {
41
+ margin-top: 8px;
42
+ }
43
+
44
+ .filters-list .filter-group .filter-group-container {
45
+ width: calc(100% - 72px);
46
+ min-height: 38px;
47
+ margin-left: .5rem;
48
+ padding: 4px 10px;
49
+ border: 1px solid rgba(0, 40, 100, .12);
50
+ border-radius: 3px;
51
+ }
52
+
53
+ .filters-list .filter-group.draggable .filter-group-container {
54
+ /* 94: conjunction width(72) + drag icon width(16) + drag icon margin left(8) */
55
+ width: calc(100% - 96px);
56
+ }
57
+
58
+ .filters-list .filter-group.readonly .filter-group-container {
59
+ width: calc(100% - 52px);
60
+ }
61
+
62
+ .filters-list .filter-group.level-1 .filter-group-container {
63
+ background-color: #f7f7f7;
64
+ }
65
+
66
+ .filters-list .filter-group-container .group-filter-add-tool {
67
+ border-top: unset;
68
+ background-color: #f7f7f7;
69
+ margin-top: 2px;
70
+ padding: 0;
71
+ height: 30px;
72
+ line-height: 30px;
73
+ font-weight: 400;
74
+ }
75
+
76
+ .filters-list .filter-group-container .group-filter-add-tool .dtable-icon-add-table,
77
+ .filters-list .filter-group-container .group-filter-add-tool .add-new-option {
78
+ color: #999;
79
+ }
80
+
81
+ .filters-list .filter-group-container .group-filter-add-tool:hover .dtable-icon-add-table,
82
+ .filters-list .filter-group-container .group-filter-add-tool:hover .add-new-option {
83
+ color: #555;
84
+ }
85
+
86
+ .filters-list .dtable-filter-group-drag {
87
+ display: flex;
88
+ margin-left: .5rem;
89
+ }
90
+
91
+ .filters-list .drag-filter-handle,
92
+ .filters-list .drag-filter-group-handle {
93
+ color: #949494;
94
+ cursor: grab;
95
+ }
96
+
97
+ .filters-list .dragging-filter-wrapper .group-filter-add-tool,
98
+ .filters-list .dragging-filter-wrapper .delete-filter {
99
+ display: none;
100
+ }
101
+ /* ---- filter group end ---- */
102
+
22
103
  .filters-list .filter-item {
23
104
  display: flex;
24
105
  align-items: center;
@@ -40,7 +121,7 @@
40
121
  margin-left: 0;
41
122
  }
42
123
 
43
- .filters-list .filter-item .filter-term .selector-collaborator {
124
+ .filters-list .filter-item .filter-term {
44
125
  max-width: 300px;
45
126
  min-width: 70px;
46
127
  }
@@ -66,6 +147,10 @@
66
147
  width: calc(100% - 20px);
67
148
  }
68
149
 
150
+ .filters-list .dtable-select.collaborator-select .selected-option-show {
151
+ height: auto;
152
+ }
153
+
69
154
  .filters-list .dtable-select .selected-option {
70
155
  width: auto;
71
156
  overflow-x: auto;
@@ -77,7 +162,7 @@
77
162
 
78
163
  .filters-list .selected-conjunction-show {
79
164
  padding: 0 10px;
80
- color: #666;
165
+ color: #666666;
81
166
  }
82
167
 
83
168
  .filters-list .filter-column {
@@ -116,14 +201,14 @@
116
201
 
117
202
  .filters-list .selector-multiple-select .option:hover,
118
203
  .filters-list .selector-multiple-select .option.option-active,
119
- .filters-list .selector-collaborator .option:hover,
120
- .filters-list .selector-collaborator .option.option-active {
204
+ .option-group-selector-collaborator .option:hover,
205
+ .option-group-selector-collaborator .option.option-active {
121
206
  color: #212529;
122
207
  background-color: #f7f7f7;
123
208
  }
124
209
 
125
210
  .filters-list .selector-multiple-select .option.option-active .select-option-name,
126
- .filters-list .selector-collaborator .option.option-active .select-option-name {
211
+ .option-group-selector-collaborator .option.option-active .select-option-name {
127
212
  color: #212529;
128
213
  }
129
214
 
@@ -171,6 +256,17 @@
171
256
  outline: 0;
172
257
  }
173
258
 
259
+ .filters-list .filter-term .rc-calendar-input {
260
+ border: 1px solid transparent;
261
+ color: #666;
262
+ cursor: text;
263
+ height: 22px;
264
+ font-size: 12px;
265
+ line-height: 1.5;
266
+ outline: 0;
267
+ width: 100%;
268
+ }
269
+
174
270
  .filters-list .filter-term .date-picker-container table tr {
175
271
  height: 30px;
176
272
  }
@@ -214,7 +310,7 @@
214
310
  }
215
311
 
216
312
  .filters-list .multiple-check-icon,
217
- .filters-list .collaborator-check-icon {
313
+ .option-group-selector-collaborator .collaborator-check-icon {
218
314
  display: inline-flex;
219
315
  width: 20px;
220
316
  height: 20px;
@@ -223,7 +319,7 @@
223
319
  }
224
320
 
225
321
  .filters-list .multiple-check-icon .dtable-icon-check-mark,
226
- .filters-list .collaborator-check-icon .dtable-icon-check-mark {
322
+ .option-group-selector-collaborator .collaborator-check-icon .dtable-icon-check-mark {
227
323
  font-size: 12px;
228
324
  color: #798d99;
229
325
  }
@@ -240,35 +336,35 @@
240
336
  background: #eaeaea;
241
337
  }
242
338
 
243
- .filters-list .collaborator-show {
339
+ .option-group-selector-collaborator .collaborator-show {
244
340
  flex: 1;
245
341
  }
246
342
 
247
- .filters-list .collaborator-avatar-container {
343
+ .option-group-selector-collaborator .collaborator-avatar-container {
248
344
  width: 16px;
249
345
  }
250
346
 
251
- .filters-list .collaborator-avatar {
347
+ .option-group-selector-collaborator .collaborator-avatar {
252
348
  width: 16px;
253
349
  height: 16px;
254
350
  transform: translateY(-1px);
255
351
  border-radius: 50%;
256
352
  }
257
353
 
258
- .filters-list .option .collaborator-avatar {
354
+ .option-group-selector-collaborator .option .collaborator-avatar {
259
355
  transform: translateY(-2px);
260
356
  }
261
357
 
262
- .filters-list .collaborator-name {
358
+ .option-group-selector-collaborator .collaborator-name {
263
359
  margin-left: 5px;
264
360
  max-width: 200px;
265
361
  }
266
362
 
267
- .filters-list .option-collaborator {
363
+ .option-group-selector-collaborator .option-collaborator {
268
364
  display: flex;
269
365
  }
270
366
 
271
- .filters-list .collaborator-container {
367
+ .option-group-selector-collaborator .collaborator-container {
272
368
  flex: 1;
273
369
  }
274
370
 
@@ -287,7 +383,7 @@
287
383
  }
288
384
 
289
385
  .filters-list .filter-item .dtable-icon-fork-number:hover {
290
- color: #555;
386
+ color: #555555;
291
387
  }
292
388
 
293
389
  .filters-list .filter-container-readonly .dtable-select .selected-option-show,
@@ -299,7 +395,8 @@
299
395
  width: 100%;
300
396
  }
301
397
 
302
- .filters-list .option-group .option-group-content .collaborator {
398
+ .dropdown-item .collaborator,
399
+ .option-group-selector-collaborator .option-group-content .collaborator {
303
400
  background-color: unset;
304
401
  }
305
402
 
@@ -9,62 +9,227 @@ exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _dtableUtils = require("dtable-utils");
12
+ var _filterItemUtils = _interopRequireDefault(require("../../utils/filter-item-utils"));
12
13
  var _filterItem = _interopRequireDefault(require("../filter-item"));
13
14
  var _utils = require("../../utils");
15
+ var _constants = require("../../constants");
16
+ var _filterGroup = _interopRequireDefault(require("../filter-group"));
14
17
  require("./index.css");
15
18
  class FiltersList extends _react.Component {
16
19
  constructor(props) {
17
20
  super(props);
18
- this.updateFilter = (filterIndex, updatedFilter) => {
19
- if (!updatedFilter) return;
20
- this.props.updateFilter(filterIndex, updatedFilter);
21
+ this.modifyFilterConjunction = new_filter_conjunction => {
22
+ const {
23
+ filterConjunction: filter_conjunction,
24
+ filters
25
+ } = this.props;
26
+ const {
27
+ filter_conjunction: next_filter_conjunction,
28
+ filters: next_filters
29
+ } = (0, _utils.applyFilterOperation)({
30
+ type: _constants.FILTER_OPERATION_TYPE.MODIFY_CONJUNCTION,
31
+ filter_conjunction,
32
+ filters,
33
+ payload: {
34
+ new_filter_conjunction
35
+ }
36
+ });
37
+ this.props.updateFilters({
38
+ filter_conjunction: next_filter_conjunction,
39
+ filters: next_filters
40
+ });
21
41
  };
22
- this.deleteFilter = index => {
42
+ this.updateFilter = (filter_index, new_filter) => {
43
+ if (!new_filter) return;
23
44
  const {
24
- scheduleUpdate
45
+ filterConjunction: filter_conjunction,
46
+ filters
25
47
  } = this.props;
26
- this.props.deleteFilter(index, scheduleUpdate);
48
+ const {
49
+ filter_conjunction: next_filter_conjunction,
50
+ filters: next_filters
51
+ } = (0, _utils.applyFilterOperation)({
52
+ type: _constants.FILTER_OPERATION_TYPE.UPDATE_FILTER,
53
+ filter_conjunction,
54
+ filters,
55
+ payload: {
56
+ filter_index,
57
+ new_filter
58
+ }
59
+ });
60
+ this.props.updateFilters({
61
+ filter_conjunction: next_filter_conjunction,
62
+ filters: next_filters
63
+ });
27
64
  };
28
- this.updateConjunction = filterConjunction => {
29
- this.props.updateFilterConjunction(filterConjunction);
65
+ this.deleteFilter = filter_index => {
66
+ const {
67
+ filterConjunction: filter_conjunction,
68
+ filters
69
+ } = this.props;
70
+ const {
71
+ filter_conjunction: next_filter_conjunction,
72
+ filters: next_filters
73
+ } = (0, _utils.applyFilterOperation)({
74
+ type: _constants.FILTER_OPERATION_TYPE.DELETE_FILTER,
75
+ filter_conjunction,
76
+ filters,
77
+ payload: {
78
+ filter_index
79
+ }
80
+ });
81
+ this.props.updateFilters({
82
+ filter_conjunction: next_filter_conjunction,
83
+ filters: next_filters
84
+ });
30
85
  };
31
- this.getConjunctionOptions = () => {
32
- if (!this.conjunctionOptions) {
33
- this.conjunctionOptions = _utils.FilterItemUtils.generatorConjunctionOptions();
86
+ this.moveFilter = _ref => {
87
+ let {
88
+ source_filter_index,
89
+ target_filter_index,
90
+ source_group_index,
91
+ target_group_index
92
+ } = _ref;
93
+ if (source_filter_index === target_filter_index && source_group_index === target_group_index) {
94
+ return;
34
95
  }
35
- return this.conjunctionOptions;
96
+ const {
97
+ filterConjunction: filter_conjunction,
98
+ filters
99
+ } = this.props;
100
+ const {
101
+ filter_conjunction: next_filter_conjunction,
102
+ filters: next_filters
103
+ } = (0, _utils.applyFilterOperation)({
104
+ type: _constants.FILTER_OPERATION_TYPE.MOVE_FILTER,
105
+ filter_conjunction,
106
+ filters,
107
+ payload: {
108
+ source_filter_index,
109
+ target_filter_index,
110
+ source_group_index,
111
+ target_group_index
112
+ }
113
+ });
114
+ this.props.updateFilters({
115
+ filter_conjunction: next_filter_conjunction,
116
+ filters: next_filters
117
+ });
36
118
  };
37
- this.getFilterColumns = () => {
119
+ this.modifyConjunctionInGroup = (group_index, new_filter_conjunction) => {
38
120
  const {
39
- columns
121
+ filterConjunction: filter_conjunction,
122
+ filters
40
123
  } = this.props;
41
- return columns.filter(column => {
42
- const {
43
- data
44
- } = column;
45
- let {
46
- type
47
- } = column;
48
- if (data && (type === _dtableUtils.CellType.LINK || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY)) {
49
- type = data.array_type;
124
+ const {
125
+ filter_conjunction: next_filter_conjunction,
126
+ filters: next_filters
127
+ } = (0, _utils.applyFilterOperation)({
128
+ type: _constants.FILTER_OPERATION_TYPE.MODIFY_CONJUNCTION_IN_GROUP,
129
+ filter_conjunction,
130
+ filters,
131
+ payload: {
132
+ group_index,
133
+ new_filter_conjunction
50
134
  }
51
- return Object.prototype.hasOwnProperty.call(_dtableUtils.FILTER_COLUMN_OPTIONS, type);
135
+ });
136
+ this.props.updateFilters({
137
+ filter_conjunction: next_filter_conjunction,
138
+ filters: next_filters
52
139
  });
53
140
  };
141
+ this.addFilterIntoGroup = (group_index, filter) => {
142
+ if (!filter) return;
143
+ const {
144
+ filterConjunction: filter_conjunction,
145
+ filters
146
+ } = this.props;
147
+ const {
148
+ filter_conjunction: next_filter_conjunction,
149
+ filters: next_filters
150
+ } = (0, _utils.applyFilterOperation)({
151
+ type: _constants.FILTER_OPERATION_TYPE.ADD_FILTER_INTO_GROUP,
152
+ filter_conjunction,
153
+ filters,
154
+ payload: {
155
+ group_index,
156
+ filter
157
+ }
158
+ });
159
+ this.props.updateFilters({
160
+ filter_conjunction: next_filter_conjunction,
161
+ filters: next_filters
162
+ });
163
+ };
164
+ this.deleteFilterInGroup = (group_index, filter_index) => {
165
+ const {
166
+ filterConjunction: filter_conjunction,
167
+ filters
168
+ } = this.props;
169
+ const {
170
+ filter_conjunction: next_filter_conjunction,
171
+ filters: next_filters
172
+ } = (0, _utils.applyFilterOperation)({
173
+ type: _constants.FILTER_OPERATION_TYPE.DELETE_FILTER_IN_GROUP,
174
+ filter_conjunction,
175
+ filters,
176
+ payload: {
177
+ group_index,
178
+ filter_index
179
+ }
180
+ });
181
+ this.props.updateFilters({
182
+ filter_conjunction: next_filter_conjunction,
183
+ filters: next_filters
184
+ });
185
+ };
186
+ this.updateFilterInGroup = (group_index, filter_index, new_filter) => {
187
+ if (!new_filter) return;
188
+ const {
189
+ filterConjunction: filter_conjunction,
190
+ filters
191
+ } = this.props;
192
+ const {
193
+ filter_conjunction: next_filter_conjunction,
194
+ filters: next_filters
195
+ } = (0, _utils.applyFilterOperation)({
196
+ type: _constants.FILTER_OPERATION_TYPE.UPDATE_FILTER_IN_GROUP,
197
+ filter_conjunction,
198
+ filters,
199
+ payload: {
200
+ group_index,
201
+ filter_index,
202
+ new_filter
203
+ }
204
+ });
205
+ this.props.updateFilters({
206
+ filter_conjunction: next_filter_conjunction,
207
+ filters: next_filters
208
+ });
209
+ };
210
+ this.getConjunctionOptions = () => {
211
+ if (!this.conjunctionOptions) {
212
+ this.conjunctionOptions = _filterItemUtils.default.generatorConjunctionOptions();
213
+ }
214
+ return this.conjunctionOptions;
215
+ };
54
216
  this.getColumnOptions = () => {
217
+ const {
218
+ columns
219
+ } = this.props;
55
220
  if (!this.columnOptions) {
56
- const filterColumns = this.getFilterColumns();
221
+ const filterColumns = (0, _utils.getFilterColumns)(columns);
57
222
  this.columnOptions = filterColumns.map(column => {
58
- return _utils.FilterItemUtils.generatorColumnOption(column);
223
+ return _filterItemUtils.default.generatorColumnOption(column);
59
224
  });
60
225
  }
61
226
  return this.columnOptions;
62
227
  };
63
- this.renderFilterItem = (filter, index, errMsg, filterColumn) => {
228
+ this.renderFilter = (filter, index, filterColumn) => {
64
229
  const {
65
230
  filterConjunction,
66
- value,
67
- isLocked,
231
+ isInModal,
232
+ columns,
68
233
  collaborators,
69
234
  userDepartmentIdsMap,
70
235
  departments,
@@ -73,24 +238,49 @@ class FiltersList extends _react.Component {
73
238
  } = this.props;
74
239
  const conjunctionOptions = this.getConjunctionOptions();
75
240
  const columnOptions = this.getColumnOptions();
241
+ if ((0, _dtableUtils.checkIsFilterGroup)(filter)) {
242
+ return /*#__PURE__*/_react.default.createElement(_filterGroup.default, {
243
+ key: "filter-group-".concat(index),
244
+ isInModal: isInModal,
245
+ lang: lang,
246
+ columns: columns,
247
+ index: index,
248
+ filterConjunction: filterConjunction,
249
+ filter: filter,
250
+ conjunctionOptions: conjunctionOptions,
251
+ columnOptions: columnOptions,
252
+ collaborators: collaborators,
253
+ userDepartmentIdsMap: userDepartmentIdsMap,
254
+ departments: departments,
255
+ firstDayOfWeek: firstDayOfWeek,
256
+ modifyFilterConjunction: this.modifyFilterConjunction,
257
+ deleteFilterGroup: this.deleteFilter,
258
+ addFilterIntoGroup: this.addFilterIntoGroup,
259
+ modifyConjunctionInGroup: this.modifyConjunctionInGroup,
260
+ deleteFilterInGroup: this.deleteFilterInGroup,
261
+ updateFilterInGroup: this.updateFilterInGroup
262
+ });
263
+ }
264
+ const {
265
+ error_message
266
+ } = _dtableUtils.ValidateFilter.validate(filter, columns);
76
267
  return /*#__PURE__*/_react.default.createElement(_filterItem.default, {
77
268
  key: index,
78
- isLocked: isLocked,
269
+ isInModal: isInModal,
270
+ lang: lang,
79
271
  index: index,
80
272
  filter: filter,
81
- errMsg: errMsg,
273
+ errMsg: error_message,
82
274
  filterColumn: filterColumn,
83
275
  filterConjunction: filterConjunction,
84
276
  conjunctionOptions: conjunctionOptions,
85
277
  filterColumnOptions: columnOptions,
86
- value: value,
87
278
  collaborators: collaborators,
88
279
  userDepartmentIdsMap: userDepartmentIdsMap,
89
280
  departments: departments,
90
- lang: lang,
91
281
  deleteFilter: this.deleteFilter,
92
282
  updateFilter: this.updateFilter,
93
- updateConjunction: this.updateConjunction,
283
+ updateConjunction: this.modifyFilterConjunction,
94
284
  firstDayOfWeek: firstDayOfWeek
95
285
  });
96
286
  };
@@ -122,11 +312,8 @@ class FiltersList extends _react.Component {
122
312
  const {
123
313
  column_key
124
314
  } = filter;
125
- const {
126
- error_message
127
- } = _dtableUtils.ValidateFilter.validateColumn(column_key, columns);
128
- const filterColumn = (0, _utils.getColumnByKey)(columns, column_key) || {};
129
- return this.renderFilterItem(filter, index, error_message, filterColumn);
315
+ const filterColumn = (0, _utils.getColumnByKey)(column_key, columns) || {};
316
+ return this.renderFilter(filter, index, filterColumn);
130
317
  }));
131
318
  }
132
319
  }
@@ -24,6 +24,11 @@
24
24
  "Deleted_department": "Deleted department",
25
25
  "View_original_image": "View original image",
26
26
  "Add_filter": "Add filter",
27
+ "And": "And",
28
+ "Or": "Or",
29
+ "Add_filter_group": "Add filter group",
30
+ "Click_to_add_filter": "Click to add filter",
31
+ "Click_to_input_value": "Click to input value",
27
32
  "Submit": "Submit",
28
33
  "No_filters": "No filters",
29
34
  "Select_an_option": "Select an option",
@@ -24,6 +24,11 @@
24
24
  "Deleted_department": "已删除部门",
25
25
  "View_original_image": "View original image",
26
26
  "Add_filter": "增加过滤条件",
27
+ "And": "并且",
28
+ "Or": "或者",
29
+ "Add_filter_group": "增加过滤组",
30
+ "Click_to_add_filter": "点击添加过滤器",
31
+ "Click_to_input_value": "点击输入值",
27
32
  "Submit": "提交",
28
33
  "No_filters": "没有过滤器",
29
34
  "Select_an_option": "选择标签",
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isEnableCheckFormat = exports.getDateColumnFormat = void 0;
6
+ exports.getDateColumnFormat = void 0;
7
+ exports.isCheckboxColumn = isCheckboxColumn;
8
+ exports.isEnableCheckFormat = void 0;
7
9
  var _dtableUtils = require("dtable-utils");
8
10
  const isEnableCheckFormat = column => {
9
11
  if (!column) return false;
@@ -22,4 +24,21 @@ const getDateColumnFormat = column => {
22
24
  // Old Europe format is D/M/YYYY new format is DD/MM/YYYY
23
25
  return format;
24
26
  };
25
- exports.getDateColumnFormat = getDateColumnFormat;
27
+ exports.getDateColumnFormat = getDateColumnFormat;
28
+ function isCheckboxColumn(column) {
29
+ let {
30
+ type,
31
+ data
32
+ } = column;
33
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
34
+ const {
35
+ result_type,
36
+ array_type
37
+ } = data || {};
38
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
39
+ return array_type === _dtableUtils.CellType.CHECKBOX;
40
+ }
41
+ return false;
42
+ }
43
+ return type === _dtableUtils.CellType.CHECKBOX;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.37",
3
+ "version": "6.0.38-alpha.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",