dtable-utils 0.0.3-beta.1 → 0.0.3
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/README.md +2 -30
- package/dist/index.js +1 -1
- package/es/cell-value-get/cell-value.js +19 -227
- package/es/cell-value-get/collaborator.js +3 -9
- package/es/cell-value-get/digital-sign.js +1 -1
- package/es/cell-value-get/duration.js +1 -1
- package/es/cell-value-get/geolocation.js +5 -29
- package/es/cell-value-get/long-text.js +1 -1
- package/es/cell-value-get/number.js +18 -42
- package/es/cell-value-get/option.js +7 -17
- package/es/cell-value-set/number.js +1 -53
- package/es/column/{core.js → common.js} +14 -2
- package/es/column/date.js +1 -1
- package/es/column/number.js +1 -1
- package/es/common.js +10 -9
- package/es/constants/column.js +2 -127
- package/es/constants/filter/index.js +1 -5
- package/es/date.js +1 -1
- package/es/index.js +10 -62
- package/es/validate/filter.js +1 -1
- package/lib/cell-value-get/cell-value.js +18 -231
- package/lib/cell-value-get/collaborator.js +2 -9
- package/lib/cell-value-get/digital-sign.js +1 -1
- package/lib/cell-value-get/duration.js +1 -0
- package/lib/cell-value-get/geolocation.js +5 -30
- package/lib/cell-value-get/long-text.js +1 -1
- package/lib/cell-value-get/number.js +17 -42
- package/lib/cell-value-get/option.js +6 -18
- package/lib/cell-value-set/number.js +0 -53
- package/lib/column/{core.js → common.js} +14 -1
- package/lib/column/date.js +2 -2
- package/lib/column/number.js +3 -3
- package/lib/common.js +11 -13
- package/lib/constants/column.js +1 -134
- package/lib/constants/filter/index.js +0 -5
- package/lib/index.js +8 -176
- package/lib/validate/filter.js +3 -3
- package/package.json +3 -5
- package/es/cell-value-get/rate.js +0 -6
- package/es/cell-value-set/date.js +0 -20
- package/es/color/gradient-color.js +0 -100
- package/es/column/color.js +0 -415
- package/es/column/option.js +0 -115
- package/es/constants/color.js +0 -16
- package/es/constants/column-permission.js +0 -7
- package/es/constants/grid-header.js +0 -6
- package/es/constants/group.js +0 -23
- package/es/constants/limit.js +0 -3
- package/es/constants/reg.js +0 -4
- package/es/constants/row-color.js +0 -11
- package/es/constants/sort.js +0 -11
- package/es/filter/core.js +0 -287
- package/es/filter/filter-column/array.js +0 -82
- package/es/filter/filter-column/checkbox.js +0 -8
- package/es/filter/filter-column/collaborator.js +0 -67
- package/es/filter/filter-column/creator.js +0 -50
- package/es/filter/filter-column/date.js +0 -59
- package/es/filter/filter-column/digital-sign.js +0 -26
- package/es/filter/filter-column/file.js +0 -24
- package/es/filter/filter-column/formula.js +0 -49
- package/es/filter/filter-column/geolocation.js +0 -53
- package/es/filter/filter-column/link.js +0 -12
- package/es/filter/filter-column/long-text.js +0 -25
- package/es/filter/filter-column/multiple-select.js +0 -60
- package/es/filter/filter-column/number.js +0 -93
- package/es/filter/filter-column/single-select.js +0 -41
- package/es/filter/filter-column/text.js +0 -55
- package/es/filter/filter-row.js +0 -198
- package/es/group/core.js +0 -107
- package/es/group/group-row.js +0 -366
- package/es/link/core.js +0 -78
- package/es/number.js +0 -13
- package/es/row/color.js +0 -278
- package/es/row/core.js +0 -161
- package/es/sort/core.js +0 -32
- package/es/sort/sort-column/array.js +0 -63
- package/es/sort/sort-column/checkbox.js +0 -15
- package/es/sort/sort-column/collaborator.js +0 -9
- package/es/sort/sort-column/date.js +0 -25
- package/es/sort/sort-column/formula.js +0 -40
- package/es/sort/sort-column/link.js +0 -23
- package/es/sort/sort-column/multiple-select.js +0 -45
- package/es/sort/sort-column/number.js +0 -18
- package/es/sort/sort-column/single-select.js +0 -22
- package/es/sort/sort-column/text.js +0 -47
- package/es/sort/sort-row.js +0 -126
- package/es/table/column.js +0 -27
- package/es/table/core.js +0 -14
- package/es/table/index.js +0 -14
- package/es/table/row.js +0 -25
- package/es/validate/geolocation.js +0 -5
- package/es/view/core.js +0 -135
- package/es/view/formula.js +0 -143
- package/es/view/group.js +0 -32
- package/es/view/summaries.js +0 -179
- package/lib/cell-value-get/rate.js +0 -10
- package/lib/cell-value-set/date.js +0 -24
- package/lib/color/gradient-color.js +0 -110
- package/lib/column/color.js +0 -424
- package/lib/column/option.js +0 -123
- package/lib/constants/color.js +0 -20
- package/lib/constants/column-permission.js +0 -11
- package/lib/constants/grid-header.js +0 -10
- package/lib/constants/group.js +0 -36
- package/lib/constants/limit.js +0 -7
- package/lib/constants/reg.js +0 -9
- package/lib/constants/row-color.js +0 -17
- package/lib/constants/sort.js +0 -18
- package/lib/filter/core.js +0 -301
- package/lib/filter/filter-column/array.js +0 -86
- package/lib/filter/filter-column/checkbox.js +0 -12
- package/lib/filter/filter-column/collaborator.js +0 -75
- package/lib/filter/filter-column/creator.js +0 -54
- package/lib/filter/filter-column/date.js +0 -63
- package/lib/filter/filter-column/digital-sign.js +0 -30
- package/lib/filter/filter-column/file.js +0 -28
- package/lib/filter/filter-column/formula.js +0 -53
- package/lib/filter/filter-column/geolocation.js +0 -57
- package/lib/filter/filter-column/link.js +0 -16
- package/lib/filter/filter-column/long-text.js +0 -29
- package/lib/filter/filter-column/multiple-select.js +0 -68
- package/lib/filter/filter-column/number.js +0 -97
- package/lib/filter/filter-column/single-select.js +0 -45
- package/lib/filter/filter-column/text.js +0 -59
- package/lib/filter/filter-row.js +0 -204
- package/lib/group/core.js +0 -117
- package/lib/group/group-row.js +0 -377
- package/lib/link/core.js +0 -90
- package/lib/number.js +0 -18
- package/lib/row/color.js +0 -286
- package/lib/row/core.js +0 -170
- package/lib/sort/core.js +0 -37
- package/lib/sort/sort-column/array.js +0 -67
- package/lib/sort/sort-column/checkbox.js +0 -19
- package/lib/sort/sort-column/collaborator.js +0 -13
- package/lib/sort/sort-column/date.js +0 -29
- package/lib/sort/sort-column/formula.js +0 -44
- package/lib/sort/sort-column/link.js +0 -27
- package/lib/sort/sort-column/multiple-select.js +0 -50
- package/lib/sort/sort-column/number.js +0 -22
- package/lib/sort/sort-column/single-select.js +0 -26
- package/lib/sort/sort-column/text.js +0 -52
- package/lib/sort/sort-row.js +0 -136
- package/lib/table/column.js +0 -32
- package/lib/table/core.js +0 -18
- package/lib/table/index.js +0 -18
- package/lib/table/row.js +0 -30
- package/lib/validate/geolocation.js +0 -9
- package/lib/view/core.js +0 -144
- package/lib/view/formula.js +0 -150
- package/lib/view/group.js +0 -36
- package/lib/view/summaries.js +0 -185
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { numberFilter } from './number.js';
|
|
2
|
-
import { dateFilter } from './date.js';
|
|
3
|
-
import { checkboxFilter } from './checkbox.js';
|
|
4
|
-
import { textFilter } from './text.js';
|
|
5
|
-
import { filterByArrayType } from './array.js';
|
|
6
|
-
import { getFormulaDisplayString } from '../../cell-value-get/cell-value.js';
|
|
7
|
-
import { FORMULA_RESULT_TYPE } from '../../constants/formula.js';
|
|
8
|
-
|
|
9
|
-
var formulaFilter = function formulaFilter(cellValue, filter, _ref) {
|
|
10
|
-
var username = _ref.username,
|
|
11
|
-
userId = _ref.userId;
|
|
12
|
-
var data = filter.column.data;
|
|
13
|
-
var _ref2 = data || {},
|
|
14
|
-
result_type = _ref2.result_type;
|
|
15
|
-
switch (result_type) {
|
|
16
|
-
case FORMULA_RESULT_TYPE.NUMBER:
|
|
17
|
-
{
|
|
18
|
-
return numberFilter(cellValue, filter);
|
|
19
|
-
}
|
|
20
|
-
case FORMULA_RESULT_TYPE.DATE:
|
|
21
|
-
{
|
|
22
|
-
return dateFilter(cellValue, filter);
|
|
23
|
-
}
|
|
24
|
-
case FORMULA_RESULT_TYPE.BOOL:
|
|
25
|
-
{
|
|
26
|
-
var normalizedCellValue = cellValue;
|
|
27
|
-
if (cellValue === 'true') {
|
|
28
|
-
normalizedCellValue = true;
|
|
29
|
-
} else if (cellValue === 'false') {
|
|
30
|
-
normalizedCellValue = false;
|
|
31
|
-
}
|
|
32
|
-
return checkboxFilter(normalizedCellValue, filter);
|
|
33
|
-
}
|
|
34
|
-
case FORMULA_RESULT_TYPE.ARRAY:
|
|
35
|
-
{
|
|
36
|
-
return filterByArrayType(cellValue, filter, {
|
|
37
|
-
username: username,
|
|
38
|
-
userId: userId
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
default:
|
|
42
|
-
{
|
|
43
|
-
// FORMULA_RESULT_TYPE.STRING
|
|
44
|
-
return textFilter(getFormulaDisplayString(cellValue, data) || '', filter, userId);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export { formulaFilter };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { getGeolocationDisplayString } from '../../cell-value-get/geolocation.js';
|
|
2
|
-
import '../../constants/filter/filter-column-options.js';
|
|
3
|
-
import '../../constants/filter/filter-modifier.js';
|
|
4
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
5
|
-
import '../../constants/filter/filter-is-within.js';
|
|
6
|
-
|
|
7
|
-
var geolocationFilter = function geolocationFilter(cellValue, _ref) {
|
|
8
|
-
var filter_predicate = _ref.filter_predicate,
|
|
9
|
-
filter_term = _ref.filter_term,
|
|
10
|
-
column = _ref.column;
|
|
11
|
-
var geolocation = getGeolocationDisplayString(cellValue, column.data);
|
|
12
|
-
switch (filter_predicate) {
|
|
13
|
-
case FILTER_PREDICATE_TYPE.CONTAINS:
|
|
14
|
-
{
|
|
15
|
-
if (!filter_term) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
if (!geolocation) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return geolocation.toString().toLowerCase().indexOf(filter_term.toLowerCase()) > -1;
|
|
22
|
-
}
|
|
23
|
-
case FILTER_PREDICATE_TYPE.NOT_CONTAIN:
|
|
24
|
-
{
|
|
25
|
-
if (!filter_term || !geolocation) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return geolocation.toString().toLowerCase().indexOf(filter_term.toLowerCase()) < 0;
|
|
29
|
-
}
|
|
30
|
-
case FILTER_PREDICATE_TYPE.IS:
|
|
31
|
-
{
|
|
32
|
-
return !filter_term || geolocation === filter_term;
|
|
33
|
-
}
|
|
34
|
-
case FILTER_PREDICATE_TYPE.IS_NOT:
|
|
35
|
-
{
|
|
36
|
-
return !filter_term || geolocation !== filter_term;
|
|
37
|
-
}
|
|
38
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
39
|
-
{
|
|
40
|
-
return geolocation ? false : true;
|
|
41
|
-
}
|
|
42
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
43
|
-
{
|
|
44
|
-
return geolocation ? true : false;
|
|
45
|
-
}
|
|
46
|
-
default:
|
|
47
|
-
{
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { geolocationFilter };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { filterByArrayType } from './array.js';
|
|
2
|
-
|
|
3
|
-
var linkFilter = function linkFilter(cellValue, filter, _ref) {
|
|
4
|
-
var username = _ref.username,
|
|
5
|
-
userId = _ref.userId;
|
|
6
|
-
return filterByArrayType(cellValue, filter, {
|
|
7
|
-
username: username,
|
|
8
|
-
userId: userId
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { linkFilter };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import '../../constants/filter/filter-column-options.js';
|
|
2
|
-
import '../../constants/filter/filter-modifier.js';
|
|
3
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
4
|
-
import '../../constants/filter/filter-is-within.js';
|
|
5
|
-
|
|
6
|
-
var longTextFilter = function longTextFilter(cellValue, _ref) {
|
|
7
|
-
var filter_predicate = _ref.filter_predicate;
|
|
8
|
-
var text = cellValue ? cellValue.text : null;
|
|
9
|
-
switch (filter_predicate) {
|
|
10
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
11
|
-
{
|
|
12
|
-
return text ? false : true;
|
|
13
|
-
}
|
|
14
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
15
|
-
{
|
|
16
|
-
return text ? true : false;
|
|
17
|
-
}
|
|
18
|
-
default:
|
|
19
|
-
{
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export { longTextFilter };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
-
import '../../constants/filter/filter-column-options.js';
|
|
3
|
-
import '../../constants/filter/filter-modifier.js';
|
|
4
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
5
|
-
import '../../constants/filter/filter-is-within.js';
|
|
6
|
-
|
|
7
|
-
var multipleSelectFilter = function multipleSelectFilter(cellValue, _ref) {
|
|
8
|
-
var filter_predicate = _ref.filter_predicate,
|
|
9
|
-
filter_term = _ref.filter_term;
|
|
10
|
-
switch (filter_predicate) {
|
|
11
|
-
case FILTER_PREDICATE_TYPE.HAS_ANY_OF:
|
|
12
|
-
{
|
|
13
|
-
return filter_term.length === 0 || Array.isArray(cellValue) && cellValue.some(function (optionId) {
|
|
14
|
-
return filter_term.includes(optionId);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
case FILTER_PREDICATE_TYPE.HAS_ALL_OF:
|
|
18
|
-
{
|
|
19
|
-
return filter_term.length === 0 || Array.isArray(cellValue) && filter_term.every(function (optionId) {
|
|
20
|
-
return cellValue.includes(optionId);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
case FILTER_PREDICATE_TYPE.HAS_NONE_OF:
|
|
24
|
-
{
|
|
25
|
-
if (filter_term.length === 0 || !Array.isArray(cellValue) || cellValue.length === 0) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return filter_term.every(function (optionId) {
|
|
29
|
-
return cellValue.indexOf(optionId) < 0;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
case FILTER_PREDICATE_TYPE.IS_EXACTLY:
|
|
33
|
-
{
|
|
34
|
-
if (filter_term.length === 0) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (!Array.isArray(cellValue)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
var uniqueArr = function uniqueArr(arr) {
|
|
41
|
-
return _toConsumableArray(new Set(arr)).sort();
|
|
42
|
-
};
|
|
43
|
-
return uniqueArr(cellValue).toString() === uniqueArr(filter_term).toString();
|
|
44
|
-
}
|
|
45
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
46
|
-
{
|
|
47
|
-
return !Array.isArray(cellValue) || cellValue.length === 0;
|
|
48
|
-
}
|
|
49
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
50
|
-
{
|
|
51
|
-
return Array.isArray(cellValue) && cellValue.length > 0;
|
|
52
|
-
}
|
|
53
|
-
default:
|
|
54
|
-
{
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export { multipleSelectFilter };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { isNumberEqual } from '../../number.js';
|
|
2
|
-
import '../../constants/filter/filter-column-options.js';
|
|
3
|
-
import '../../constants/filter/filter-modifier.js';
|
|
4
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
5
|
-
import '../../constants/filter/filter-is-within.js';
|
|
6
|
-
|
|
7
|
-
var numberFilter = function numberFilter(cellValue, _ref) {
|
|
8
|
-
var filter_predicate = _ref.filter_predicate,
|
|
9
|
-
filter_term = _ref.filter_term;
|
|
10
|
-
switch (filter_predicate) {
|
|
11
|
-
case FILTER_PREDICATE_TYPE.EQUAL:
|
|
12
|
-
{
|
|
13
|
-
if (!filter_term && filter_term !== 0) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (!cellValue && cellValue !== 0) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return isNumberEqual(filter_term, cellValue);
|
|
20
|
-
}
|
|
21
|
-
case FILTER_PREDICATE_TYPE.NOT_EQUAL:
|
|
22
|
-
{
|
|
23
|
-
if (!filter_term && filter_term !== 0 || !cellValue && cellValue !== 0) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return !isNumberEqual(filter_term, cellValue);
|
|
27
|
-
}
|
|
28
|
-
case FILTER_PREDICATE_TYPE.LESS:
|
|
29
|
-
{
|
|
30
|
-
if (!filter_term && filter_term !== 0) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (!cellValue && cellValue !== 0 || isNumberEqual(cellValue, filter_term)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return cellValue < filter_term;
|
|
37
|
-
}
|
|
38
|
-
case FILTER_PREDICATE_TYPE.GREATER:
|
|
39
|
-
{
|
|
40
|
-
if (!filter_term && filter_term !== 0) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
if (!cellValue && cellValue !== 0 || isNumberEqual(cellValue, filter_term)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return cellValue > filter_term;
|
|
47
|
-
}
|
|
48
|
-
case FILTER_PREDICATE_TYPE.LESS_OR_EQUAL:
|
|
49
|
-
{
|
|
50
|
-
if (!filter_term && filter_term !== 0) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (!cellValue && cellValue !== 0) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
if (isNumberEqual(cellValue, filter_term)) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return cellValue < filter_term;
|
|
60
|
-
}
|
|
61
|
-
case FILTER_PREDICATE_TYPE.GREATER_OR_EQUAL:
|
|
62
|
-
{
|
|
63
|
-
if (!filter_term && filter_term !== 0) {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
if (!cellValue && cellValue !== 0) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return isNumberEqual(cellValue, filter_term) || cellValue > filter_term;
|
|
70
|
-
}
|
|
71
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
72
|
-
{
|
|
73
|
-
if (cellValue === 0) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return !cellValue || typeof cellValue !== 'number';
|
|
77
|
-
}
|
|
78
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
79
|
-
{
|
|
80
|
-
// must be a number
|
|
81
|
-
if (cellValue === 0) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
return cellValue && typeof cellValue === 'number' ? true : false;
|
|
85
|
-
}
|
|
86
|
-
default:
|
|
87
|
-
{
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export { numberFilter };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import '../../constants/filter/filter-column-options.js';
|
|
2
|
-
import '../../constants/filter/filter-modifier.js';
|
|
3
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
4
|
-
import '../../constants/filter/filter-is-within.js';
|
|
5
|
-
|
|
6
|
-
var singleSelectFilter = function singleSelectFilter(cellValue, _ref) {
|
|
7
|
-
var filter_predicate = _ref.filter_predicate,
|
|
8
|
-
filter_term = _ref.filter_term;
|
|
9
|
-
switch (filter_predicate) {
|
|
10
|
-
case FILTER_PREDICATE_TYPE.IS:
|
|
11
|
-
{
|
|
12
|
-
return !filter_term || cellValue === filter_term;
|
|
13
|
-
}
|
|
14
|
-
case FILTER_PREDICATE_TYPE.IS_NOT:
|
|
15
|
-
{
|
|
16
|
-
return !filter_term || cellValue !== filter_term;
|
|
17
|
-
}
|
|
18
|
-
case FILTER_PREDICATE_TYPE.IS_ANY_OF:
|
|
19
|
-
{
|
|
20
|
-
return filter_term.length === 0 || filter_term.includes(cellValue);
|
|
21
|
-
}
|
|
22
|
-
case FILTER_PREDICATE_TYPE.IS_NONE_OF:
|
|
23
|
-
{
|
|
24
|
-
return filter_term.length === 0 || filter_term.indexOf(cellValue) < 0;
|
|
25
|
-
}
|
|
26
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
27
|
-
{
|
|
28
|
-
return cellValue ? false : true;
|
|
29
|
-
}
|
|
30
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
31
|
-
{
|
|
32
|
-
return cellValue ? true : false;
|
|
33
|
-
}
|
|
34
|
-
default:
|
|
35
|
-
{
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { singleSelectFilter };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import '../../constants/filter/filter-column-options.js';
|
|
2
|
-
import '../../constants/filter/filter-modifier.js';
|
|
3
|
-
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
4
|
-
import '../../constants/filter/filter-is-within.js';
|
|
5
|
-
|
|
6
|
-
var textFilter = function textFilter(cellValue, _ref, userId) {
|
|
7
|
-
var filter_predicate = _ref.filter_predicate,
|
|
8
|
-
filter_term = _ref.filter_term;
|
|
9
|
-
switch (filter_predicate) {
|
|
10
|
-
case FILTER_PREDICATE_TYPE.CONTAINS:
|
|
11
|
-
{
|
|
12
|
-
if (!filter_term) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
if (!cellValue) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return cellValue.toString().toLowerCase().indexOf(filter_term.toLowerCase()) > -1;
|
|
19
|
-
}
|
|
20
|
-
case FILTER_PREDICATE_TYPE.NOT_CONTAIN:
|
|
21
|
-
{
|
|
22
|
-
if (!filter_term || !cellValue) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return cellValue.toString().toLowerCase().indexOf(filter_term.toLowerCase()) < 0;
|
|
26
|
-
}
|
|
27
|
-
case FILTER_PREDICATE_TYPE.IS:
|
|
28
|
-
{
|
|
29
|
-
return !filter_term || cellValue === filter_term;
|
|
30
|
-
}
|
|
31
|
-
case FILTER_PREDICATE_TYPE.IS_NOT:
|
|
32
|
-
{
|
|
33
|
-
return !filter_term || cellValue !== filter_term;
|
|
34
|
-
}
|
|
35
|
-
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
36
|
-
{
|
|
37
|
-
return cellValue ? false : true;
|
|
38
|
-
}
|
|
39
|
-
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
|
|
40
|
-
{
|
|
41
|
-
return cellValue ? true : false;
|
|
42
|
-
}
|
|
43
|
-
case FILTER_PREDICATE_TYPE.IS_CURRENT_USER_ID:
|
|
44
|
-
{
|
|
45
|
-
if (!userId) return false;
|
|
46
|
-
return cellValue === userId;
|
|
47
|
-
}
|
|
48
|
-
default:
|
|
49
|
-
{
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { textFilter };
|
package/es/filter/filter-row.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { getFormattedFilters, deleteInvalidFilter } from './core.js';
|
|
2
|
-
import { checkboxFilter } from './filter-column/checkbox.js';
|
|
3
|
-
import { collaboratorFilter } from './filter-column/collaborator.js';
|
|
4
|
-
import { creatorFilter } from './filter-column/creator.js';
|
|
5
|
-
import { dateFilter } from './filter-column/date.js';
|
|
6
|
-
import { digitalSignFilter } from './filter-column/digital-sign.js';
|
|
7
|
-
import { fileFilter } from './filter-column/file.js';
|
|
8
|
-
import { formulaFilter } from './filter-column/formula.js';
|
|
9
|
-
import { geolocationFilter } from './filter-column/geolocation.js';
|
|
10
|
-
import { textFilter } from './filter-column/text.js';
|
|
11
|
-
import { longTextFilter } from './filter-column/long-text.js';
|
|
12
|
-
import { multipleSelectFilter } from './filter-column/multiple-select.js';
|
|
13
|
-
import { numberFilter } from './filter-column/number.js';
|
|
14
|
-
import { singleSelectFilter } from './filter-column/single-select.js';
|
|
15
|
-
import { linkFilter } from './filter-column/link.js';
|
|
16
|
-
import { FILTER_CONJUNCTION_TYPE } from '../constants/filter/index.js';
|
|
17
|
-
import { DateUtils } from '../date.js';
|
|
18
|
-
import { CellType } from '../constants/cell-type.js';
|
|
19
|
-
import { DATE_FORMAT_MAP } from '../constants/column.js';
|
|
20
|
-
|
|
21
|
-
var getFilterResult = function getFilterResult(row, filter, _ref) {
|
|
22
|
-
var formulaRow = _ref.formulaRow,
|
|
23
|
-
username = _ref.username,
|
|
24
|
-
userId = _ref.userId;
|
|
25
|
-
var column_key = filter.column_key,
|
|
26
|
-
column = filter.column;
|
|
27
|
-
var cellValue = row[column_key];
|
|
28
|
-
switch (column.type) {
|
|
29
|
-
case CellType.CHECKBOX:
|
|
30
|
-
{
|
|
31
|
-
return checkboxFilter(cellValue, filter);
|
|
32
|
-
}
|
|
33
|
-
case CellType.SINGLE_SELECT:
|
|
34
|
-
{
|
|
35
|
-
return singleSelectFilter(cellValue, filter);
|
|
36
|
-
}
|
|
37
|
-
case CellType.MULTIPLE_SELECT:
|
|
38
|
-
{
|
|
39
|
-
return multipleSelectFilter(cellValue, filter);
|
|
40
|
-
}
|
|
41
|
-
case CellType.DURATION:
|
|
42
|
-
case CellType.NUMBER:
|
|
43
|
-
case CellType.RATE:
|
|
44
|
-
{
|
|
45
|
-
return numberFilter(cellValue, filter);
|
|
46
|
-
}
|
|
47
|
-
case CellType.DATE:
|
|
48
|
-
{
|
|
49
|
-
return dateFilter(cellValue, filter);
|
|
50
|
-
}
|
|
51
|
-
case CellType.CTIME:
|
|
52
|
-
case CellType.MTIME:
|
|
53
|
-
{
|
|
54
|
-
cellValue = DateUtils.format(cellValue, DATE_FORMAT_MAP.YYYY_MM_DD_HH_MM_SS);
|
|
55
|
-
return dateFilter(cellValue, filter);
|
|
56
|
-
}
|
|
57
|
-
case CellType.COLLABORATOR:
|
|
58
|
-
{
|
|
59
|
-
return collaboratorFilter(cellValue, filter, username);
|
|
60
|
-
}
|
|
61
|
-
case CellType.LONG_TEXT:
|
|
62
|
-
{
|
|
63
|
-
return longTextFilter(cellValue, filter);
|
|
64
|
-
}
|
|
65
|
-
case CellType.TEXT:
|
|
66
|
-
case CellType.AUTO_NUMBER:
|
|
67
|
-
case CellType.EMAIL:
|
|
68
|
-
case CellType.URL:
|
|
69
|
-
{
|
|
70
|
-
return textFilter(cellValue, filter, userId);
|
|
71
|
-
}
|
|
72
|
-
case CellType.IMAGE:
|
|
73
|
-
case CellType.FILE:
|
|
74
|
-
{
|
|
75
|
-
return fileFilter(cellValue, filter);
|
|
76
|
-
}
|
|
77
|
-
case CellType.LAST_MODIFIER:
|
|
78
|
-
case CellType.CREATOR:
|
|
79
|
-
{
|
|
80
|
-
return creatorFilter(cellValue, filter, username);
|
|
81
|
-
}
|
|
82
|
-
case CellType.GEOLOCATION:
|
|
83
|
-
{
|
|
84
|
-
return geolocationFilter(cellValue, filter);
|
|
85
|
-
}
|
|
86
|
-
case CellType.FORMULA:
|
|
87
|
-
case CellType.LINK_FORMULA:
|
|
88
|
-
{
|
|
89
|
-
cellValue = formulaRow[column_key];
|
|
90
|
-
return formulaFilter(cellValue, filter, {
|
|
91
|
-
username: username,
|
|
92
|
-
userId: userId
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
case CellType.LINK:
|
|
96
|
-
{
|
|
97
|
-
cellValue = formulaRow[column_key];
|
|
98
|
-
cellValue = Array.isArray(cellValue) ? cellValue.map(function (linked) {
|
|
99
|
-
return linked.display_value;
|
|
100
|
-
}) : null;
|
|
101
|
-
return linkFilter(cellValue, filter, {
|
|
102
|
-
username: username,
|
|
103
|
-
userId: userId
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
case CellType.DIGITAL_SIGN:
|
|
107
|
-
{
|
|
108
|
-
return digitalSignFilter(cellValue, filter);
|
|
109
|
-
}
|
|
110
|
-
default:
|
|
111
|
-
{
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
var filterRow = function filterRow(row, filterConjunction, filters) {
|
|
117
|
-
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
118
|
-
_ref2$formulaRow = _ref2.formulaRow,
|
|
119
|
-
formulaRow = _ref2$formulaRow === void 0 ? {} : _ref2$formulaRow,
|
|
120
|
-
_ref2$username = _ref2.username,
|
|
121
|
-
username = _ref2$username === void 0 ? '' : _ref2$username,
|
|
122
|
-
userId = _ref2.userId;
|
|
123
|
-
if (filterConjunction === FILTER_CONJUNCTION_TYPE.AND) {
|
|
124
|
-
return filters.every(function (filter) {
|
|
125
|
-
return getFilterResult(row, filter, {
|
|
126
|
-
formulaRow: formulaRow,
|
|
127
|
-
username: username,
|
|
128
|
-
userId: userId
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (filterConjunction === FILTER_CONJUNCTION_TYPE.OR) {
|
|
133
|
-
return filters.some(function (filter) {
|
|
134
|
-
return getFilterResult(row, filter, {
|
|
135
|
-
formulaRow: formulaRow,
|
|
136
|
-
username: username,
|
|
137
|
-
userId: userId
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
};
|
|
143
|
-
var filterRows = function filterRows(filterConjunction, filters, rows, _ref3) {
|
|
144
|
-
var formulaRows = _ref3.formulaRows,
|
|
145
|
-
username = _ref3.username,
|
|
146
|
-
userId = _ref3.userId;
|
|
147
|
-
var filteredRows = [];
|
|
148
|
-
var formattedFilters = getFormattedFilters(filters);
|
|
149
|
-
rows.forEach(function (row) {
|
|
150
|
-
var rowId = row._id;
|
|
151
|
-
var formulaRow = formulaRows && formulaRows[rowId] ? formulaRows[rowId] : {};
|
|
152
|
-
if (filterRow(row, filterConjunction, formattedFilters, {
|
|
153
|
-
formulaRow: formulaRow,
|
|
154
|
-
username: username,
|
|
155
|
-
userId: userId
|
|
156
|
-
})) {
|
|
157
|
-
filteredRows.push(rowId);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return filteredRows;
|
|
161
|
-
};
|
|
162
|
-
var getFilteredRowsWithoutFormulaCalculation = function getFilteredRowsWithoutFormulaCalculation(filterConjunction, filters, rows, table) {
|
|
163
|
-
var _ref4 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
164
|
-
_ref4$formulaRows = _ref4.formulaRows,
|
|
165
|
-
formulaRows = _ref4$formulaRows === void 0 ? null : _ref4$formulaRows,
|
|
166
|
-
_ref4$username = _ref4.username,
|
|
167
|
-
username = _ref4$username === void 0 ? null : _ref4$username,
|
|
168
|
-
_ref4$userId = _ref4.userId,
|
|
169
|
-
userId = _ref4$userId === void 0 ? null : _ref4$userId;
|
|
170
|
-
var columns = table.columns;
|
|
171
|
-
var validFilters = [];
|
|
172
|
-
try {
|
|
173
|
-
validFilters = deleteInvalidFilter(filters, columns);
|
|
174
|
-
} catch (err) {
|
|
175
|
-
return {
|
|
176
|
-
row_ids: [],
|
|
177
|
-
error_message: err.message
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
var filteredRows = [];
|
|
181
|
-
if (validFilters.length === 0) {
|
|
182
|
-
filteredRows = rows.map(function (row) {
|
|
183
|
-
return row._id;
|
|
184
|
-
});
|
|
185
|
-
} else {
|
|
186
|
-
filteredRows = filterRows(filterConjunction, validFilters, rows, {
|
|
187
|
-
formulaRows: formulaRows,
|
|
188
|
-
username: username,
|
|
189
|
-
userId: userId
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
row_ids: filteredRows,
|
|
194
|
-
error_message: null
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export { filterRow, filterRows, getFilteredRowsWithoutFormulaCalculation };
|
package/es/group/core.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { isDateColumn } from '../column/date.js';
|
|
3
|
-
import { getLinkedTableID } from '../link/core.js';
|
|
4
|
-
import { getTableColumnByKey } from '../table/column.js';
|
|
5
|
-
import { getTableById } from '../table/core.js';
|
|
6
|
-
import { CellType } from '../constants/cell-type.js';
|
|
7
|
-
import { SUPPORT_GROUP_COLUMN_TYPES, GROUP_DATE_GRANULARITY, GROUP_GEOLOCATION_GRANULARITY } from '../constants/group.js';
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* check is valid groupby
|
|
14
|
-
* @param {object} groupby { column_key: '', count_type: '', sort_type: '' }
|
|
15
|
-
* @param {array} columns
|
|
16
|
-
* @returns boolean
|
|
17
|
-
*/
|
|
18
|
-
var isValidGroupby = function isValidGroupby(groupby, columns) {
|
|
19
|
-
if (!groupby || !Array.isArray(columns)) return false;
|
|
20
|
-
var column_key = groupby.column_key;
|
|
21
|
-
var groupbyColumn = columns.find(function (column) {
|
|
22
|
-
return column.key === column_key;
|
|
23
|
-
});
|
|
24
|
-
if (!groupbyColumn) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return SUPPORT_GROUP_COLUMN_TYPES.includes(groupbyColumn.type);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* get valid groupbys
|
|
32
|
-
* @param {array} groupbys
|
|
33
|
-
* @param {array} columns
|
|
34
|
-
* @returns array
|
|
35
|
-
*/
|
|
36
|
-
var getValidGroupbys = function getValidGroupbys(groupbys, columns) {
|
|
37
|
-
if (!Array.isArray(groupbys) || !Array.isArray(columns)) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
return groupbys.filter(function (groupby) {
|
|
41
|
-
return isValidGroupby(groupby, columns);
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var deleteInvalidGroupby = function deleteInvalidGroupby(groupbys, columns, currentTable, value) {
|
|
45
|
-
var validGroupbys = getValidGroupbys(groupbys, columns);
|
|
46
|
-
var cleanGroupbys = [];
|
|
47
|
-
validGroupbys.forEach(function (groupby) {
|
|
48
|
-
var groupbyColumnKey = groupby.column_key,
|
|
49
|
-
count_type = groupby.count_type;
|
|
50
|
-
var groupbyColumn = columns.find(function (column) {
|
|
51
|
-
return groupbyColumnKey === column.key;
|
|
52
|
-
});
|
|
53
|
-
var columnType = groupbyColumn.type,
|
|
54
|
-
columnData = groupbyColumn.data;
|
|
55
|
-
var newGroupby = _objectSpread(_objectSpread({}, groupby), {}, {
|
|
56
|
-
column: groupbyColumn
|
|
57
|
-
});
|
|
58
|
-
switch (columnType) {
|
|
59
|
-
case CellType.DATE:
|
|
60
|
-
case CellType.CTIME:
|
|
61
|
-
case CellType.MTIME:
|
|
62
|
-
{
|
|
63
|
-
newGroupby.count_type = count_type || GROUP_DATE_GRANULARITY.MONTH;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case CellType.GEOLOCATION:
|
|
67
|
-
{
|
|
68
|
-
newGroupby.count_type = count_type || GROUP_GEOLOCATION_GRANULARITY.PROVINCE;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case CellType.COLLABORATOR:
|
|
72
|
-
{
|
|
73
|
-
var collaborator_email_map = {};
|
|
74
|
-
value.collaborators.forEach(function (collaborator) {
|
|
75
|
-
collaborator_email_map[collaborator.email] = true;
|
|
76
|
-
});
|
|
77
|
-
newGroupby.collaborator_email_map = collaborator_email_map;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case CellType.LINK:
|
|
81
|
-
{
|
|
82
|
-
var table_id = columnData.table_id,
|
|
83
|
-
other_table_id = columnData.other_table_id,
|
|
84
|
-
display_column_key = columnData.display_column_key;
|
|
85
|
-
var currentTableId = currentTable ? currentTable._id : '';
|
|
86
|
-
var linkedTableID = getLinkedTableID(currentTableId, table_id, other_table_id);
|
|
87
|
-
var linkedTable = getTableById(value.tables, linkedTableID);
|
|
88
|
-
var displayColumn = getTableColumnByKey(linkedTable, display_column_key);
|
|
89
|
-
newGroupby.linked_table = linkedTable;
|
|
90
|
-
newGroupby.display_column = displayColumn;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
case CellType.FORMULA:
|
|
94
|
-
case CellType.LINK_FORMULA:
|
|
95
|
-
{
|
|
96
|
-
if (isDateColumn(groupbyColumn) && !count_type) {
|
|
97
|
-
newGroupby.count_type = GROUP_DATE_GRANULARITY.MONTH;
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
cleanGroupbys.push(newGroupby);
|
|
103
|
-
});
|
|
104
|
-
return cleanGroupbys;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export { deleteInvalidGroupby, getValidGroupbys, isValidGroupby };
|