dtable-utils 0.0.3-beta.1 → 0.0.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/dist/index.js +1 -1
- package/es/cell-value-get/cell-value.js +82 -60
- package/es/cell-value-get/collaborator.js +9 -2
- package/es/cell-value-get/duration.js +3 -3
- package/es/cell-value-get/geolocation.js +23 -25
- package/es/cell-value-get/number.js +19 -11
- package/es/cell-value-get/option.js +18 -4
- package/es/cell-value-get/rate.js +5 -0
- package/es/cell-value-set/date.js +9 -3
- package/es/{column/color.js → color/column-color.js} +25 -3
- package/es/{row/color.js → color/row-color.js} +12 -1
- package/es/column/option.js +37 -7
- package/es/common.js +23 -2
- package/es/constants/formula.js +2 -1
- package/es/filter/core.js +61 -26
- package/es/filter/filter-column/array.js +35 -30
- package/es/filter/filter-column/checkbox.js +9 -3
- package/es/filter/filter-column/collaborator.js +20 -15
- package/es/filter/filter-column/creator.js +22 -13
- package/es/filter/filter-column/date.js +57 -14
- package/es/filter/filter-column/digital-sign.js +11 -8
- package/es/filter/filter-column/file.js +9 -6
- package/es/filter/filter-column/formula.js +16 -8
- package/es/filter/filter-column/geolocation.js +12 -7
- package/es/filter/filter-column/link.js +10 -2
- package/es/filter/filter-column/long-text.js +10 -7
- package/es/filter/filter-column/multiple-select.js +17 -13
- package/es/filter/filter-column/number.js +25 -21
- package/es/filter/filter-column/single-select.js +14 -10
- package/es/filter/filter-column/text.js +18 -13
- package/es/filter/filter-row.js +35 -0
- package/es/group/core.js +15 -6
- package/es/group/group-row.js +39 -3
- package/es/index.js +10 -10
- package/es/link/core.js +14 -14
- package/es/number.js +11 -3
- package/es/row/core.js +20 -1
- package/es/sort/core.js +66 -7
- package/es/sort/sort-column/array.js +39 -30
- package/es/sort/sort-column/checkbox.js +12 -5
- package/es/sort/sort-column/collaborator.js +11 -4
- package/es/sort/sort-column/date.js +12 -12
- package/es/sort/sort-column/formula.js +21 -12
- package/es/sort/sort-column/link.js +18 -9
- package/es/sort/sort-column/multiple-select.js +26 -26
- package/es/sort/sort-column/number.js +15 -8
- package/es/sort/sort-column/single-select.js +16 -8
- package/es/sort/sort-column/text.js +24 -10
- package/es/sort/sort-row.js +22 -38
- package/es/table/column.js +2 -2
- package/es/table/core.js +2 -2
- package/es/table/row.js +4 -4
- package/es/view/core.js +20 -21
- package/es/view/formula.js +35 -31
- package/es/view/group.js +4 -4
- package/es/view/summaries.js +17 -29
- package/lib/cell-value-get/cell-value.js +82 -60
- package/lib/cell-value-get/collaborator.js +9 -2
- package/lib/cell-value-get/duration.js +4 -2
- package/lib/cell-value-get/geolocation.js +23 -25
- package/lib/cell-value-get/number.js +19 -11
- package/lib/cell-value-get/option.js +18 -4
- package/lib/cell-value-get/rate.js +5 -0
- package/lib/cell-value-set/date.js +9 -3
- package/lib/{column/color.js → color/column-color.js} +31 -9
- package/lib/{row/color.js → color/row-color.js} +12 -1
- package/lib/column/option.js +37 -7
- package/lib/common.js +23 -1
- package/lib/constants/formula.js +2 -0
- package/lib/filter/core.js +61 -26
- package/lib/filter/filter-column/array.js +35 -30
- package/lib/filter/filter-column/checkbox.js +9 -3
- package/lib/filter/filter-column/collaborator.js +20 -15
- package/lib/filter/filter-column/creator.js +22 -13
- package/lib/filter/filter-column/date.js +57 -14
- package/lib/filter/filter-column/digital-sign.js +11 -8
- package/lib/filter/filter-column/file.js +9 -6
- package/lib/filter/filter-column/formula.js +16 -8
- package/lib/filter/filter-column/geolocation.js +12 -7
- package/lib/filter/filter-column/link.js +10 -2
- package/lib/filter/filter-column/long-text.js +10 -7
- package/lib/filter/filter-column/multiple-select.js +17 -13
- package/lib/filter/filter-column/number.js +25 -21
- package/lib/filter/filter-column/single-select.js +14 -10
- package/lib/filter/filter-column/text.js +18 -13
- package/lib/filter/filter-row.js +35 -0
- package/lib/group/core.js +15 -6
- package/lib/group/group-row.js +39 -3
- package/lib/index.js +47 -45
- package/lib/link/core.js +14 -14
- package/lib/number.js +11 -3
- package/lib/row/core.js +20 -1
- package/lib/sort/core.js +71 -6
- package/lib/sort/sort-column/array.js +39 -30
- package/lib/sort/sort-column/checkbox.js +12 -5
- package/lib/sort/sort-column/collaborator.js +11 -4
- package/lib/sort/sort-column/date.js +12 -12
- package/lib/sort/sort-column/formula.js +21 -12
- package/lib/sort/sort-column/link.js +18 -9
- package/lib/sort/sort-column/multiple-select.js +25 -26
- package/lib/sort/sort-column/number.js +15 -8
- package/lib/sort/sort-column/single-select.js +16 -8
- package/lib/sort/sort-column/text.js +24 -10
- package/lib/sort/sort-row.js +21 -42
- package/lib/table/column.js +2 -2
- package/lib/table/core.js +2 -2
- package/lib/table/row.js +4 -4
- package/lib/view/core.js +20 -21
- package/lib/view/formula.js +35 -31
- package/lib/view/group.js +4 -4
- package/lib/view/summaries.js +17 -29
- package/package.json +1 -1
- package/es/table/index.js +0 -14
- package/lib/table/index.js +0 -18
package/lib/filter/filter-row.js
CHANGED
|
@@ -117,6 +117,17 @@ var getFilterResult = function getFilterResult(row, filter, _ref) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Filter row
|
|
123
|
+
* @param {object} row e.g. { _id, .... }
|
|
124
|
+
* @param {string} filterConjunction e.g. 'And' | 'Or'
|
|
125
|
+
* @param {array} filters e.g. [{ column_key, filter_predicate, ... }, ...]
|
|
126
|
+
* @param {object} formulaRow
|
|
127
|
+
* @param {string} username
|
|
128
|
+
* @param {string} userId
|
|
129
|
+
* @returns filter result, bool
|
|
130
|
+
*/
|
|
120
131
|
var filterRow = function filterRow(row, filterConjunction, filters) {
|
|
121
132
|
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
122
133
|
_ref2$formulaRow = _ref2.formulaRow,
|
|
@@ -144,6 +155,17 @@ var filterRow = function filterRow(row, filterConjunction, filters) {
|
|
|
144
155
|
}
|
|
145
156
|
return false;
|
|
146
157
|
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Filter rows
|
|
161
|
+
* @param {string} filterConjunction e.g. 'And' | 'Or'
|
|
162
|
+
* @param {array} filters e.g. [{ column_key, filter_predicate, ... }, ...]
|
|
163
|
+
* @param {array} rows e.g. [{ _id, .... }, ...]
|
|
164
|
+
* @param {object} formulaRows
|
|
165
|
+
* @param {string} username
|
|
166
|
+
* @param {userId} username
|
|
167
|
+
* @returns filtered rows ids, array
|
|
168
|
+
*/
|
|
147
169
|
var filterRows = function filterRows(filterConjunction, filters, rows, _ref3) {
|
|
148
170
|
var formulaRows = _ref3.formulaRows,
|
|
149
171
|
username = _ref3.username,
|
|
@@ -163,6 +185,19 @@ var filterRows = function filterRows(filterConjunction, filters, rows, _ref3) {
|
|
|
163
185
|
});
|
|
164
186
|
return filteredRows;
|
|
165
187
|
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Filter rows without formula calculation
|
|
191
|
+
* The "formulaRows" need to be provided if you want to filter formula, link columns etc.
|
|
192
|
+
* @param {string} filterConjunction e.g. 'And' | 'Or'
|
|
193
|
+
* @param {array} filters e.g. [{ column_key, filter_predicate, ... }, ...]
|
|
194
|
+
* @param {array} rows e.g. [{ _id, .... }, ...]
|
|
195
|
+
* @param {object} table e.g. { columns, ... }
|
|
196
|
+
* @param {object} formulaRows
|
|
197
|
+
* @param {string} username
|
|
198
|
+
* @param {userId} username
|
|
199
|
+
* @returns filtered rows: row_ids and error message: error_message, object
|
|
200
|
+
*/
|
|
166
201
|
var getFilteredRowsWithoutFormulaCalculation = function getFilteredRowsWithoutFormulaCalculation(filterConjunction, filters, rows, table) {
|
|
167
202
|
var _ref4 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
168
203
|
_ref4$formulaRows = _ref4.formulaRows,
|
package/lib/group/core.js
CHANGED
|
@@ -18,10 +18,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
18
|
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__default["default"](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; }
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {object} groupby { column_key
|
|
21
|
+
* Check is valid groupby
|
|
22
|
+
* @param {object} groupby e.g. { column_key, count_type, sort_type, ... }
|
|
23
23
|
* @param {array} columns
|
|
24
|
-
* @returns
|
|
24
|
+
* @returns bool
|
|
25
25
|
*/
|
|
26
26
|
var isValidGroupby = function isValidGroupby(groupby, columns) {
|
|
27
27
|
if (!groupby || !Array.isArray(columns)) return false;
|
|
@@ -36,10 +36,10 @@ var isValidGroupby = function isValidGroupby(groupby, columns) {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param {array} groupbys
|
|
39
|
+
* Get valid groupbys
|
|
40
|
+
* @param {array} groupbys e.g. [{ column_key, count_type, ... }, ...]
|
|
41
41
|
* @param {array} columns
|
|
42
|
-
* @returns array
|
|
42
|
+
* @returns valid groupbys, array
|
|
43
43
|
*/
|
|
44
44
|
var getValidGroupbys = function getValidGroupbys(groupbys, columns) {
|
|
45
45
|
if (!Array.isArray(groupbys) || !Array.isArray(columns)) {
|
|
@@ -49,6 +49,15 @@ var getValidGroupbys = function getValidGroupbys(groupbys, columns) {
|
|
|
49
49
|
return isValidGroupby(groupby, columns);
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get valid and formatted groupbys
|
|
55
|
+
* @param {array} groupbys e.g. [{ column_key, count_type, ... }, ...]
|
|
56
|
+
* @param {array} columns
|
|
57
|
+
* @param {object} currentTable e.g. { _id, ... }
|
|
58
|
+
* @param {object} value e.g. { tables, collaborators }
|
|
59
|
+
* @returns valid and formatted groupbys
|
|
60
|
+
*/
|
|
52
61
|
var deleteInvalidGroupby = function deleteInvalidGroupby(groupbys, columns, currentTable, value) {
|
|
53
62
|
var validGroupbys = getValidGroupbys(groupbys, columns);
|
|
54
63
|
var cleanGroupbys = [];
|
package/lib/group/group-row.js
CHANGED
|
@@ -320,6 +320,17 @@ var groupRowsWithMultipleGroupbys = function groupRowsWithMultipleGroupbys(group
|
|
|
320
320
|
groups = getSortedGroups(groups, validGroupbys, value, 0);
|
|
321
321
|
return groups;
|
|
322
322
|
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Group table rows
|
|
326
|
+
* @param {array} groupbys e.g. [{ column_key, count_type, column, ... }, ...]
|
|
327
|
+
* @param {array} rows e.g. [{ _id, ... }, ...]
|
|
328
|
+
* @param {object} formulaRows computed value of formula, link-formula, link etc.
|
|
329
|
+
* @param {object} value e.g. { collaborators, ... }
|
|
330
|
+
* @returns groups: [{
|
|
331
|
+
* cell_value, original_cell_value, column_key,
|
|
332
|
+
row_ids, subgroups, summaries, ...}, ...], array
|
|
333
|
+
*/
|
|
323
334
|
var groupTableRows = function groupTableRows(groupbys, rows, formulaRows, value) {
|
|
324
335
|
if (groupbys.length === 0) {
|
|
325
336
|
return [];
|
|
@@ -356,13 +367,38 @@ var groupTableRows = function groupTableRows(groupbys, rows, formulaRows, value)
|
|
|
356
367
|
groups = getSortedGroups(groups, groupbys, value, 0);
|
|
357
368
|
return groups;
|
|
358
369
|
};
|
|
359
|
-
|
|
360
|
-
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Group view rows
|
|
373
|
+
* @param {array} groupbys e.g. [{ column_key, count_type, column, ... }, ...]
|
|
374
|
+
* @param {object} table e.g. { id_row_map, ... }
|
|
375
|
+
* @param {array} rowsIds e.g. [ row._id, ...]
|
|
376
|
+
* @param {object} formulaRows computed value of formula, link-formula, link etc.
|
|
377
|
+
* @param {object} value e.g. { collaborators, ... }
|
|
378
|
+
* @returns groups: [{
|
|
379
|
+
* cell_value, original_cell_value, column_key,
|
|
380
|
+
row_ids, subgroups, summaries, ...}, ...], array
|
|
381
|
+
*/
|
|
382
|
+
var groupViewRows = function groupViewRows(groupbys, table, rowsIds, formulaRows, value) {
|
|
383
|
+
if (rowsIds.length === 0) {
|
|
361
384
|
return [];
|
|
362
385
|
}
|
|
363
|
-
var rowsData = row.getRowsByIds(table,
|
|
386
|
+
var rowsData = row.getRowsByIds(table, rowsIds);
|
|
364
387
|
return groupTableRows(groupbys, rowsData, formulaRows, value);
|
|
365
388
|
};
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Group rows
|
|
392
|
+
* The "formulaRows" must be supplied if you want group rows by formula/link-formula/link columns
|
|
393
|
+
* @param {array} groupbys e.g. [{ column_key, count_type, ... }, ...]
|
|
394
|
+
* @param {array} rows e.g. table rows: [{ _id, ... }, ...] | view rows: [ row._id, ...]
|
|
395
|
+
* @param {object} table e.g. { id_row_map, columns, ... }
|
|
396
|
+
* @param {object} value e.g. { collaborators, ... }
|
|
397
|
+
* @param {object} formulaRows computed value of formula, link-formula, link etc.
|
|
398
|
+
* @returns groups: [{
|
|
399
|
+
* cell_value, original_cell_value, column_key,
|
|
400
|
+
row_ids, subgroups, summaries, ...}, ...], array
|
|
401
|
+
*/
|
|
366
402
|
var getGroupedRowsWithoutFormulaCalculation = function getGroupedRowsWithoutFormulaCalculation(groupbys, rows, table, value) {
|
|
367
403
|
var _ref3 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
368
404
|
_ref3$formulaRows = _ref3.formulaRows,
|
package/lib/index.js
CHANGED
|
@@ -14,14 +14,15 @@ var reg = require('./constants/reg.js');
|
|
|
14
14
|
var color = require('./constants/color.js');
|
|
15
15
|
var gridHeader = require('./constants/grid-header.js');
|
|
16
16
|
var common = require('./common.js');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var core$1 = require('./
|
|
17
|
+
var core = require('./table/core.js');
|
|
18
|
+
var column$1 = require('./table/column.js');
|
|
19
|
+
var row = require('./table/row.js');
|
|
20
|
+
var core$1 = require('./row/core.js');
|
|
21
|
+
var core$2 = require('./view/core.js');
|
|
21
22
|
var summaries = require('./view/summaries.js');
|
|
22
23
|
var formula$1 = require('./view/formula.js');
|
|
23
24
|
var group$1 = require('./view/group.js');
|
|
24
|
-
var core$
|
|
25
|
+
var core$3 = require('./link/core.js');
|
|
25
26
|
var date = require('./cell-value-get/date.js');
|
|
26
27
|
var duration = require('./cell-value-get/duration.js');
|
|
27
28
|
var number = require('./cell-value-get/number.js');
|
|
@@ -37,13 +38,12 @@ var date$1 = require('./cell-value-set/date.js');
|
|
|
37
38
|
var option$1 = require('./column/option.js');
|
|
38
39
|
var date$2 = require('./column/date.js');
|
|
39
40
|
var number$2 = require('./column/number.js');
|
|
40
|
-
var color$2 = require('./column/color.js');
|
|
41
41
|
var date$3 = require('./date.js');
|
|
42
42
|
var number$3 = require('./number.js');
|
|
43
43
|
var filter = require('./validate/filter.js');
|
|
44
44
|
var email = require('./validate/email.js');
|
|
45
45
|
var geolocation$1 = require('./validate/geolocation.js');
|
|
46
|
-
var core$
|
|
46
|
+
var core$4 = require('./filter/core.js');
|
|
47
47
|
var checkbox = require('./filter/filter-column/checkbox.js');
|
|
48
48
|
var collaborator$1 = require('./filter/filter-column/collaborator.js');
|
|
49
49
|
var creator = require('./filter/filter-column/creator.js');
|
|
@@ -59,7 +59,7 @@ var number$4 = require('./filter/filter-column/number.js');
|
|
|
59
59
|
var singleSelect = require('./filter/filter-column/single-select.js');
|
|
60
60
|
var link = require('./filter/filter-column/link.js');
|
|
61
61
|
var filterRow = require('./filter/filter-row.js');
|
|
62
|
-
var core$
|
|
62
|
+
var core$5 = require('./sort/core.js');
|
|
63
63
|
var checkbox$1 = require('./sort/sort-column/checkbox.js');
|
|
64
64
|
var collaborator$2 = require('./sort/sort-column/collaborator.js');
|
|
65
65
|
var date$5 = require('./sort/sort-column/date.js');
|
|
@@ -71,15 +71,15 @@ var number$5 = require('./sort/sort-column/number.js');
|
|
|
71
71
|
var singleSelect$1 = require('./sort/sort-column/single-select.js');
|
|
72
72
|
var text$1 = require('./sort/sort-column/text.js');
|
|
73
73
|
var sortRow = require('./sort/sort-row.js');
|
|
74
|
-
var core$
|
|
74
|
+
var core$6 = require('./group/core.js');
|
|
75
75
|
var groupRow = require('./group/group-row.js');
|
|
76
76
|
var gradientColor = require('./color/gradient-color.js');
|
|
77
|
+
var columnColor = require('./color/column-color.js');
|
|
78
|
+
var rowColor = require('./color/row-color.js');
|
|
77
79
|
var filterColumnOptions = require('./constants/filter/filter-column-options.js');
|
|
78
80
|
var filterModifier = require('./constants/filter/filter-modifier.js');
|
|
79
81
|
var filterPredicate = require('./constants/filter/filter-predicate.js');
|
|
80
82
|
var filterIsWithin = require('./constants/filter/filter-is-within.js');
|
|
81
|
-
var column$1 = require('./table/column.js');
|
|
82
|
-
var row = require('./table/row.js');
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
@@ -105,6 +105,7 @@ exports.SINGLE_CELL_VALUE_COLUMN_TYPE_MAP = column.SINGLE_CELL_VALUE_COLUMN_TYPE
|
|
|
105
105
|
exports.UTC_FORMAT_DEFAULT = column.UTC_FORMAT_DEFAULT;
|
|
106
106
|
exports.FILTER_CONJUNCTION_TYPE = index.FILTER_CONJUNCTION_TYPE;
|
|
107
107
|
exports.FILTER_ERR_MSG = index.FILTER_ERR_MSG;
|
|
108
|
+
exports.DISPLAY_INTERNAL_ERRORS = formula.DISPLAY_INTERNAL_ERRORS;
|
|
108
109
|
exports.FORMULA_COLUMN_TYPES_MAP = formula.FORMULA_COLUMN_TYPES_MAP;
|
|
109
110
|
exports.FORMULA_RESULT_TYPE = formula.FORMULA_RESULT_TYPE;
|
|
110
111
|
exports.HIGHLIGHT_COLORS = selectOption.HIGHLIGHT_COLORS;
|
|
@@ -126,16 +127,20 @@ exports.COLOR_GRADATION_OPTIONS = color.COLOR_GRADATION_OPTIONS;
|
|
|
126
127
|
exports.HEADER_HEIGHT_TYPE = gridHeader.HEADER_HEIGHT_TYPE;
|
|
127
128
|
exports.generatorBase64Code = common.generatorBase64Code;
|
|
128
129
|
exports.isEmpty = common.isEmpty;
|
|
129
|
-
exports.
|
|
130
|
-
exports.
|
|
131
|
-
exports.
|
|
132
|
-
exports.
|
|
133
|
-
exports.
|
|
134
|
-
exports.
|
|
135
|
-
exports.
|
|
136
|
-
exports.
|
|
137
|
-
exports.
|
|
138
|
-
exports.
|
|
130
|
+
exports.isEmptyObject = common.isEmptyObject;
|
|
131
|
+
exports.getTableById = core.getTableById;
|
|
132
|
+
exports.getTableColumnByKey = column$1.getTableColumnByKey;
|
|
133
|
+
exports.getTableColumnByName = column$1.getTableColumnByName;
|
|
134
|
+
exports.getRowById = row.getRowById;
|
|
135
|
+
exports.getRowsByIds = row.getRowsByIds;
|
|
136
|
+
exports.convertRow = core$1.convertRow;
|
|
137
|
+
exports.isTableRows = core$1.isTableRows;
|
|
138
|
+
exports.getLinkColumnsUsedInFilters = core$2.getLinkColumnsUsedInFilters;
|
|
139
|
+
exports.getViewById = core$2.getViewById;
|
|
140
|
+
exports.isDefaultView = core$2.isDefaultView;
|
|
141
|
+
exports.isFilterView = core$2.isFilterView;
|
|
142
|
+
exports.isGroupView = core$2.isGroupView;
|
|
143
|
+
exports.isSortView = core$2.isSortView;
|
|
139
144
|
exports.getSummaries = summaries.getSummaries;
|
|
140
145
|
exports.getSummariesWithSubgroups = summaries.getSummariesWithSubgroups;
|
|
141
146
|
exports.updateGroupSummaries = summaries.updateGroupSummaries;
|
|
@@ -144,11 +149,11 @@ exports.getSortedFormulaColumns = formula$1.getSortedFormulaColumns;
|
|
|
144
149
|
exports.getSortedFormulaColumnsContainLinks = formula$1.getSortedFormulaColumnsContainLinks;
|
|
145
150
|
exports.transLink2LinkFormula = formula$1.transLink2LinkFormula;
|
|
146
151
|
exports.getGroupByPath = group$1.getGroupByPath;
|
|
147
|
-
exports.getLinkById = core$
|
|
148
|
-
exports.getLinkCellValue = core$
|
|
149
|
-
exports.getLinkTableID = core$
|
|
150
|
-
exports.getLinkedTableID = core$
|
|
151
|
-
exports.isValidLink = core$
|
|
152
|
+
exports.getLinkById = core$3.getLinkById;
|
|
153
|
+
exports.getLinkCellValue = core$3.getLinkCellValue;
|
|
154
|
+
exports.getLinkTableID = core$3.getLinkTableID;
|
|
155
|
+
exports.getLinkedTableID = core$3.getLinkedTableID;
|
|
156
|
+
exports.isValidLink = core$3.isValidLink;
|
|
152
157
|
exports.getDateDisplayString = date.getDateDisplayString;
|
|
153
158
|
exports.getDurationDisplayString = duration.getDurationDisplayString;
|
|
154
159
|
exports.getNumberDisplayString = number.getNumberDisplayString;
|
|
@@ -181,20 +186,19 @@ exports.getColumnOptions = option$1.getColumnOptions;
|
|
|
181
186
|
exports.isDateColumn = date$2.isDateColumn;
|
|
182
187
|
exports.isNumberColumn = number$2.isNumberColumn;
|
|
183
188
|
exports.isNumericColumn = number$2.isNumericColumn;
|
|
184
|
-
exports.ColumnColorUtils = color$2["default"];
|
|
185
189
|
exports.DateUtils = date$3.DateUtils;
|
|
186
190
|
exports.isNumber = number$3.isNumber;
|
|
187
191
|
exports.isNumberEqual = number$3.isNumberEqual;
|
|
188
192
|
exports.ValidateFilter = filter.ValidateFilter;
|
|
189
193
|
exports.isValidEmail = email.isValidEmail;
|
|
190
194
|
exports.isValidPosition = geolocation$1.isValidPosition;
|
|
191
|
-
exports.deleteInvalidFilter = core$
|
|
192
|
-
exports.getFormattedFilter = core$
|
|
193
|
-
exports.getFormattedFilterOtherDate = core$
|
|
194
|
-
exports.getFormattedFilters = core$
|
|
195
|
-
exports.getValidFilters = core$
|
|
196
|
-
exports.getValidFiltersWithoutError = core$
|
|
197
|
-
exports.otherDate = core$
|
|
195
|
+
exports.deleteInvalidFilter = core$4.deleteInvalidFilter;
|
|
196
|
+
exports.getFormattedFilter = core$4.getFormattedFilter;
|
|
197
|
+
exports.getFormattedFilterOtherDate = core$4.getFormattedFilterOtherDate;
|
|
198
|
+
exports.getFormattedFilters = core$4.getFormattedFilters;
|
|
199
|
+
exports.getValidFilters = core$4.getValidFilters;
|
|
200
|
+
exports.getValidFiltersWithoutError = core$4.getValidFiltersWithoutError;
|
|
201
|
+
exports.otherDate = core$4.otherDate;
|
|
198
202
|
exports.checkboxFilter = checkbox.checkboxFilter;
|
|
199
203
|
exports.collaboratorFilter = collaborator$1.collaboratorFilter;
|
|
200
204
|
exports.creatorFilter = creator.creatorFilter;
|
|
@@ -212,30 +216,32 @@ exports.linkFilter = link.linkFilter;
|
|
|
212
216
|
exports.filterRow = filterRow.filterRow;
|
|
213
217
|
exports.filterRows = filterRow.filterRows;
|
|
214
218
|
exports.getFilteredRowsWithoutFormulaCalculation = filterRow.getFilteredRowsWithoutFormulaCalculation;
|
|
215
|
-
exports.
|
|
216
|
-
exports.
|
|
219
|
+
exports.deleteInvalidSort = core$5.deleteInvalidSort;
|
|
220
|
+
exports.getMultipleIndexesOrderbyOptions = core$5.getMultipleIndexesOrderbyOptions;
|
|
221
|
+
exports.getValidSorts = core$5.getValidSorts;
|
|
222
|
+
exports.isValidSort = core$5.isValidSort;
|
|
217
223
|
exports.sortCheckbox = checkbox$1.sortCheckbox;
|
|
218
224
|
exports.sortCollaborator = collaborator$2.sortCollaborator;
|
|
219
225
|
exports.sortDate = date$5.sortDate;
|
|
220
226
|
exports.sortByArrayType = array.sortByArrayType;
|
|
221
227
|
exports.sortFormula = formula$3.sortFormula;
|
|
222
228
|
exports.sortLink = link$1.sortLink;
|
|
223
|
-
exports.getMultipleIndexesOrderbyOptions = multipleSelect$1.getMultipleIndexesOrderbyOptions;
|
|
224
229
|
exports.sortMultipleSelect = multipleSelect$1.sortMultipleSelect;
|
|
225
230
|
exports.sortNumber = number$5.sortNumber;
|
|
226
231
|
exports.sortSingleSelect = singleSelect$1.sortSingleSelect;
|
|
227
232
|
exports.compareString = text$1.compareString;
|
|
228
233
|
exports.sortText = text$1.sortText;
|
|
229
|
-
exports.deleteInvalidSort = sortRow.deleteInvalidSort;
|
|
230
234
|
exports.sortRowsWithMultiSorts = sortRow.sortRowsWithMultiSorts;
|
|
231
235
|
exports.sortTableRows = sortRow.sortTableRows;
|
|
232
|
-
exports.deleteInvalidGroupby = core$
|
|
233
|
-
exports.getValidGroupbys = core$
|
|
234
|
-
exports.isValidGroupby = core$
|
|
236
|
+
exports.deleteInvalidGroupby = core$6.deleteInvalidGroupby;
|
|
237
|
+
exports.getValidGroupbys = core$6.getValidGroupbys;
|
|
238
|
+
exports.isValidGroupby = core$6.isValidGroupby;
|
|
235
239
|
exports.getGroupedRowsWithoutFormulaCalculation = groupRow.getGroupedRowsWithoutFormulaCalculation;
|
|
236
240
|
exports.groupTableRows = groupRow.groupTableRows;
|
|
237
241
|
exports.groupViewRows = groupRow.groupViewRows;
|
|
238
242
|
exports.GradientColorUtils = gradientColor["default"];
|
|
243
|
+
exports.ColumnColorUtils = columnColor["default"];
|
|
244
|
+
exports.RowColorUtils = rowColor["default"];
|
|
239
245
|
exports.FILTER_COLUMN_OPTIONS = filterColumnOptions.FILTER_COLUMN_OPTIONS;
|
|
240
246
|
exports.FILTER_TERM_MODIFIER_SHOW = filterModifier.FILTER_TERM_MODIFIER_SHOW;
|
|
241
247
|
exports.FILTER_TERM_MODIFIER_TYPE = filterModifier.FILTER_TERM_MODIFIER_TYPE;
|
|
@@ -243,7 +249,3 @@ exports.FILTER_PREDICATE_SHOW = filterPredicate.FILTER_PREDICATE_SHOW;
|
|
|
243
249
|
exports.FILTER_PREDICATE_TYPE = filterPredicate.FILTER_PREDICATE_TYPE;
|
|
244
250
|
exports.filterTermModifierIsWithin = filterIsWithin.filterTermModifierIsWithin;
|
|
245
251
|
exports.filterTermModifierNotWithin = filterIsWithin.filterTermModifierNotWithin;
|
|
246
|
-
exports.getTableColumnByKey = column$1.getTableColumnByKey;
|
|
247
|
-
exports.getTableColumnByName = column$1.getTableColumnByName;
|
|
248
|
-
exports.getRowById = row.getRowById;
|
|
249
|
-
exports.getRowsByIds = row.getRowsByIds;
|
package/lib/link/core.js
CHANGED
|
@@ -9,10 +9,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {array} links [{ _id, ... }]
|
|
12
|
+
* Get link by id
|
|
13
|
+
* @param {array} links e.g. [{ _id, ... }, ...]
|
|
14
14
|
* @param {string} linkId
|
|
15
|
-
* @returns object
|
|
15
|
+
* @returns link, object
|
|
16
16
|
*/
|
|
17
17
|
var getLinkById = function getLinkById(links, linkId) {
|
|
18
18
|
if (!Array.isArray(links) || !linkId) return null;
|
|
@@ -22,9 +22,9 @@ var getLinkById = function getLinkById(links, linkId) {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {object} columnData
|
|
27
|
-
* @returns
|
|
25
|
+
* Check is valid link
|
|
26
|
+
* @param {object} columnData
|
|
27
|
+
* @returns bool
|
|
28
28
|
*/
|
|
29
29
|
var isValidLink = function isValidLink(linkColumnData) {
|
|
30
30
|
if (!linkColumnData) return false;
|
|
@@ -36,35 +36,35 @@ var isValidLink = function isValidLink(linkColumnData) {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Get current table id by link relationship
|
|
40
40
|
* @param {string} currentTableID
|
|
41
41
|
* @param {string} tableID
|
|
42
42
|
* @param {string} otherTableID
|
|
43
|
-
* @returns string
|
|
43
|
+
* @returns current table id, string
|
|
44
44
|
*/
|
|
45
45
|
var getLinkTableID = function getLinkTableID(currentTableID, tableID, otherTableID) {
|
|
46
46
|
return currentTableID === tableID ? tableID : otherTableID;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Get linked table id by link relationship
|
|
51
51
|
* @param {string} currentTableID
|
|
52
52
|
* @param {string} tableID
|
|
53
53
|
* @param {string} otherTableID
|
|
54
|
-
* @returns string
|
|
54
|
+
* @returns linked table id, string
|
|
55
55
|
*/
|
|
56
56
|
var getLinkedTableID = function getLinkedTableID(currentTableID, tableID, otherTableID) {
|
|
57
57
|
return currentTableID === tableID ? otherTableID : tableID;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {array} links [ { _id
|
|
63
|
-
* @param {string}
|
|
61
|
+
* Get linked rows ids by the given row id
|
|
62
|
+
* @param {array} links e.g. [ { _id, table1_id, table2_id, table1_table2_map, table2_table1_map, ... }, ... ]
|
|
63
|
+
* @param {string} linkId
|
|
64
64
|
* @param {string} table1Id
|
|
65
65
|
* @param {string} table2Id
|
|
66
66
|
* @param {string} rowId
|
|
67
|
-
* @returns
|
|
67
|
+
* @returns linked rows ids, array
|
|
68
68
|
*/
|
|
69
69
|
var getLinkCellValue = function getLinkCellValue(links, linkId, table1Id, table2Id, rowId) {
|
|
70
70
|
if (!Array.isArray(links) || links.length === 0 || !table1Id || !table2Id || !rowId) return [];
|
package/lib/number.js
CHANGED
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Check whether is number
|
|
7
7
|
* @param {number} number
|
|
8
8
|
* @returns boolean
|
|
9
9
|
*/
|
|
10
10
|
var isNumber = function isNumber(number) {
|
|
11
11
|
return (number || number === 0) && Object.prototype.toString.call(number) === '[object Number]';
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Check whether the numbers is equal
|
|
16
|
+
* Two numbers are considered equal if the absolute value of their difference is less than 0.00001
|
|
17
|
+
* @param {number} leftNumber
|
|
18
|
+
* @param {number} rightNumber
|
|
19
|
+
* @returns bool
|
|
20
|
+
*/
|
|
21
|
+
var isNumberEqual = function isNumberEqual(leftNumber, rightNumber) {
|
|
22
|
+
return leftNumber === rightNumber || Math.abs(leftNumber - rightNumber) < 0.00001;
|
|
15
23
|
};
|
|
16
24
|
|
|
17
25
|
exports.isNumber = isNumber;
|
package/lib/row/core.js
CHANGED
|
@@ -6,6 +6,7 @@ var _typeof = require('@babel/runtime/helpers/typeof');
|
|
|
6
6
|
var cellValue = require('../cell-value-get/cell-value.js');
|
|
7
7
|
require('dayjs');
|
|
8
8
|
require('../constants/column.js');
|
|
9
|
+
require('../constants/formula.js');
|
|
9
10
|
var option = require('../cell-value-get/option.js');
|
|
10
11
|
require('../constants/group.js');
|
|
11
12
|
var core = require('../link/core.js');
|
|
@@ -17,9 +18,27 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
18
|
|
|
18
19
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Check is table rows
|
|
23
|
+
* @param {array} rows e.g. table rows: [{ _id, xxx }, ...] | view rows: [ row._id, ... ]
|
|
24
|
+
* @returns bool
|
|
25
|
+
*/
|
|
20
26
|
var isTableRows = function isTableRows(rows) {
|
|
21
27
|
return Array.isArray(rows) && _typeof__default["default"](rows[0]) === 'object';
|
|
22
28
|
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Convert row
|
|
32
|
+
* e.g. { '0000': 'a' } to { 'Name': 'a' }
|
|
33
|
+
* @param {object} row
|
|
34
|
+
* @param {object} value e.g. { links, ... }
|
|
35
|
+
* @param {object} table e.g. { _id, columns, ... }
|
|
36
|
+
* @param {object} view e.g. { hidden_columns, ... }
|
|
37
|
+
* @param {object} formulaResults computed value of formula, link-formula, link etc.
|
|
38
|
+
* @param {bool} convertLinkID use to convert link: get linked from formulaResults if true, otherwise get linked from links
|
|
39
|
+
* @param {func} debug use to debug if supplied
|
|
40
|
+
* @returns converted row, object
|
|
41
|
+
*/
|
|
23
42
|
var convertRow = function convertRow(row, value, table, view, formulaResults, convertLinkID) {
|
|
24
43
|
var _ref = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {},
|
|
25
44
|
debug = _ref.debug;
|
|
@@ -102,7 +121,7 @@ var convertRow = function convertRow(row, value, table, view, formulaResults, co
|
|
|
102
121
|
// get values form formulaResults
|
|
103
122
|
var formulaRow = formulaResults && formulaResults[row._id];
|
|
104
123
|
var cellResult = formulaRow && formulaRow[key];
|
|
105
|
-
if (!
|
|
124
|
+
if (!Array.isArray(cellResult) || cellResult.length === 0) {
|
|
106
125
|
result[columnName] = null;
|
|
107
126
|
break;
|
|
108
127
|
}
|
package/lib/sort/core.js
CHANGED
|
@@ -2,13 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var option = require('../column/option.js');
|
|
7
|
+
var cellType = require('../constants/cell-type.js');
|
|
5
8
|
var sort = require('../constants/sort.js');
|
|
6
9
|
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
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__default["default"](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; }
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {object} sort e.g. { column_key
|
|
18
|
+
* Check is valid sort
|
|
19
|
+
* @param {object} sort e.g. { column_key, sort_type, ... }
|
|
10
20
|
* @param {array} columns
|
|
11
|
-
* @returns
|
|
21
|
+
* @returns bool
|
|
12
22
|
*/
|
|
13
23
|
var isValidSort = function isValidSort(sort$1, columns) {
|
|
14
24
|
var sortByColumn = sort$1 && columns.find(function (column) {
|
|
@@ -19,12 +29,12 @@ var isValidSort = function isValidSort(sort$1, columns) {
|
|
|
19
29
|
};
|
|
20
30
|
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
32
|
+
* Get valid sorts
|
|
23
33
|
* 1. sort column is exist or not
|
|
24
34
|
* 2. valid sort type
|
|
25
|
-
* @param {array} sorts
|
|
35
|
+
* @param {array} sorts e.g. [{ column_key, sort_type, ... }, ...]
|
|
26
36
|
* @param {array} columns
|
|
27
|
-
* @returns array
|
|
37
|
+
* @returns valid sorts, array
|
|
28
38
|
*/
|
|
29
39
|
var getValidSorts = function getValidSorts(sorts, columns) {
|
|
30
40
|
if (!Array.isArray(sorts) || !Array.isArray(columns)) return [];
|
|
@@ -33,5 +43,60 @@ var getValidSorts = function getValidSorts(sorts, columns) {
|
|
|
33
43
|
});
|
|
34
44
|
};
|
|
35
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Get sorted option index of the "optionIds"
|
|
48
|
+
* @param {array} optionIds
|
|
49
|
+
* @param {object} option_id_index_map e.g. {[option.id]: 0, ...}
|
|
50
|
+
* @returns sorted options index, array
|
|
51
|
+
*/
|
|
52
|
+
var getMultipleIndexesOrderbyOptions = function getMultipleIndexesOrderbyOptions(optionIds, option_id_index_map) {
|
|
53
|
+
var indexArr = [];
|
|
54
|
+
optionIds.forEach(function (optionId) {
|
|
55
|
+
var index = option_id_index_map[optionId];
|
|
56
|
+
if (index > -1) {
|
|
57
|
+
indexArr.push(index);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return indexArr.sort();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get valid and formatted sorts
|
|
65
|
+
* @param {array} sorts e.g. [{ column_key, sort_type, ... }, ...]
|
|
66
|
+
* @param {array} columns
|
|
67
|
+
* @returns valid and formatted sorts, array
|
|
68
|
+
*/
|
|
69
|
+
var deleteInvalidSort = function deleteInvalidSort(sorts, columns) {
|
|
70
|
+
var validSorts = getValidSorts(sorts, columns);
|
|
71
|
+
var cleanSorts = [];
|
|
72
|
+
validSorts.forEach(function (sort) {
|
|
73
|
+
var column_key = sort.column_key;
|
|
74
|
+
var sortColumn = columns.find(function (column) {
|
|
75
|
+
return column.key === column_key;
|
|
76
|
+
});
|
|
77
|
+
var columnType = sortColumn.type;
|
|
78
|
+
var newSort = _objectSpread(_objectSpread({}, sort), {}, {
|
|
79
|
+
column: sortColumn
|
|
80
|
+
});
|
|
81
|
+
switch (columnType) {
|
|
82
|
+
case cellType.CellType.SINGLE_SELECT:
|
|
83
|
+
case cellType.CellType.MULTIPLE_SELECT:
|
|
84
|
+
{
|
|
85
|
+
var options = option.getColumnOptions(sortColumn);
|
|
86
|
+
var option_id_index_map = {};
|
|
87
|
+
options.forEach(function (option, index) {
|
|
88
|
+
option_id_index_map[option.id] = index;
|
|
89
|
+
});
|
|
90
|
+
newSort.option_id_index_map = option_id_index_map;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
cleanSorts.push(newSort);
|
|
95
|
+
});
|
|
96
|
+
return cleanSorts;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.deleteInvalidSort = deleteInvalidSort;
|
|
100
|
+
exports.getMultipleIndexesOrderbyOptions = getMultipleIndexesOrderbyOptions;
|
|
36
101
|
exports.getValidSorts = getValidSorts;
|
|
37
102
|
exports.isValidSort = isValidSort;
|