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