dtable-ui-component 6.0.38-alpha.1 → 6.0.38
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/DTableFiltersPopover/constants/index.js +2 -30
- package/lib/DTableFiltersPopover/index.css +17 -36
- package/lib/DTableFiltersPopover/index.js +136 -118
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +4 -10
- package/lib/DTableFiltersPopover/utils/index.js +82 -358
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.css +0 -0
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +4 -6
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +2 -13
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +6 -18
- package/lib/DTableFiltersPopover/widgets/filter-item.js +53 -138
- package/lib/DTableFiltersPopover/widgets/filter-list/index.css +16 -113
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +39 -226
- package/lib/GeolocationEditor/mb-editor/map-editor/index.css +5 -2
- package/lib/GeolocationEditor/mb-editor/map-editor/index.js +93 -51
- package/lib/GeolocationEditor/pc-editor/index.css +6 -15
- package/lib/GeolocationEditor/pc-editor/index.js +4 -1
- package/lib/GeolocationEditor/pc-editor/map-editor/index.css +33 -0
- package/lib/GeolocationEditor/pc-editor/map-editor/index.js +143 -99
- package/lib/GeolocationEditor/pc-editor/map-editor/large-editor/index.css +13 -11
- package/lib/GeolocationEditor/pc-editor/map-editor/large-editor/index.js +100 -70
- package/lib/GeolocationEditor/pc-editor/map-selection-editor/index.js +20 -11
- package/lib/GeolocationEditor/pc-editor/map-selection-editor/large-editor/index.js +2 -2
- package/lib/RowExpandEditor/geolocation-editor/pc-editor/index.js +19 -5
- package/lib/locales/de.json +5 -3
- package/lib/locales/en.json +5 -8
- package/lib/locales/es.json +5 -3
- package/lib/locales/fr.json +5 -3
- package/lib/locales/pt.json +5 -3
- package/lib/locales/ru.json +5 -3
- package/lib/locales/zh-CN.json +5 -8
- package/lib/utils/column-utils.js +2 -21
- package/package.json +2 -2
- package/lib/DTableFiltersPopover/widgets/filter-group.js +0 -185
|
@@ -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.isCheckboxColumn = exports.getUpdatedFilterByTermModifier = exports.getUpdatedFilterBySpecialTerm = exports.getUpdatedFilterBySelectSingle = exports.getUpdatedFilterBySelectMultiple = exports.getUpdatedFilterByRate = exports.getUpdatedFilterByPredicate = exports.getUpdatedFilterByNormalTerm = exports.getUpdatedFilterByCreator = exports.getUpdatedFilterByColumn = exports.getUpdatedFilterByCollaborator = exports.getFormulaColumnFilter = exports.getFilterByColumn = exports.getColumnOptions = exports.getColumnByKey = exports.generateDefaultUser = 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 (_constants.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 (filter.filter_predicate === _dtableUtils.FILTER_PREDICATE_TYPE.IS_ANY_OF || filter.filter_predicate === _dtableUtils.FILTER_PREDICATE_TYPE.IS_NONE_OF) {
|
|
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,9 +119,7 @@ const getUpdatedFilterByCollaborator = (filter, collaborator) => {
|
|
|
119
119
|
exports.getUpdatedFilterByCollaborator = getUpdatedFilterByCollaborator;
|
|
120
120
|
const getUpdatedFilterByRate = (filter, value) => {
|
|
121
121
|
if (filter.filter_term === value) {
|
|
122
|
-
return
|
|
123
|
-
filter_term: 0
|
|
124
|
-
});
|
|
122
|
+
return;
|
|
125
123
|
}
|
|
126
124
|
return Object.assign({}, filter, {
|
|
127
125
|
filter_term: value
|
|
@@ -133,7 +131,7 @@ const getColumnOptions = column => {
|
|
|
133
131
|
type,
|
|
134
132
|
data
|
|
135
133
|
} = column;
|
|
136
|
-
if (
|
|
134
|
+
if (_constants.FORMULA_COLUMN_TYPES.includes(type)) {
|
|
137
135
|
return getFormulaColumnFilterOptions(column);
|
|
138
136
|
}
|
|
139
137
|
if (type === _dtableUtils.CellType.LINK) {
|
|
@@ -206,17 +204,23 @@ const getFilterOptionsByArrayType = array_type => {
|
|
|
206
204
|
}
|
|
207
205
|
return filterOptions;
|
|
208
206
|
};
|
|
209
|
-
const getFilterByColumn = function (column) {
|
|
210
|
-
let
|
|
207
|
+
const getFilterByColumn = function (column, value) {
|
|
208
|
+
let {
|
|
209
|
+
textDefaultPredicate
|
|
210
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
211
|
+
let filter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
211
212
|
let {
|
|
212
213
|
type: columnType,
|
|
213
214
|
data: columnData
|
|
214
215
|
} = column;
|
|
215
216
|
let {
|
|
216
217
|
filterPredicateList
|
|
217
|
-
} = getColumnOptions(column);
|
|
218
|
+
} = getColumnOptions(column, value);
|
|
218
219
|
if (!filterPredicateList) return;
|
|
219
220
|
let filterPredicate = filterPredicateList[0];
|
|
221
|
+
if (textDefaultPredicate && columnType === _dtableUtils.CellType.TEXT && filterPredicateList.includes(textDefaultPredicate)) {
|
|
222
|
+
filterPredicate = textDefaultPredicate;
|
|
223
|
+
}
|
|
220
224
|
let updatedFilter = Object.assign({}, filter, {
|
|
221
225
|
column_key: column.key,
|
|
222
226
|
filter_predicate: filterPredicate
|
|
@@ -252,8 +256,8 @@ const getFilterByColumn = function (column) {
|
|
|
252
256
|
return updatedFilter;
|
|
253
257
|
}
|
|
254
258
|
// formula | link-formula
|
|
255
|
-
if (
|
|
256
|
-
const newUpdatedFilter = getFormulaColumnFilter(column, filter);
|
|
259
|
+
if (_constants.FORMULA_COLUMN_TYPES.includes(columnType)) {
|
|
260
|
+
const newUpdatedFilter = getFormulaColumnFilter(column, value, filter);
|
|
257
261
|
if (newUpdatedFilter) {
|
|
258
262
|
updatedFilter.filter_term = newUpdatedFilter.filter_term;
|
|
259
263
|
}
|
|
@@ -277,7 +281,7 @@ const getFilterByColumn = function (column) {
|
|
|
277
281
|
type: array_type,
|
|
278
282
|
data: array_data
|
|
279
283
|
};
|
|
280
|
-
const newUpdatedFilter = getFilterByColumn(linkedColumn, filter) || {};
|
|
284
|
+
const newUpdatedFilter = getFilterByColumn(linkedColumn, value, filter) || {};
|
|
281
285
|
if (newUpdatedFilter) {
|
|
282
286
|
updatedFilter.filter_term = newUpdatedFilter.filter_term;
|
|
283
287
|
}
|
|
@@ -287,7 +291,7 @@ const getFilterByColumn = function (column) {
|
|
|
287
291
|
return updatedFilter;
|
|
288
292
|
};
|
|
289
293
|
exports.getFilterByColumn = getFilterByColumn;
|
|
290
|
-
const getFormulaColumnFilter = (column, filter) => {
|
|
294
|
+
const getFormulaColumnFilter = (column, value, filter) => {
|
|
291
295
|
const {
|
|
292
296
|
data
|
|
293
297
|
} = column;
|
|
@@ -302,7 +306,7 @@ const getFormulaColumnFilter = (column, filter) => {
|
|
|
302
306
|
type: array_type,
|
|
303
307
|
data: array_data
|
|
304
308
|
};
|
|
305
|
-
return getFilterByColumn(linkedColumn, filter);
|
|
309
|
+
return getFilterByColumn(linkedColumn, value, filter);
|
|
306
310
|
}
|
|
307
311
|
// result_type: string | number | bool | date
|
|
308
312
|
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.BOOL) {
|
|
@@ -316,7 +320,7 @@ const getFormulaColumnFilter = (column, filter) => {
|
|
|
316
320
|
type: array_type,
|
|
317
321
|
data: array_data
|
|
318
322
|
};
|
|
319
|
-
return getFilterByColumn(linkedColumn, filter);
|
|
323
|
+
return getFilterByColumn(linkedColumn, value, filter);
|
|
320
324
|
};
|
|
321
325
|
|
|
322
326
|
// file, image : not support
|
|
@@ -324,12 +328,12 @@ const getFormulaColumnFilter = (column, filter) => {
|
|
|
324
328
|
// checkbox : boolean
|
|
325
329
|
// multiple-select, collaborator, creator, last modifier : array
|
|
326
330
|
exports.getFormulaColumnFilter = getFormulaColumnFilter;
|
|
327
|
-
const getUpdatedFilterByColumn = (filters, filterIndex, column) => {
|
|
331
|
+
const getUpdatedFilterByColumn = (filters, value, filterIndex, column) => {
|
|
328
332
|
const filter = filters[filterIndex];
|
|
329
333
|
if (filter.column_key === column.key) {
|
|
330
334
|
return;
|
|
331
335
|
}
|
|
332
|
-
return getFilterByColumn(column, filter);
|
|
336
|
+
return getFilterByColumn(column, value, filter);
|
|
333
337
|
};
|
|
334
338
|
exports.getUpdatedFilterByColumn = getUpdatedFilterByColumn;
|
|
335
339
|
const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
@@ -376,376 +380,96 @@ const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
|
376
380
|
return updatedFilter;
|
|
377
381
|
};
|
|
378
382
|
exports.getUpdatedFilterByPredicate = getUpdatedFilterByPredicate;
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
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;
|
|
383
|
+
const getUpdatedFilterByTermModifier = (filters, filterIndex, filterTermModifier) => {
|
|
384
|
+
const filter = filters[filterIndex];
|
|
385
|
+
if (filter.filter_term_modifier === filterTermModifier) {
|
|
386
|
+
return;
|
|
412
387
|
}
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
}
|
|
388
|
+
return Object.assign({}, filter, {
|
|
389
|
+
filter_term_modifier: filterTermModifier
|
|
430
390
|
});
|
|
431
|
-
return formulaFilters;
|
|
432
391
|
};
|
|
433
|
-
exports.
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return
|
|
392
|
+
exports.getUpdatedFilterByTermModifier = getUpdatedFilterByTermModifier;
|
|
393
|
+
const getUpdatedFilterByNormalTerm = (filters, column, filterIndex, event) => {
|
|
394
|
+
const filter = filters[filterIndex];
|
|
395
|
+
let filterTerm;
|
|
396
|
+
if (column.type === _dtableUtils.CellType.CHECKBOX) {
|
|
397
|
+
filterTerm = event.target.checked;
|
|
398
|
+
} else {
|
|
399
|
+
filterTerm = event.target.value;
|
|
400
|
+
}
|
|
401
|
+
if (filter.filter_term === filterTerm) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
return Object.assign({}, filter, {
|
|
405
|
+
filter_term: filterTerm
|
|
444
406
|
});
|
|
445
407
|
};
|
|
446
|
-
exports.
|
|
447
|
-
const
|
|
448
|
-
const
|
|
449
|
-
type,
|
|
450
|
-
filter_conjunction,
|
|
451
|
-
filters,
|
|
452
|
-
payload
|
|
453
|
-
} = operation;
|
|
408
|
+
exports.getUpdatedFilterByNormalTerm = getUpdatedFilterByNormalTerm;
|
|
409
|
+
const getUpdatedFilterBySpecialTerm = (filters, filterIndex, type, value) => {
|
|
410
|
+
const filter = filters[filterIndex];
|
|
454
411
|
switch (type) {
|
|
455
|
-
case _constants.
|
|
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:
|
|
412
|
+
case _constants.SPECIAL_TERM_TYPE.CREATOR:
|
|
466
413
|
{
|
|
467
|
-
|
|
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
|
-
};
|
|
414
|
+
return getUpdatedFilterByCreator(filter, value);
|
|
482
415
|
}
|
|
483
|
-
case _constants.
|
|
416
|
+
case _constants.SPECIAL_TERM_TYPE.SINGLE_SELECT:
|
|
484
417
|
{
|
|
485
|
-
|
|
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
|
-
};
|
|
418
|
+
return getUpdatedFilterBySelectSingle(filter, value);
|
|
501
419
|
}
|
|
502
|
-
case _constants.
|
|
420
|
+
case _constants.SPECIAL_TERM_TYPE.MULTIPLE_SELECT:
|
|
503
421
|
{
|
|
504
|
-
|
|
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
|
-
};
|
|
422
|
+
return getUpdatedFilterBySelectMultiple(filter, value);
|
|
567
423
|
}
|
|
568
|
-
case _constants.
|
|
424
|
+
case _constants.SPECIAL_TERM_TYPE.COLLABORATOR:
|
|
569
425
|
{
|
|
570
|
-
|
|
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
|
-
};
|
|
426
|
+
return getUpdatedFilterByCollaborator(filter, value);
|
|
591
427
|
}
|
|
592
|
-
case _constants.
|
|
428
|
+
case _constants.SPECIAL_TERM_TYPE.RATE:
|
|
593
429
|
{
|
|
594
|
-
|
|
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
|
-
};
|
|
430
|
+
return getUpdatedFilterByRate(filter, value);
|
|
656
431
|
}
|
|
657
432
|
default:
|
|
658
433
|
{
|
|
659
|
-
|
|
660
|
-
filter_conjunction,
|
|
661
|
-
filters
|
|
662
|
-
};
|
|
434
|
+
break;
|
|
663
435
|
}
|
|
664
436
|
}
|
|
665
437
|
};
|
|
666
|
-
exports.
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
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;
|
|
677
|
-
};
|
|
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;
|
|
438
|
+
exports.getUpdatedFilterBySpecialTerm = getUpdatedFilterBySpecialTerm;
|
|
439
|
+
const getColumnByKey = (columns, columnKey) => {
|
|
440
|
+
if (!Array.isArray(columns) || !columnKey) return null;
|
|
441
|
+
return columns.find(column => column.key === columnKey);
|
|
698
442
|
};
|
|
699
|
-
exports.
|
|
700
|
-
const
|
|
701
|
-
|
|
443
|
+
exports.getColumnByKey = getColumnByKey;
|
|
444
|
+
const isCheckboxColumn = column => {
|
|
445
|
+
let {
|
|
702
446
|
type,
|
|
703
447
|
data
|
|
704
448
|
} = column;
|
|
705
|
-
if (_dtableUtils.
|
|
706
|
-
return getFormulaColumnFilterOptions(column);
|
|
707
|
-
}
|
|
708
|
-
if (type === _dtableUtils.CellType.LINK) {
|
|
449
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
709
450
|
const {
|
|
451
|
+
result_type,
|
|
710
452
|
array_type
|
|
711
453
|
} = data || {};
|
|
712
|
-
if (
|
|
713
|
-
return _dtableUtils.
|
|
714
|
-
}
|
|
715
|
-
if (array_type === _dtableUtils.FORMULA_RESULT_TYPE.STRING) {
|
|
716
|
-
return _dtableUtils.FILTER_COLUMN_OPTIONS[_dtableUtils.CellType.TEXT];
|
|
454
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
455
|
+
return array_type === _dtableUtils.CellType.CHECKBOX;
|
|
717
456
|
}
|
|
718
|
-
return
|
|
457
|
+
return false;
|
|
719
458
|
}
|
|
720
|
-
return
|
|
459
|
+
return type === _dtableUtils.CellType.CHECKBOX;
|
|
721
460
|
};
|
|
722
|
-
exports.
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
if (index > -1) {
|
|
727
|
-
newFilterTerm.splice(index, 1);
|
|
728
|
-
} else {
|
|
729
|
-
newFilterTerm.push(option.id);
|
|
730
|
-
}
|
|
731
|
-
return newFilterTerm;
|
|
461
|
+
exports.isCheckboxColumn = isCheckboxColumn;
|
|
462
|
+
const getMediaUrl = () => {
|
|
463
|
+
var _window, _window$dtable, _window2, _window2$dtablePlugin;
|
|
464
|
+
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/';
|
|
732
465
|
};
|
|
733
|
-
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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;
|
|
466
|
+
const generateDefaultUser = name => {
|
|
467
|
+
const mediaUrl = getMediaUrl();
|
|
468
|
+
const defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
|
|
469
|
+
return {
|
|
470
|
+
name,
|
|
471
|
+
email: name,
|
|
472
|
+
avatar_url: defaultAvatarUrl
|
|
473
|
+
};
|
|
750
474
|
};
|
|
751
|
-
exports.
|
|
475
|
+
exports.generateDefaultUser = generateDefaultUser;
|
|
File without changes
|
|
@@ -10,6 +10,7 @@ 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");
|
|
13
14
|
class CollaboratorFilter extends _react.Component {
|
|
14
15
|
constructor(props) {
|
|
15
16
|
super(props);
|
|
@@ -62,9 +63,7 @@ class CollaboratorFilter extends _react.Component {
|
|
|
62
63
|
filterTerm,
|
|
63
64
|
collaborators,
|
|
64
65
|
placeholder,
|
|
65
|
-
filter_predicate
|
|
66
|
-
isInModal,
|
|
67
|
-
readonly
|
|
66
|
+
filter_predicate
|
|
68
67
|
} = this.props;
|
|
69
68
|
let isSupportMultipleSelect = this.supportMultipleSelectOptions.indexOf(filter_predicate) > -1 ? true : false;
|
|
70
69
|
let selectedCollaborators = Array.isArray(filterTerm) && filterTerm.length > 0 && filterTerm.map(item => {
|
|
@@ -104,12 +103,11 @@ class CollaboratorFilter extends _react.Component {
|
|
|
104
103
|
onSelectOption: this.props.onSelectCollaborator,
|
|
105
104
|
options: options,
|
|
106
105
|
placeholder: placeholder,
|
|
107
|
-
isLocked:
|
|
106
|
+
isLocked: this.props.isLocked,
|
|
108
107
|
supportMultipleSelect: isSupportMultipleSelect,
|
|
109
108
|
searchable: true,
|
|
110
109
|
searchPlaceholder: (0, _lang.getLocale)('Search_collaborator'),
|
|
111
|
-
isShowSelected: false
|
|
112
|
-
isInModal: isInModal
|
|
110
|
+
isShowSelected: false
|
|
113
111
|
});
|
|
114
112
|
}
|
|
115
113
|
}
|
|
@@ -13,11 +13,9 @@ 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"));
|
|
17
16
|
function DepartmentMultipleSelectFilter(props) {
|
|
18
17
|
const {
|
|
19
18
|
value,
|
|
20
|
-
isInModal,
|
|
21
19
|
departments
|
|
22
20
|
} = props;
|
|
23
21
|
const [isShowSelector, setIsShowSelector] = (0, _react.useState)(false);
|
|
@@ -41,7 +39,6 @@ function DepartmentMultipleSelectFilter(props) {
|
|
|
41
39
|
type: "checkbox",
|
|
42
40
|
className: "vam department-select-input",
|
|
43
41
|
checked: selectedDepartments.includes(type),
|
|
44
|
-
onClick: event => event.stopPropagation(),
|
|
45
42
|
onChange: event => selectDepartment(event, type)
|
|
46
43
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
47
44
|
className: "text-truncate department-name"
|
|
@@ -88,21 +85,13 @@ function DepartmentMultipleSelectFilter(props) {
|
|
|
88
85
|
className: "select-placeholder"
|
|
89
86
|
}, (0, _lang.getLocale)('Select_department')), /*#__PURE__*/_react.default.createElement("span", {
|
|
90
87
|
className: "dtable-font dtable-icon-down3"
|
|
91
|
-
})), isShowSelector &&
|
|
88
|
+
})), isShowSelector && /*#__PURE__*/_react.default.createElement(_DepartmentMultipleSelectEditor.default, {
|
|
92
89
|
isShowSelectedDepartments: false,
|
|
93
90
|
classNamePrefix: "filter",
|
|
94
91
|
value: selectedDepartments,
|
|
95
92
|
onCommit: selectDepartment,
|
|
96
93
|
renderUserDepartmentOptions: renderUserDepartmentOptions,
|
|
97
94
|
departments: departments
|
|
98
|
-
})
|
|
99
|
-
isInModal: isInModal,
|
|
100
|
-
isShowSelectedDepartments: false,
|
|
101
|
-
classNamePrefix: "filter",
|
|
102
|
-
value: selectedDepartments,
|
|
103
|
-
position: selectorRef.current.getBoundingClientRect(),
|
|
104
|
-
onCommit: selectDepartment,
|
|
105
|
-
renderUserDepartmentOptions: renderUserDepartmentOptions
|
|
106
|
-
})));
|
|
95
|
+
}));
|
|
107
96
|
}
|
|
108
97
|
var _default = exports.default = DepartmentMultipleSelectFilter;
|