dtable-ui-component 6.0.37 → 6.0.38-alpha.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/lib/CheckboxEditor/index.css +6 -7
- package/lib/DTableFiltersPopover/constants/index.js +30 -2
- package/lib/DTableFiltersPopover/index.css +50 -14
- package/lib/DTableFiltersPopover/index.js +118 -136
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +10 -4
- package/lib/DTableFiltersPopover/utils/index.js +358 -82
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +6 -4
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +13 -2
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +20 -6
- package/lib/DTableFiltersPopover/widgets/filter-group.js +185 -0
- package/lib/DTableFiltersPopover/widgets/filter-item.js +138 -53
- package/lib/DTableFiltersPopover/widgets/filter-list/index.css +119 -10
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +226 -39
- package/lib/locales/en.json +5 -0
- package/lib/locales/zh-CN.json +5 -0
- package/lib/utils/column-utils.js +21 -2
- package/package.json +1 -1
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.css +0 -0
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "FilterItemUtils", {
|
|
|
10
10
|
return _filterItemUtils.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.isFilterTermArray = exports.
|
|
13
|
+
exports.isFilterTermArray = exports.getUpdatedFilterBySelectSingle = exports.getUpdatedFilterBySelectMultiple = exports.getUpdatedFilterByRate = exports.getUpdatedFilterByPredicate = exports.getUpdatedFilterByCreator = exports.getUpdatedFilterByColumn = exports.getUpdatedFilterByCollaborator = exports.getSingleSelectUpdatedFilterTerm = exports.getMultipleSelectUpdatedFilterTerm = exports.getFormulaColumnFilter = exports.getFormulaAndLinkFilters = exports.getFilterConfigOptions = exports.getFilterColumns = exports.getFilterByColumn = exports.getDefaultFilterGroup = exports.getDefaultFilter = exports.getCreatorUpdatedFilterTerm = exports.getColumnOptions = exports.getColumnByKey = exports.getCollaboratorUpdatedFilterTerm = exports.generateDefaultUser = exports.applyFilterOperation = void 0;
|
|
14
14
|
var _dtableUtils = require("dtable-utils");
|
|
15
15
|
var _filterItemUtils = _interopRequireDefault(require("./filter-item-utils"));
|
|
16
16
|
var _constants = require("../constants");
|
|
@@ -28,7 +28,7 @@ const isFilterTermArray = (column, filterPredicate) => {
|
|
|
28
28
|
if (type === _dtableUtils.CellType.SINGLE_SELECT && [_dtableUtils.FILTER_PREDICATE_TYPE.IS_ANY_OF, _dtableUtils.FILTER_PREDICATE_TYPE.IS_NONE_OF].includes(filterPredicate)) {
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
|
-
if (
|
|
31
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES.includes(type)) {
|
|
32
32
|
const {
|
|
33
33
|
result_type,
|
|
34
34
|
array_type
|
|
@@ -74,7 +74,7 @@ exports.getUpdatedFilterByCreator = getUpdatedFilterByCreator;
|
|
|
74
74
|
const getUpdatedFilterBySelectSingle = (filter, columnOption) => {
|
|
75
75
|
let new_filter_term;
|
|
76
76
|
// if predicate is any of / is none of, filter_term is array; else filter_term is string
|
|
77
|
-
if (
|
|
77
|
+
if (_constants.ARRAY_PREDICATE[filter.filter_predicate]) {
|
|
78
78
|
new_filter_term = Array.isArray(filter.filter_term) ? [...filter.filter_term] : [];
|
|
79
79
|
const index = new_filter_term.indexOf(columnOption.id);
|
|
80
80
|
if (index === -1) {
|
|
@@ -119,7 +119,9 @@ const getUpdatedFilterByCollaborator = (filter, collaborator) => {
|
|
|
119
119
|
exports.getUpdatedFilterByCollaborator = getUpdatedFilterByCollaborator;
|
|
120
120
|
const getUpdatedFilterByRate = (filter, value) => {
|
|
121
121
|
if (filter.filter_term === value) {
|
|
122
|
-
return
|
|
122
|
+
return Object.assign({}, filter, {
|
|
123
|
+
filter_term: 0
|
|
124
|
+
});
|
|
123
125
|
}
|
|
124
126
|
return Object.assign({}, filter, {
|
|
125
127
|
filter_term: value
|
|
@@ -131,7 +133,7 @@ const getColumnOptions = column => {
|
|
|
131
133
|
type,
|
|
132
134
|
data
|
|
133
135
|
} = column;
|
|
134
|
-
if (
|
|
136
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES.includes(type)) {
|
|
135
137
|
return getFormulaColumnFilterOptions(column);
|
|
136
138
|
}
|
|
137
139
|
if (type === _dtableUtils.CellType.LINK) {
|
|
@@ -204,23 +206,17 @@ const getFilterOptionsByArrayType = array_type => {
|
|
|
204
206
|
}
|
|
205
207
|
return filterOptions;
|
|
206
208
|
};
|
|
207
|
-
const getFilterByColumn = function (column
|
|
208
|
-
let {
|
|
209
|
-
textDefaultPredicate
|
|
210
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
211
|
-
let filter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
209
|
+
const getFilterByColumn = function (column) {
|
|
210
|
+
let filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
212
211
|
let {
|
|
213
212
|
type: columnType,
|
|
214
213
|
data: columnData
|
|
215
214
|
} = column;
|
|
216
215
|
let {
|
|
217
216
|
filterPredicateList
|
|
218
|
-
} = getColumnOptions(column
|
|
217
|
+
} = getColumnOptions(column);
|
|
219
218
|
if (!filterPredicateList) return;
|
|
220
219
|
let filterPredicate = filterPredicateList[0];
|
|
221
|
-
if (textDefaultPredicate && columnType === _dtableUtils.CellType.TEXT && filterPredicateList.includes(textDefaultPredicate)) {
|
|
222
|
-
filterPredicate = textDefaultPredicate;
|
|
223
|
-
}
|
|
224
220
|
let updatedFilter = Object.assign({}, filter, {
|
|
225
221
|
column_key: column.key,
|
|
226
222
|
filter_predicate: filterPredicate
|
|
@@ -256,8 +252,8 @@ const getFilterByColumn = function (column, value) {
|
|
|
256
252
|
return updatedFilter;
|
|
257
253
|
}
|
|
258
254
|
// formula | link-formula
|
|
259
|
-
if (
|
|
260
|
-
const newUpdatedFilter = getFormulaColumnFilter(column,
|
|
255
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
256
|
+
const newUpdatedFilter = getFormulaColumnFilter(column, filter);
|
|
261
257
|
if (newUpdatedFilter) {
|
|
262
258
|
updatedFilter.filter_term = newUpdatedFilter.filter_term;
|
|
263
259
|
}
|
|
@@ -281,7 +277,7 @@ const getFilterByColumn = function (column, value) {
|
|
|
281
277
|
type: array_type,
|
|
282
278
|
data: array_data
|
|
283
279
|
};
|
|
284
|
-
const newUpdatedFilter = getFilterByColumn(linkedColumn,
|
|
280
|
+
const newUpdatedFilter = getFilterByColumn(linkedColumn, filter) || {};
|
|
285
281
|
if (newUpdatedFilter) {
|
|
286
282
|
updatedFilter.filter_term = newUpdatedFilter.filter_term;
|
|
287
283
|
}
|
|
@@ -291,7 +287,7 @@ const getFilterByColumn = function (column, value) {
|
|
|
291
287
|
return updatedFilter;
|
|
292
288
|
};
|
|
293
289
|
exports.getFilterByColumn = getFilterByColumn;
|
|
294
|
-
const getFormulaColumnFilter = (column,
|
|
290
|
+
const getFormulaColumnFilter = (column, filter) => {
|
|
295
291
|
const {
|
|
296
292
|
data
|
|
297
293
|
} = column;
|
|
@@ -306,7 +302,7 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
306
302
|
type: array_type,
|
|
307
303
|
data: array_data
|
|
308
304
|
};
|
|
309
|
-
return getFilterByColumn(linkedColumn,
|
|
305
|
+
return getFilterByColumn(linkedColumn, filter);
|
|
310
306
|
}
|
|
311
307
|
// result_type: string | number | bool | date
|
|
312
308
|
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
|
|
@@ -320,7 +316,7 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
320
316
|
type: array_type,
|
|
321
317
|
data: array_data
|
|
322
318
|
};
|
|
323
|
-
return getFilterByColumn(linkedColumn,
|
|
319
|
+
return getFilterByColumn(linkedColumn, filter);
|
|
324
320
|
};
|
|
325
321
|
|
|
326
322
|
// file, image : not support
|
|
@@ -328,12 +324,12 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
328
324
|
// checkbox : boolean
|
|
329
325
|
// multiple-select, collaborator, creator, last modifier : array
|
|
330
326
|
exports.getFormulaColumnFilter = getFormulaColumnFilter;
|
|
331
|
-
const getUpdatedFilterByColumn = (filters,
|
|
327
|
+
const getUpdatedFilterByColumn = (filters, filterIndex, column) => {
|
|
332
328
|
const filter = filters[filterIndex];
|
|
333
329
|
if (filter.column_key === column.key) {
|
|
334
330
|
return;
|
|
335
331
|
}
|
|
336
|
-
return getFilterByColumn(column,
|
|
332
|
+
return getFilterByColumn(column, filter);
|
|
337
333
|
};
|
|
338
334
|
exports.getUpdatedFilterByColumn = getUpdatedFilterByColumn;
|
|
339
335
|
const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
@@ -380,96 +376,376 @@ const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
|
380
376
|
return updatedFilter;
|
|
381
377
|
};
|
|
382
378
|
exports.getUpdatedFilterByPredicate = getUpdatedFilterByPredicate;
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
379
|
+
const getColumnByKey = (columnKey, columns) => {
|
|
380
|
+
if (!Array.isArray(columns) || !columnKey) return null;
|
|
381
|
+
return columns.find(column => column.key === columnKey);
|
|
382
|
+
};
|
|
383
|
+
exports.getColumnByKey = getColumnByKey;
|
|
384
|
+
const getMediaUrl = () => {
|
|
385
|
+
var _window, _window$dtable, _window2, _window2$dtablePlugin;
|
|
386
|
+
return ((_window = window) === null || _window === void 0 ? void 0 : (_window$dtable = _window.dtable) === null || _window$dtable === void 0 ? void 0 : _window$dtable.mediaUrl) || ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$dtablePlugin = _window2.dtablePluginConfig) === null || _window2$dtablePlugin === void 0 ? void 0 : _window2$dtablePlugin.mediaUrl) || '/media/';
|
|
387
|
+
};
|
|
388
|
+
const generateDefaultUser = name => {
|
|
389
|
+
const mediaUrl = getMediaUrl();
|
|
390
|
+
const defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
|
|
391
|
+
return {
|
|
392
|
+
name,
|
|
393
|
+
email: name,
|
|
394
|
+
avatar_url: defaultAvatarUrl
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
exports.generateDefaultUser = generateDefaultUser;
|
|
398
|
+
const getDefaultFilter = columns => {
|
|
399
|
+
if (!columns) return null;
|
|
400
|
+
let defaultColumn = columns[0];
|
|
401
|
+
if (!_dtableUtils.FILTER_COLUMN_OPTIONS[defaultColumn.type]) {
|
|
402
|
+
defaultColumn = columns.find(c => _dtableUtils.FILTER_COLUMN_OPTIONS[c.type]);
|
|
403
|
+
}
|
|
404
|
+
if (!defaultColumn) return null;
|
|
405
|
+
return getFilterByColumn(defaultColumn);
|
|
406
|
+
};
|
|
407
|
+
exports.getDefaultFilter = getDefaultFilter;
|
|
408
|
+
const getDefaultFilterGroup = columns => {
|
|
409
|
+
const defaultFilter = getDefaultFilter(columns);
|
|
410
|
+
if (!defaultFilter) {
|
|
411
|
+
return null;
|
|
387
412
|
}
|
|
388
|
-
|
|
389
|
-
|
|
413
|
+
const filters = [defaultFilter];
|
|
414
|
+
return {
|
|
415
|
+
filter_conjunction: _dtableUtils.FILTER_CONJUNCTION_TYPE.AND,
|
|
416
|
+
filters
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
exports.getDefaultFilterGroup = getDefaultFilterGroup;
|
|
420
|
+
const getFormulaAndLinkFilters = (filters, columns) => {
|
|
421
|
+
let formulaFilters = [];
|
|
422
|
+
filters.forEach(filter => {
|
|
423
|
+
const filterColumn = columns.find(column => column.key === (filter === null || filter === void 0 ? void 0 : filter.column_key));
|
|
424
|
+
const {
|
|
425
|
+
type
|
|
426
|
+
} = filterColumn;
|
|
427
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] || type === _dtableUtils.CellType.LINK) {
|
|
428
|
+
formulaFilters.push(filter);
|
|
429
|
+
}
|
|
390
430
|
});
|
|
431
|
+
return formulaFilters;
|
|
391
432
|
};
|
|
392
|
-
exports.
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
return Object.assign({}, filter, {
|
|
405
|
-
filter_term: filterTerm
|
|
433
|
+
exports.getFormulaAndLinkFilters = getFormulaAndLinkFilters;
|
|
434
|
+
const getFilterColumns = columns => {
|
|
435
|
+
return columns.filter(column => {
|
|
436
|
+
const {
|
|
437
|
+
data,
|
|
438
|
+
type
|
|
439
|
+
} = column;
|
|
440
|
+
if (data && (type === _dtableUtils.CellType.LINK || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY)) {
|
|
441
|
+
return Object.prototype.hasOwnProperty.call(_dtableUtils.FILTER_COLUMN_OPTIONS, data.array_type);
|
|
442
|
+
}
|
|
443
|
+
return Object.prototype.hasOwnProperty.call(_dtableUtils.FILTER_COLUMN_OPTIONS, type);
|
|
406
444
|
});
|
|
407
445
|
};
|
|
408
|
-
exports.
|
|
409
|
-
const
|
|
410
|
-
const
|
|
446
|
+
exports.getFilterColumns = getFilterColumns;
|
|
447
|
+
const applyFilterOperation = operation => {
|
|
448
|
+
const {
|
|
449
|
+
type,
|
|
450
|
+
filter_conjunction,
|
|
451
|
+
filters,
|
|
452
|
+
payload
|
|
453
|
+
} = operation;
|
|
411
454
|
switch (type) {
|
|
412
|
-
case _constants.
|
|
455
|
+
case _constants.FILTER_OPERATION_TYPE.MODIFY_CONJUNCTION:
|
|
456
|
+
{
|
|
457
|
+
const {
|
|
458
|
+
new_filter_conjunction
|
|
459
|
+
} = payload;
|
|
460
|
+
return {
|
|
461
|
+
filter_conjunction: new_filter_conjunction,
|
|
462
|
+
filters
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
case _constants.FILTER_OPERATION_TYPE.DELETE_FILTER:
|
|
413
466
|
{
|
|
414
|
-
|
|
467
|
+
const {
|
|
468
|
+
filter_index
|
|
469
|
+
} = payload;
|
|
470
|
+
let updatedFilters = [...filters];
|
|
471
|
+
if (!updatedFilters[filter_index]) {
|
|
472
|
+
return {
|
|
473
|
+
filter_conjunction,
|
|
474
|
+
filters
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
updatedFilters.splice(filter_index, 1);
|
|
478
|
+
return {
|
|
479
|
+
filter_conjunction,
|
|
480
|
+
filters: updatedFilters
|
|
481
|
+
};
|
|
415
482
|
}
|
|
416
|
-
case _constants.
|
|
483
|
+
case _constants.FILTER_OPERATION_TYPE.UPDATE_FILTER:
|
|
417
484
|
{
|
|
418
|
-
|
|
485
|
+
const {
|
|
486
|
+
filter_index,
|
|
487
|
+
new_filter
|
|
488
|
+
} = payload;
|
|
489
|
+
let updatedFilters = [...filters];
|
|
490
|
+
if (!updatedFilters[filter_index]) {
|
|
491
|
+
return {
|
|
492
|
+
filter_conjunction,
|
|
493
|
+
filters
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
updatedFilters[filter_index] = new_filter;
|
|
497
|
+
return {
|
|
498
|
+
filter_conjunction,
|
|
499
|
+
filters: updatedFilters
|
|
500
|
+
};
|
|
419
501
|
}
|
|
420
|
-
case _constants.
|
|
502
|
+
case _constants.FILTER_OPERATION_TYPE.MOVE_FILTER:
|
|
421
503
|
{
|
|
422
|
-
|
|
504
|
+
const {
|
|
505
|
+
source_filter_index,
|
|
506
|
+
target_filter_index,
|
|
507
|
+
source_group_index,
|
|
508
|
+
target_group_index
|
|
509
|
+
} = payload;
|
|
510
|
+
const isFromFilterGroup = typeof source_group_index === 'number';
|
|
511
|
+
const isToFilterGroup = typeof target_group_index === 'number';
|
|
512
|
+
let updatedFilters = [...filters];
|
|
513
|
+
|
|
514
|
+
// move filter(not in group) or filter-group over filter(not in group) or filter-group
|
|
515
|
+
if (!isFromFilterGroup && !isToFilterGroup) {
|
|
516
|
+
const movedFilter = updatedFilters[source_filter_index];
|
|
517
|
+
if (!movedFilter) {
|
|
518
|
+
return {
|
|
519
|
+
filter_conjunction,
|
|
520
|
+
filters
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
updatedFilters.splice(source_filter_index, 1);
|
|
524
|
+
updatedFilters.splice(target_filter_index, 0, movedFilter);
|
|
525
|
+
return {
|
|
526
|
+
filter_conjunction,
|
|
527
|
+
filters: updatedFilters
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// source
|
|
532
|
+
let sourceFilters = null;
|
|
533
|
+
if (isFromFilterGroup) {
|
|
534
|
+
const filterGroup = updatedFilters[source_group_index];
|
|
535
|
+
const subFilters = filterGroup && filterGroup.filters;
|
|
536
|
+
sourceFilters = subFilters;
|
|
537
|
+
} else {
|
|
538
|
+
sourceFilters = updatedFilters;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// target
|
|
542
|
+
let targetFilters = null;
|
|
543
|
+
if (isToFilterGroup) {
|
|
544
|
+
const filterGroup = updatedFilters[target_group_index];
|
|
545
|
+
const subFilters = filterGroup && filterGroup.filters;
|
|
546
|
+
targetFilters = subFilters;
|
|
547
|
+
} else {
|
|
548
|
+
targetFilters = updatedFilters;
|
|
549
|
+
}
|
|
550
|
+
const movedFilter = sourceFilters && sourceFilters[source_filter_index];
|
|
551
|
+
if (!movedFilter || !targetFilters) {
|
|
552
|
+
return {
|
|
553
|
+
filter_conjunction,
|
|
554
|
+
filters
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
let targetIndex = target_filter_index;
|
|
558
|
+
if ((isFromFilterGroup || isToFilterGroup) && source_group_index !== target_group_index) {
|
|
559
|
+
targetIndex = target_filter_index + 1;
|
|
560
|
+
}
|
|
561
|
+
sourceFilters.splice(source_filter_index, 1);
|
|
562
|
+
targetFilters.splice(targetIndex, 0, movedFilter);
|
|
563
|
+
return {
|
|
564
|
+
filter_conjunction,
|
|
565
|
+
filters: updatedFilters
|
|
566
|
+
};
|
|
423
567
|
}
|
|
424
|
-
case _constants.
|
|
568
|
+
case _constants.FILTER_OPERATION_TYPE.ADD_FILTER_INTO_GROUP:
|
|
425
569
|
{
|
|
426
|
-
|
|
570
|
+
const {
|
|
571
|
+
filter,
|
|
572
|
+
group_index
|
|
573
|
+
} = payload;
|
|
574
|
+
let updatedFilters = [...filters];
|
|
575
|
+
let updatedFilterGroup = updatedFilters[group_index];
|
|
576
|
+
if (!updatedFilterGroup) {
|
|
577
|
+
return {
|
|
578
|
+
filter_conjunction,
|
|
579
|
+
filters
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
if (!Array.isArray(updatedFilterGroup.filters)) {
|
|
583
|
+
updatedFilterGroup.filters = [filter];
|
|
584
|
+
} else {
|
|
585
|
+
updatedFilterGroup.filters.push(filter);
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
filter_conjunction,
|
|
589
|
+
filters: updatedFilters
|
|
590
|
+
};
|
|
427
591
|
}
|
|
428
|
-
case _constants.
|
|
592
|
+
case _constants.FILTER_OPERATION_TYPE.MODIFY_CONJUNCTION_IN_GROUP:
|
|
429
593
|
{
|
|
430
|
-
|
|
594
|
+
const {
|
|
595
|
+
group_index,
|
|
596
|
+
new_filter_conjunction
|
|
597
|
+
} = payload;
|
|
598
|
+
let updatedFilters = [...filters];
|
|
599
|
+
let updatedFilterGroup = updatedFilters[group_index];
|
|
600
|
+
if (!updatedFilterGroup) {
|
|
601
|
+
return {
|
|
602
|
+
filter_conjunction,
|
|
603
|
+
filters
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
updatedFilterGroup.filter_conjunction = new_filter_conjunction;
|
|
607
|
+
return {
|
|
608
|
+
filter_conjunction,
|
|
609
|
+
filters: updatedFilters
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
case _constants.FILTER_OPERATION_TYPE.DELETE_FILTER_IN_GROUP:
|
|
613
|
+
{
|
|
614
|
+
const {
|
|
615
|
+
group_index,
|
|
616
|
+
filter_index
|
|
617
|
+
} = payload;
|
|
618
|
+
let updatedFilters = [...filters];
|
|
619
|
+
let updatedFilterGroup = updatedFilters[group_index];
|
|
620
|
+
if (!updatedFilterGroup || !updatedFilterGroup.filters || !updatedFilterGroup.filters[filter_index]) {
|
|
621
|
+
return {
|
|
622
|
+
filter_conjunction,
|
|
623
|
+
filters
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
let subFilters = [...updatedFilterGroup.filters];
|
|
627
|
+
subFilters.splice(filter_index, 1);
|
|
628
|
+
updatedFilterGroup.filters = subFilters;
|
|
629
|
+
return {
|
|
630
|
+
filter_conjunction,
|
|
631
|
+
filters: updatedFilters
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
case _constants.FILTER_OPERATION_TYPE.UPDATE_FILTER_IN_GROUP:
|
|
635
|
+
{
|
|
636
|
+
const {
|
|
637
|
+
group_index,
|
|
638
|
+
filter_index,
|
|
639
|
+
new_filter
|
|
640
|
+
} = payload;
|
|
641
|
+
let updatedFilters = [...filters];
|
|
642
|
+
let updatedFilterGroup = updatedFilters[group_index];
|
|
643
|
+
if (!updatedFilterGroup || !updatedFilterGroup.filters || !updatedFilterGroup.filters[filter_index]) {
|
|
644
|
+
return {
|
|
645
|
+
filter_conjunction,
|
|
646
|
+
filters
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
let subFilters = [...updatedFilterGroup.filters];
|
|
650
|
+
subFilters[filter_index] = new_filter;
|
|
651
|
+
updatedFilterGroup.filters = subFilters;
|
|
652
|
+
return {
|
|
653
|
+
filter_conjunction,
|
|
654
|
+
filters: updatedFilters
|
|
655
|
+
};
|
|
431
656
|
}
|
|
432
657
|
default:
|
|
433
658
|
{
|
|
434
|
-
|
|
659
|
+
return {
|
|
660
|
+
filter_conjunction,
|
|
661
|
+
filters
|
|
662
|
+
};
|
|
435
663
|
}
|
|
436
664
|
}
|
|
437
665
|
};
|
|
438
|
-
exports.
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
666
|
+
exports.applyFilterOperation = applyFilterOperation;
|
|
667
|
+
const getCollaboratorUpdatedFilterTerm = (filterTerm, collaborator) => {
|
|
668
|
+
let newFilterTerm = filterTerm ? filterTerm.slice(0) : [];
|
|
669
|
+
const selectedEmail = collaborator.email;
|
|
670
|
+
const index = newFilterTerm.indexOf(selectedEmail);
|
|
671
|
+
if (index > -1) {
|
|
672
|
+
newFilterTerm.splice(index, 1);
|
|
673
|
+
} else {
|
|
674
|
+
newFilterTerm.push(selectedEmail);
|
|
675
|
+
}
|
|
676
|
+
return newFilterTerm;
|
|
442
677
|
};
|
|
443
|
-
exports.
|
|
444
|
-
const
|
|
445
|
-
|
|
678
|
+
exports.getCollaboratorUpdatedFilterTerm = getCollaboratorUpdatedFilterTerm;
|
|
679
|
+
const getCreatorUpdatedFilterTerm = (filterTerm, filterPredicate, collaborator) => {
|
|
680
|
+
const multipleSelectType = [_dtableUtils.FILTER_PREDICATE_TYPE.CONTAINS, _dtableUtils.FILTER_PREDICATE_TYPE.NOT_CONTAIN];
|
|
681
|
+
let newFilterTerm = filterTerm;
|
|
682
|
+
if (multipleSelectType.includes(filterPredicate)) {
|
|
683
|
+
newFilterTerm = newFilterTerm ? newFilterTerm.slice(0) : [];
|
|
684
|
+
const selectedEmail = collaborator.email;
|
|
685
|
+
const index = newFilterTerm.indexOf(selectedEmail);
|
|
686
|
+
if (index > -1) {
|
|
687
|
+
newFilterTerm.splice(index, 1);
|
|
688
|
+
} else {
|
|
689
|
+
newFilterTerm.push(selectedEmail);
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
if (newFilterTerm[0] === collaborator.email) {
|
|
693
|
+
return newFilterTerm;
|
|
694
|
+
}
|
|
695
|
+
newFilterTerm = [collaborator.email];
|
|
696
|
+
}
|
|
697
|
+
return newFilterTerm;
|
|
698
|
+
};
|
|
699
|
+
exports.getCreatorUpdatedFilterTerm = getCreatorUpdatedFilterTerm;
|
|
700
|
+
const getFilterConfigOptions = column => {
|
|
701
|
+
const {
|
|
446
702
|
type,
|
|
447
703
|
data
|
|
448
704
|
} = column;
|
|
449
|
-
if (_dtableUtils.
|
|
705
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES.includes(type)) {
|
|
706
|
+
return getFormulaColumnFilterOptions(column);
|
|
707
|
+
}
|
|
708
|
+
if (type === _dtableUtils.CellType.LINK) {
|
|
450
709
|
const {
|
|
451
|
-
result_type,
|
|
452
710
|
array_type
|
|
453
711
|
} = data || {};
|
|
454
|
-
if (
|
|
455
|
-
return
|
|
712
|
+
if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
|
|
713
|
+
return _dtableUtils.FILTER_COLUMN_OPTIONS[_dtableUtils.CellType.CHECKBOX];
|
|
714
|
+
}
|
|
715
|
+
if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.STRING) {
|
|
716
|
+
return _dtableUtils.FILTER_COLUMN_OPTIONS[_dtableUtils.CellType.TEXT];
|
|
456
717
|
}
|
|
457
|
-
return
|
|
718
|
+
return getFilterOptionsByArrayType(array_type);
|
|
458
719
|
}
|
|
459
|
-
return type
|
|
720
|
+
return _dtableUtils.FILTER_COLUMN_OPTIONS[type] || {};
|
|
460
721
|
};
|
|
461
|
-
exports.
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
722
|
+
exports.getFilterConfigOptions = getFilterConfigOptions;
|
|
723
|
+
const getMultipleSelectUpdatedFilterTerm = (filterTerm, option) => {
|
|
724
|
+
let newFilterTerm = filterTerm || [];
|
|
725
|
+
const index = newFilterTerm.indexOf(option.id);
|
|
726
|
+
if (index > -1) {
|
|
727
|
+
newFilterTerm.splice(index, 1);
|
|
728
|
+
} else {
|
|
729
|
+
newFilterTerm.push(option.id);
|
|
730
|
+
}
|
|
731
|
+
return newFilterTerm;
|
|
465
732
|
};
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
733
|
+
exports.getMultipleSelectUpdatedFilterTerm = getMultipleSelectUpdatedFilterTerm;
|
|
734
|
+
const getSingleSelectUpdatedFilterTerm = (filterTerm, filterPredicate, option) => {
|
|
735
|
+
let newFilterTerm;
|
|
736
|
+
|
|
737
|
+
// if predicate is any of / is none of, filter_term is array; else filter_term is string
|
|
738
|
+
if (_constants.ARRAY_PREDICATE[filterPredicate]) {
|
|
739
|
+
newFilterTerm = Array.isArray(filterTerm) ? [...filterTerm] : [];
|
|
740
|
+
const index = newFilterTerm.indexOf(option.id);
|
|
741
|
+
if (index === -1) {
|
|
742
|
+
newFilterTerm.push(option.id);
|
|
743
|
+
} else {
|
|
744
|
+
newFilterTerm.splice(index, 1);
|
|
745
|
+
}
|
|
746
|
+
} else {
|
|
747
|
+
newFilterTerm = option.id;
|
|
748
|
+
}
|
|
749
|
+
return newFilterTerm;
|
|
474
750
|
};
|
|
475
|
-
exports.
|
|
751
|
+
exports.getSingleSelectUpdatedFilterTerm = getSingleSelectUpdatedFilterTerm;
|
|
@@ -10,7 +10,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _dtableUtils = require("dtable-utils");
|
|
11
11
|
var _DTableCustomizeSelect = _interopRequireDefault(require("../../../DTableCustomizeSelect"));
|
|
12
12
|
var _lang = require("../../../lang");
|
|
13
|
-
require("./index.css");
|
|
14
13
|
class CollaboratorFilter extends _react.Component {
|
|
15
14
|
constructor(props) {
|
|
16
15
|
super(props);
|
|
@@ -63,7 +62,9 @@ class CollaboratorFilter extends _react.Component {
|
|
|
63
62
|
filterTerm,
|
|
64
63
|
collaborators,
|
|
65
64
|
placeholder,
|
|
66
|
-
filter_predicate
|
|
65
|
+
filter_predicate,
|
|
66
|
+
isInModal,
|
|
67
|
+
readonly
|
|
67
68
|
} = this.props;
|
|
68
69
|
let isSupportMultipleSelect = this.supportMultipleSelectOptions.indexOf(filter_predicate) > -1 ? true : false;
|
|
69
70
|
let selectedCollaborators = Array.isArray(filterTerm) && filterTerm.length > 0 && filterTerm.map(item => {
|
|
@@ -103,11 +104,12 @@ class CollaboratorFilter extends _react.Component {
|
|
|
103
104
|
onSelectOption: this.props.onSelectCollaborator,
|
|
104
105
|
options: options,
|
|
105
106
|
placeholder: placeholder,
|
|
106
|
-
isLocked:
|
|
107
|
+
isLocked: readonly,
|
|
107
108
|
supportMultipleSelect: isSupportMultipleSelect,
|
|
108
109
|
searchable: true,
|
|
109
110
|
searchPlaceholder: (0, _lang.getLocale)('Search_collaborator'),
|
|
110
|
-
isShowSelected: false
|
|
111
|
+
isShowSelected: false,
|
|
112
|
+
isInModal: isInModal
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -13,9 +13,11 @@ var _DepartmentMultipleSelectEditor = _interopRequireDefault(require("../../../D
|
|
|
13
13
|
var _departments = require("../../../constants/departments");
|
|
14
14
|
var _commonHooks = require("../../../hooks/common-hooks");
|
|
15
15
|
var _lang = require("../../../lang");
|
|
16
|
+
var _ModalPortal = _interopRequireDefault(require("../../../ModalPortal"));
|
|
16
17
|
function DepartmentMultipleSelectFilter(props) {
|
|
17
18
|
const {
|
|
18
19
|
value,
|
|
20
|
+
isInModal,
|
|
19
21
|
departments
|
|
20
22
|
} = props;
|
|
21
23
|
const [isShowSelector, setIsShowSelector] = (0, _react.useState)(false);
|
|
@@ -39,6 +41,7 @@ function DepartmentMultipleSelectFilter(props) {
|
|
|
39
41
|
type: "checkbox",
|
|
40
42
|
className: "vam department-select-input",
|
|
41
43
|
checked: selectedDepartments.includes(type),
|
|
44
|
+
onClick: event => event.stopPropagation(),
|
|
42
45
|
onChange: event => selectDepartment(event, type)
|
|
43
46
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
44
47
|
className: "text-truncate department-name"
|
|
@@ -85,13 +88,21 @@ function DepartmentMultipleSelectFilter(props) {
|
|
|
85
88
|
className: "select-placeholder"
|
|
86
89
|
}, (0, _lang.getLocale)('Select_department')), /*#__PURE__*/_react.default.createElement("span", {
|
|
87
90
|
className: "dtable-font dtable-icon-down3"
|
|
88
|
-
})), isShowSelector && /*#__PURE__*/_react.default.createElement(_DepartmentMultipleSelectEditor.default, {
|
|
91
|
+
})), isShowSelector && !isInModal && /*#__PURE__*/_react.default.createElement(_DepartmentMultipleSelectEditor.default, {
|
|
89
92
|
isShowSelectedDepartments: false,
|
|
90
93
|
classNamePrefix: "filter",
|
|
91
94
|
value: selectedDepartments,
|
|
92
95
|
onCommit: selectDepartment,
|
|
93
96
|
renderUserDepartmentOptions: renderUserDepartmentOptions,
|
|
94
97
|
departments: departments
|
|
95
|
-
})
|
|
98
|
+
}), isShowSelector && isInModal && /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement(_DepartmentMultipleSelectEditor.default, {
|
|
99
|
+
isInModal: isInModal,
|
|
100
|
+
isShowSelectedDepartments: false,
|
|
101
|
+
classNamePrefix: "filter",
|
|
102
|
+
value: selectedDepartments,
|
|
103
|
+
position: selectorRef.current.getBoundingClientRect(),
|
|
104
|
+
onCommit: selectDepartment,
|
|
105
|
+
renderUserDepartmentOptions: renderUserDepartmentOptions
|
|
106
|
+
})));
|
|
96
107
|
}
|
|
97
108
|
var _default = exports.default = DepartmentMultipleSelectFilter;
|