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
|
@@ -21,24 +21,32 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
21
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
22
|
|
|
23
23
|
var ARRAY_VALUE_COLUMN_TYPES = [cellType.CellType.IMAGE, cellType.CellType.FILE, cellType.CellType.MULTIPLE_SELECT, cellType.CellType.COLLABORATOR];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* the helper of 'getCellValueStringResult'
|
|
27
|
+
* @param {any} cellValue
|
|
28
|
+
* @param {object} column
|
|
29
|
+
* @param {array} collaborators
|
|
30
|
+
* @param {bool} isArchiveView
|
|
31
|
+
* @returns formatted array cell value, string
|
|
32
|
+
*/
|
|
24
33
|
var _getArrayColumnCellValue = function _getArrayColumnCellValue(cellValue, column, _ref) {
|
|
25
34
|
var collaborators = _ref.collaborators,
|
|
26
35
|
isArchiveView = _ref.isArchiveView;
|
|
27
|
-
if (!
|
|
36
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0 || !column.data) {
|
|
28
37
|
return '';
|
|
29
38
|
}
|
|
30
39
|
var key = column.key,
|
|
31
40
|
data = column.data;
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
array_data = _ref2.array_data;
|
|
41
|
+
var array_type = data.array_type,
|
|
42
|
+
array_data = data.array_data;
|
|
35
43
|
var newColumn = {
|
|
36
44
|
key: key,
|
|
37
45
|
type: array_type,
|
|
38
46
|
data: array_data
|
|
39
47
|
};
|
|
40
48
|
// cellValue itself is an array
|
|
41
|
-
if (
|
|
49
|
+
if (ARRAY_VALUE_COLUMN_TYPES.includes(array_type)) {
|
|
42
50
|
return getCellValueStringResult(_defineProperty__default["default"]({}, key, cellValue), newColumn, {
|
|
43
51
|
collaborators: collaborators
|
|
44
52
|
});
|
|
@@ -134,16 +142,16 @@ var getFormulaDisplayString = function getFormulaDisplayString(cellValue, column
|
|
|
134
142
|
* @returns formatted cell value, string|array
|
|
135
143
|
*/
|
|
136
144
|
var getCellValueDisplayString = function getCellValueDisplayString(row, type, key) {
|
|
137
|
-
var
|
|
138
|
-
data =
|
|
139
|
-
|
|
140
|
-
formulaRows =
|
|
141
|
-
|
|
142
|
-
collaborators =
|
|
143
|
-
|
|
144
|
-
isBaiduMap =
|
|
145
|
-
|
|
146
|
-
geolocationHyphen =
|
|
145
|
+
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
146
|
+
data = _ref2.data,
|
|
147
|
+
_ref2$formulaRows = _ref2.formulaRows,
|
|
148
|
+
formulaRows = _ref2$formulaRows === void 0 ? {} : _ref2$formulaRows,
|
|
149
|
+
_ref2$collaborators = _ref2.collaborators,
|
|
150
|
+
collaborators = _ref2$collaborators === void 0 ? [] : _ref2$collaborators,
|
|
151
|
+
_ref2$isBaiduMap = _ref2.isBaiduMap,
|
|
152
|
+
isBaiduMap = _ref2$isBaiduMap === void 0 ? true : _ref2$isBaiduMap,
|
|
153
|
+
_ref2$geolocationHyph = _ref2.geolocationHyphen,
|
|
154
|
+
geolocationHyphen = _ref2$geolocationHyph === void 0 ? '' : _ref2$geolocationHyph;
|
|
147
155
|
if (!row) return '';
|
|
148
156
|
var cellValue = row[key];
|
|
149
157
|
switch (type) {
|
|
@@ -180,9 +188,9 @@ var getCellValueDisplayString = function getCellValueDisplayString(row, type, ke
|
|
|
180
188
|
}
|
|
181
189
|
case cellType.CellType.DATE:
|
|
182
190
|
{
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
format =
|
|
191
|
+
var _ref3 = data || {},
|
|
192
|
+
_ref3$format = _ref3.format,
|
|
193
|
+
format = _ref3$format === void 0 ? column.DEFAULT_DATE_FORMAT : _ref3$format;
|
|
186
194
|
return date.getDateDisplayString(cellValue, format);
|
|
187
195
|
}
|
|
188
196
|
case cellType.CellType.CTIME:
|
|
@@ -202,7 +210,8 @@ var getCellValueDisplayString = function getCellValueDisplayString(row, type, ke
|
|
|
202
210
|
case cellType.CellType.FORMULA:
|
|
203
211
|
case cellType.CellType.LINK_FORMULA:
|
|
204
212
|
{
|
|
205
|
-
var formulaRow = formulaRows[row._id]
|
|
213
|
+
var formulaRow = formulaRows && formulaRows[row._id];
|
|
214
|
+
if (!formulaRow) return '';
|
|
206
215
|
return getFormulaDisplayString(formulaRow[key], data);
|
|
207
216
|
}
|
|
208
217
|
case cellType.CellType.DIGITAL_SIGN:
|
|
@@ -218,18 +227,28 @@ var getCellValueDisplayString = function getCellValueDisplayString(row, type, ke
|
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
229
|
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Format cell value to string
|
|
233
|
+
* @param {object} row { [column.key]: '', ... }
|
|
234
|
+
* @param {object} column
|
|
235
|
+
* @param {object} formulaRows formula results of rows. Default as "{}"
|
|
236
|
+
* @param {array} collaborators e.g. [{ email, name, ... }, ...]. Default as "[]"
|
|
237
|
+
* @param {bool} isArchiveView If is archive view, get original cell value from "row", otherwise get cell value from "formulaRows"
|
|
238
|
+
* @returns formatted cell value, string
|
|
239
|
+
*/
|
|
221
240
|
var getCellValueStringResult = function getCellValueStringResult(row, column$1) {
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
formulaRows =
|
|
225
|
-
|
|
226
|
-
collaborators =
|
|
227
|
-
|
|
228
|
-
isArchiveView =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
type =
|
|
232
|
-
data =
|
|
241
|
+
var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
242
|
+
_ref4$formulaRows = _ref4.formulaRows,
|
|
243
|
+
formulaRows = _ref4$formulaRows === void 0 ? {} : _ref4$formulaRows,
|
|
244
|
+
_ref4$collaborators = _ref4.collaborators,
|
|
245
|
+
collaborators = _ref4$collaborators === void 0 ? [] : _ref4$collaborators,
|
|
246
|
+
_ref4$isArchiveView = _ref4.isArchiveView,
|
|
247
|
+
isArchiveView = _ref4$isArchiveView === void 0 ? false : _ref4$isArchiveView;
|
|
248
|
+
if (!row || !column$1) return '';
|
|
249
|
+
var key = column$1.key,
|
|
250
|
+
type = column$1.type,
|
|
251
|
+
data = column$1.data;
|
|
233
252
|
var cellValue = row[key];
|
|
234
253
|
switch (type) {
|
|
235
254
|
case cellType.CellType.TEXT:
|
|
@@ -276,20 +295,18 @@ var getCellValueStringResult = function getCellValueStringResult(row, column$1)
|
|
|
276
295
|
case cellType.CellType.SINGLE_SELECT:
|
|
277
296
|
{
|
|
278
297
|
if (!data) return '';
|
|
279
|
-
|
|
280
|
-
return option.getOptionName(options, cellValue);
|
|
298
|
+
return option.getOptionName(data.options, cellValue);
|
|
281
299
|
}
|
|
282
300
|
case cellType.CellType.MULTIPLE_SELECT:
|
|
283
301
|
{
|
|
284
302
|
if (!data) return '';
|
|
285
|
-
|
|
286
|
-
return option.getMultipleOptionName(_options2, cellValue);
|
|
303
|
+
return option.getMultipleOptionName(data.options, cellValue);
|
|
287
304
|
}
|
|
288
305
|
case cellType.CellType.DATE:
|
|
289
306
|
{
|
|
290
|
-
var
|
|
291
|
-
|
|
292
|
-
format =
|
|
307
|
+
var _ref5 = data || {},
|
|
308
|
+
_ref5$format = _ref5.format,
|
|
309
|
+
format = _ref5$format === void 0 ? column.DEFAULT_DATE_FORMAT : _ref5$format;
|
|
293
310
|
// patch: compatible with previous format
|
|
294
311
|
var normalizedFormat = format === 'D/M/YYYY' ? format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY') : format;
|
|
295
312
|
return date.getDateDisplayString(cellValue, normalizedFormat);
|
|
@@ -310,63 +327,68 @@ var getCellValueStringResult = function getCellValueStringResult(row, column$1)
|
|
|
310
327
|
}
|
|
311
328
|
case cellType.CellType.LINK:
|
|
312
329
|
{
|
|
330
|
+
var computedCellValue = cellValue;
|
|
313
331
|
if (!isArchiveView) {
|
|
314
|
-
var formulaRow = formulaRows[row._id]
|
|
315
|
-
|
|
332
|
+
var formulaRow = formulaRows && formulaRows[row._id];
|
|
333
|
+
computedCellValue = formulaRow && formulaRow[key];
|
|
316
334
|
}
|
|
317
|
-
if (!
|
|
318
|
-
|
|
335
|
+
if (!Array.isArray(computedCellValue) || computedCellValue.length === 0) {
|
|
336
|
+
return '';
|
|
337
|
+
}
|
|
338
|
+
var displayCellValue = computedCellValue.map(function (linked) {
|
|
319
339
|
return linked.display_value;
|
|
320
340
|
});
|
|
321
|
-
var isTwoDimensionalArray =
|
|
341
|
+
var isTwoDimensionalArray = displayCellValue.some(function (item) {
|
|
322
342
|
return Array.isArray(item);
|
|
323
343
|
});
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
|
|
344
|
+
if (isTwoDimensionalArray) {
|
|
345
|
+
var result = displayCellValue.map(function (item) {
|
|
346
|
+
return _getArrayColumnCellValue(item, column$1, {
|
|
347
|
+
collaborators: collaborators,
|
|
348
|
+
isArchiveView: isArchiveView
|
|
349
|
+
});
|
|
327
350
|
});
|
|
351
|
+
return result.filter(Boolean).join(', ');
|
|
328
352
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
collaborators: collaborators,
|
|
332
|
-
isArchiveView: isArchiveView
|
|
333
|
-
});
|
|
353
|
+
return _getArrayColumnCellValue(displayCellValue, column$1, {
|
|
354
|
+
collaborators: collaborators
|
|
334
355
|
});
|
|
335
|
-
return result.filter(Boolean).join(', ');
|
|
336
356
|
}
|
|
337
357
|
case cellType.CellType.FORMULA:
|
|
338
358
|
case cellType.CellType.LINK_FORMULA:
|
|
339
359
|
{
|
|
360
|
+
var _computedCellValue = cellValue;
|
|
340
361
|
if (!isArchiveView) {
|
|
341
|
-
var _formulaRow = formulaRows[row._id]
|
|
342
|
-
|
|
362
|
+
var _formulaRow = formulaRows && formulaRows[row._id];
|
|
363
|
+
_computedCellValue = _formulaRow && _formulaRow[key];
|
|
343
364
|
}
|
|
344
365
|
var result_type = data.result_type;
|
|
345
366
|
if (result_type === formula.FORMULA_RESULT_TYPE.STRING) {
|
|
346
|
-
return
|
|
367
|
+
return _computedCellValue || '';
|
|
347
368
|
}
|
|
348
369
|
if (result_type === formula.FORMULA_RESULT_TYPE.BOOL) {
|
|
349
|
-
|
|
370
|
+
if (typeof _computedCellValue === 'boolean') return String(_computedCellValue);
|
|
371
|
+
return _computedCellValue === 'true' ? 'true' : 'false';
|
|
350
372
|
}
|
|
351
373
|
if (result_type === formula.FORMULA_RESULT_TYPE.NUMBER) {
|
|
352
374
|
// data is stored in the data of the current column
|
|
353
|
-
return number.getNumberDisplayString(
|
|
375
|
+
return number.getNumberDisplayString(_computedCellValue, data);
|
|
354
376
|
}
|
|
355
377
|
if (result_type === formula.FORMULA_RESULT_TYPE.DATE) {
|
|
356
378
|
// data is stored in the data of the current column
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
return date.getDateDisplayString(cellValue, _format);
|
|
379
|
+
var _format = data.format;
|
|
380
|
+
return date.getDateDisplayString(_computedCellValue, _format);
|
|
360
381
|
}
|
|
361
382
|
|
|
362
383
|
// FORMULA_RESULT_TYPE.ARRAY
|
|
363
|
-
return _getArrayColumnCellValue(
|
|
384
|
+
return _getArrayColumnCellValue(_computedCellValue, column$1, {
|
|
364
385
|
collaborators: collaborators,
|
|
365
386
|
isArchiveView: isArchiveView
|
|
366
387
|
});
|
|
367
388
|
}
|
|
368
389
|
case cellType.CellType.FILE:
|
|
369
390
|
case cellType.CellType.IMAGE:
|
|
391
|
+
case cellType.CellType.DIGITAL_SIGN:
|
|
370
392
|
case cellType.CellType.BUTTON:
|
|
371
393
|
{
|
|
372
394
|
return '';
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Get collaborator by email
|
|
7
|
+
* @param {array} collaborators e.g. [{ email, name, ... }, ...]
|
|
8
|
+
* @param {string} email
|
|
9
|
+
* @returns collaborator, object
|
|
10
|
+
*/
|
|
11
|
+
var getCollaborator = function getCollaborator(collaborators, email) {
|
|
12
|
+
if (!Array.isArray(collaborators) || !email) return null;
|
|
6
13
|
return collaborators.find(function (collaborator) {
|
|
7
|
-
return collaborator.email ===
|
|
14
|
+
return collaborator.email === email;
|
|
8
15
|
});
|
|
9
16
|
};
|
|
10
17
|
|
|
@@ -73,8 +73,8 @@ var getDurationDisplayString = function getDurationDisplayString(duration, forma
|
|
|
73
73
|
}
|
|
74
74
|
var decimalDigits = column.DURATION_DECIMAL_DIGITS[duration_format];
|
|
75
75
|
var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
|
|
76
|
-
var hours = parseInt(positiveValue / 3600
|
|
77
|
-
var minutes = parseInt((positiveValue - hours * 3600) / 60
|
|
76
|
+
var hours = parseInt(positiveValue / 3600);
|
|
77
|
+
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
78
78
|
var displayString = duration < 0 ? '-' : '';
|
|
79
79
|
if (duration_format === column.DURATION_FORMATS_MAP.H_MM) {
|
|
80
80
|
displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : "0".concat(minutes));
|
|
@@ -87,4 +87,6 @@ var getDurationDisplayString = function getDurationDisplayString(duration, forma
|
|
|
87
87
|
return displayString;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
exports.getDurationDecimalSuffix = getDurationDecimalSuffix;
|
|
90
91
|
exports.getDurationDisplayString = getDurationDisplayString;
|
|
92
|
+
exports.getMathRoundedDuration = getMathRoundedDuration;
|
|
@@ -19,67 +19,65 @@ var getGeolocationDisplayString = function getGeolocationDisplayString(loc, form
|
|
|
19
19
|
isBaiduMap = _ref$isBaiduMap === void 0 ? true : _ref$isBaiduMap,
|
|
20
20
|
_ref$hyphen = _ref.hyphen,
|
|
21
21
|
hyphen = _ref$hyphen === void 0 ? '' : _ref$hyphen;
|
|
22
|
-
if (!loc)
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
22
|
+
if (!loc) return '';
|
|
25
23
|
var _ref2 = formats || {},
|
|
26
24
|
geo_format = _ref2.geo_format;
|
|
27
25
|
switch (geo_format) {
|
|
28
26
|
case 'lng_lat':
|
|
29
27
|
{
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
lat = _ref3.lat;
|
|
28
|
+
var lng = loc.lng,
|
|
29
|
+
lat = loc.lat;
|
|
33
30
|
if (!geolocation.isValidPosition(lng, lat)) return '';
|
|
34
31
|
return isBaiduMap ? "".concat(lng, ", ").concat(lat) : "".concat(lat, ", ").concat(lng);
|
|
35
32
|
}
|
|
36
33
|
case 'country_region':
|
|
37
34
|
{
|
|
38
|
-
var
|
|
39
|
-
country_region = _ref4.country_region;
|
|
35
|
+
var country_region = loc.country_region;
|
|
40
36
|
return country_region || '';
|
|
41
37
|
}
|
|
42
38
|
case 'province':
|
|
43
39
|
{
|
|
44
|
-
var
|
|
45
|
-
province = _ref5.province;
|
|
40
|
+
var province = loc.province;
|
|
46
41
|
return province || '';
|
|
47
42
|
}
|
|
48
43
|
case 'province_city':
|
|
49
44
|
{
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
city = _ref6.city;
|
|
45
|
+
var _province = loc.province,
|
|
46
|
+
city = loc.city;
|
|
53
47
|
return "".concat(_province || '').concat(hyphen).concat(city || '').trim();
|
|
54
48
|
}
|
|
55
49
|
case 'province_city_district':
|
|
56
50
|
{
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
district = _ref7.district;
|
|
51
|
+
var _province2 = loc.province,
|
|
52
|
+
_city = loc.city,
|
|
53
|
+
district = loc.district;
|
|
61
54
|
return "".concat(_province2 || '').concat(hyphen).concat(_city || '').concat(hyphen).concat(district || '').trim();
|
|
62
55
|
}
|
|
63
56
|
case 'map_selection':
|
|
64
57
|
{
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
title = _ref8.title;
|
|
58
|
+
var address = loc.address,
|
|
59
|
+
title = loc.title;
|
|
68
60
|
return "".concat(address || '').concat(hyphen).concat(title || '').trim();
|
|
69
61
|
}
|
|
70
62
|
default:
|
|
71
63
|
{
|
|
72
64
|
// default as 'geolocation'
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
detail = _ref9.detail;
|
|
65
|
+
var _province3 = loc.province,
|
|
66
|
+
_city2 = loc.city,
|
|
67
|
+
_district = loc.district,
|
|
68
|
+
detail = loc.detail;
|
|
78
69
|
if (!_province3 && !_city2 && !_district && !detail) return '';
|
|
79
70
|
return "".concat(_province3 || '').concat(hyphen).concat(_city2 || '').concat(hyphen).concat(_district || '').concat(hyphen).concat(detail || '').trim();
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get geolocation by granularity
|
|
77
|
+
* @param {object} geolocation e.g. { province, ... }
|
|
78
|
+
* @param {string} granularity
|
|
79
|
+
* @returns geolocation string
|
|
80
|
+
*/
|
|
83
81
|
var getGeolocationByGranularity = function getGeolocationByGranularity(geolocation, granularity) {
|
|
84
82
|
if (!geolocation) return '';
|
|
85
83
|
var province = geolocation.province,
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var index = require('../helper/number-precision/index.js');
|
|
6
6
|
var duration = require('./duration.js');
|
|
7
7
|
var column = require('../constants/column.js');
|
|
8
|
+
var formula = require('../constants/formula.js');
|
|
8
9
|
|
|
9
10
|
var separatorMap = {
|
|
10
11
|
comma: ',',
|
|
@@ -12,29 +13,36 @@ var separatorMap = {
|
|
|
12
13
|
no: '',
|
|
13
14
|
space: ' '
|
|
14
15
|
};
|
|
15
|
-
var _getDecimalDigits = function _getDecimalDigits(
|
|
16
|
-
if (Number.isInteger(
|
|
16
|
+
var _getDecimalDigits = function _getDecimalDigits(number) {
|
|
17
|
+
if (Number.isInteger(number)) {
|
|
17
18
|
return 0;
|
|
18
19
|
}
|
|
19
|
-
var valueArr = (
|
|
20
|
+
var valueArr = String(number).split('.');
|
|
20
21
|
var digitsLength = valueArr[1] ? valueArr[1].length : 8;
|
|
21
22
|
return digitsLength > 8 ? 8 : digitsLength;
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get fixed number by precision
|
|
27
|
+
* @param {number} number
|
|
28
|
+
* @param {object} formats e.g. { enable_precision, precision, ... }
|
|
29
|
+
* @returns fixed number, string
|
|
30
|
+
*/
|
|
31
|
+
var getPrecisionNumber = function getPrecisionNumber(number, formats) {
|
|
32
|
+
var _ref = formats || {},
|
|
25
33
|
_ref$precision = _ref.precision,
|
|
26
34
|
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
27
35
|
_ref$enable_precision = _ref.enable_precision,
|
|
28
36
|
enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
|
|
29
|
-
var type = Object.prototype.toString.call(
|
|
37
|
+
var type = Object.prototype.toString.call(number);
|
|
30
38
|
if (type !== '[object Number]') {
|
|
31
|
-
if (type === '[object String]' && DISPLAY_INTERNAL_ERRORS.includes(
|
|
32
|
-
return
|
|
39
|
+
if (type === '[object String]' && formula.DISPLAY_INTERNAL_ERRORS.includes(number)) {
|
|
40
|
+
return number;
|
|
33
41
|
}
|
|
34
42
|
return null;
|
|
35
43
|
}
|
|
36
|
-
var decimalDigits = enable_precision ? precision : _getDecimalDigits(
|
|
37
|
-
return
|
|
44
|
+
var decimalDigits = enable_precision ? precision : _getDecimalDigits(number);
|
|
45
|
+
return number.toFixed(decimalDigits);
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
/**
|
|
@@ -93,7 +101,7 @@ var toThousands = function toThousands(number, _ref2) {
|
|
|
93
101
|
}
|
|
94
102
|
return numericString;
|
|
95
103
|
}
|
|
96
|
-
return number;
|
|
104
|
+
return String(number);
|
|
97
105
|
}
|
|
98
106
|
var decimalString = separatorMap[decimal];
|
|
99
107
|
var thousandsString = separatorMap[thousands];
|
|
@@ -4,15 +4,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var option = require('../column/option.js');
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Get option by id
|
|
9
|
+
* @param {array} options e.g. [{ id, name, ... }]
|
|
10
|
+
* @param {string} optionId
|
|
11
|
+
* @returns option, object
|
|
12
|
+
*/
|
|
7
13
|
var getOption = function getOption(options, optionId) {
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
if (!Array.isArray(options) || !optionId) return null;
|
|
15
|
+
return options.find(function (option) {
|
|
16
|
+
return option.id === optionId;
|
|
10
17
|
});
|
|
11
18
|
};
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* Get option name of the given id
|
|
15
|
-
* @param {array} options e.g. [ { id
|
|
22
|
+
* @param {array} options e.g. [ { id, color, name, ... } ]
|
|
16
23
|
* @param {string} targetOptionId option id
|
|
17
24
|
* @returns option name, string
|
|
18
25
|
*/
|
|
@@ -21,6 +28,13 @@ var getOptionName = function getOptionName(options, targetOptionId) {
|
|
|
21
28
|
var targetOption = getOption(options, targetOptionId);
|
|
22
29
|
return targetOption ? targetOption.name : '';
|
|
23
30
|
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get column option name by id
|
|
34
|
+
* @param {object} column e.g. { data: { options, ... }, ... }
|
|
35
|
+
* @param {string} optionId
|
|
36
|
+
* @returns option name, string
|
|
37
|
+
*/
|
|
24
38
|
var getColumnOptionNameById = function getColumnOptionNameById(column, optionId) {
|
|
25
39
|
var options = option.getColumnOptions(column);
|
|
26
40
|
return getOptionName(options, optionId);
|
|
@@ -28,7 +42,7 @@ var getColumnOptionNameById = function getColumnOptionNameById(column, optionId)
|
|
|
28
42
|
|
|
29
43
|
/**
|
|
30
44
|
* Get concatenated options names of given ids.
|
|
31
|
-
* @param {array} options e.g. [ { id
|
|
45
|
+
* @param {array} options e.g. [ { id, color, name, ... }, ... ]
|
|
32
46
|
* @param {array} targetOptionsIds e.g. [ option.id, ... ]
|
|
33
47
|
* @returns concatenated options names, string. e.g. 'name1, name2'
|
|
34
48
|
*/
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Get formatted rate
|
|
7
|
+
* @param {number} value
|
|
8
|
+
* @returns formatted rate
|
|
9
|
+
*/
|
|
5
10
|
var getRateDisplayString = function getRateDisplayString(value) {
|
|
6
11
|
if (!value) return '';
|
|
7
12
|
return String(value);
|
|
@@ -5,17 +5,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var date = require('../date.js');
|
|
6
6
|
var number = require('./number.js');
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Parse string to date
|
|
10
|
+
* @param {string} text
|
|
11
|
+
* @param {string} format default as "YYYY-MM-DD"
|
|
12
|
+
* @returns date, string
|
|
13
|
+
*/
|
|
8
14
|
var formatTextToDate = function formatTextToDate(text) {
|
|
9
|
-
var
|
|
15
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD';
|
|
10
16
|
if (typeof text !== 'string' || !text.trim()) return null;
|
|
11
17
|
var isAllNumber = /^[0-9]+$/.test(text);
|
|
12
18
|
var dateObj = {};
|
|
13
19
|
if (isAllNumber) {
|
|
14
20
|
dateObj = new Date(number.getFloatNumber(text));
|
|
15
21
|
} else {
|
|
16
|
-
dateObj = date.DateUtils.parseDateWithFormat(text,
|
|
22
|
+
dateObj = date.DateUtils.parseDateWithFormat(text, format);
|
|
17
23
|
}
|
|
18
|
-
if (
|
|
24
|
+
if (format.indexOf('HH:mm') < 0) {
|
|
19
25
|
return date.DateUtils.format(dateObj, 'YYYY-MM-DD') || null;
|
|
20
26
|
}
|
|
21
27
|
return date.DateUtils.format(dateObj, 'YYYY-MM-DD HH:MM') || null;
|
|
@@ -7,12 +7,12 @@ var deepCopy = require('deep-copy');
|
|
|
7
7
|
var core = require('../filter/core.js');
|
|
8
8
|
var filterRow = require('../filter/filter-row.js');
|
|
9
9
|
var filter = require('../validate/filter.js');
|
|
10
|
-
var number = require('
|
|
10
|
+
var number = require('../column/number.js');
|
|
11
11
|
var row = require('../table/row.js');
|
|
12
12
|
var sortRow = require('../sort/sort-row.js');
|
|
13
13
|
var core$1 = require('../row/core.js');
|
|
14
|
-
var
|
|
15
|
-
var gradientColor = require('
|
|
14
|
+
var rowColor = require('./row-color.js');
|
|
15
|
+
var gradientColor = require('./gradient-color.js');
|
|
16
16
|
var cellType = require('../constants/cell-type.js');
|
|
17
17
|
require('../constants/column.js');
|
|
18
18
|
var index = require('../constants/filter/index.js');
|
|
@@ -184,7 +184,7 @@ var getFormattedColumn = function getFormattedColumn(column, view, table, value,
|
|
|
184
184
|
var _ref4 = value || {},
|
|
185
185
|
_ref4$collaborators = _ref4.collaborators,
|
|
186
186
|
collaborators = _ref4$collaborators === void 0 ? [] : _ref4$collaborators;
|
|
187
|
-
var formattedColumn =
|
|
187
|
+
var formattedColumn = rowColor["default"].getFormattedDuplicateColumns([dupColumn], [duplicateColumnKey], {
|
|
188
188
|
collaborators: collaborators
|
|
189
189
|
});
|
|
190
190
|
var duplicate_rows_ids_map = {};
|
|
@@ -193,7 +193,7 @@ var getFormattedColumn = function getFormattedColumn(column, view, table, value,
|
|
|
193
193
|
var row = rows[i];
|
|
194
194
|
var rowId = row._id;
|
|
195
195
|
var formulaRow = formulaRows && formulaRows[rowId];
|
|
196
|
-
var rowValue =
|
|
196
|
+
var rowValue = rowColor["default"].getDuplicateRowValue(row, formattedColumn, formulaRow);
|
|
197
197
|
if (!rowValue) continue;
|
|
198
198
|
var rowIds = duplicate_rows_ids_map[rowValue];
|
|
199
199
|
if (rowIds && rowIds.length > 0) {
|
|
@@ -251,6 +251,17 @@ var getFormattedColumn = function getFormattedColumn(column, view, table, value,
|
|
|
251
251
|
dupColumn.gradientColorUtils = gradientColorUtils;
|
|
252
252
|
return dupColumn;
|
|
253
253
|
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Calculate column color
|
|
257
|
+
* @param {array} rows
|
|
258
|
+
* @param {object} view
|
|
259
|
+
* @param {object} table e.g. { id_row_map, ... }
|
|
260
|
+
* @param {object} value e.g. { tables, collaborators, ... }
|
|
261
|
+
* @param {string} username
|
|
262
|
+
* @param {userId} username
|
|
263
|
+
* @returns column color, object
|
|
264
|
+
*/
|
|
254
265
|
var getColumnColors = function getColumnColors(rows, view, table, value) {
|
|
255
266
|
var _ref5 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
256
267
|
_ref5$username = _ref5.username,
|
|
@@ -306,13 +317,13 @@ var getColumnColors = function getColumnColors(rows, view, table, value) {
|
|
|
306
317
|
var colorRule = colorByRules[m];
|
|
307
318
|
var filter_conjunction = colorRule.filter_conjunction,
|
|
308
319
|
filters = colorRule.filters,
|
|
309
|
-
color
|
|
320
|
+
color = colorRule.color;
|
|
310
321
|
if (filterRow.filterRow(row, filter_conjunction, filters, {
|
|
311
322
|
formulaRow: formulaRow,
|
|
312
323
|
username: username,
|
|
313
324
|
userId: userId
|
|
314
325
|
})) {
|
|
315
|
-
column_color[columnKey] = color
|
|
326
|
+
column_color[columnKey] = color;
|
|
316
327
|
break;
|
|
317
328
|
}
|
|
318
329
|
}
|
|
@@ -322,10 +333,10 @@ var getColumnColors = function getColumnColors(rows, view, table, value) {
|
|
|
322
333
|
var _ref6 = value || {},
|
|
323
334
|
_ref6$collaborators = _ref6.collaborators,
|
|
324
335
|
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
|
|
325
|
-
var formattedColumn =
|
|
336
|
+
var formattedColumn = rowColor["default"].getFormattedDuplicateColumns([column], [duplicateColumnKey], {
|
|
326
337
|
collaborators: collaborators
|
|
327
338
|
});
|
|
328
|
-
var rowValue =
|
|
339
|
+
var rowValue = rowColor["default"].getDuplicateRowValue(row, formattedColumn, formulaRow);
|
|
329
340
|
if (!rowValue) continue;
|
|
330
341
|
var rowIds = duplicate_rows_ids_map[rowValue];
|
|
331
342
|
if (rowIds && rowIds.length > 1) {
|
|
@@ -362,6 +373,17 @@ var getColumnColors = function getColumnColors(rows, view, table, value) {
|
|
|
362
373
|
}
|
|
363
374
|
return column_colors;
|
|
364
375
|
};
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Update column color by updated rows.
|
|
379
|
+
* @param {array} rows updated rows | rows ids
|
|
380
|
+
* @param {object} view
|
|
381
|
+
* @param {object} table e.g. { id_row_map, ... }
|
|
382
|
+
* @param {object} value e.g. { tables, collaborators, ... }
|
|
383
|
+
* @param {string} username
|
|
384
|
+
* @param {userId} username
|
|
385
|
+
* @returns column color, object
|
|
386
|
+
*/
|
|
365
387
|
var updateColumnColorsByUpdateRows = function updateColumnColorsByUpdateRows(rows, view, table, value) {
|
|
366
388
|
var _ref7 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
367
389
|
_ref7$username = _ref7.username,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
6
|
var column = require('../table/column.js');
|
|
7
7
|
var row = require('../table/row.js');
|
|
8
|
-
var core$1 = require('
|
|
8
|
+
var core$1 = require('../row/core.js');
|
|
9
9
|
var option = require('../column/option.js');
|
|
10
10
|
var geolocation = require('../cell-value-get/geolocation.js');
|
|
11
11
|
var filter = require('../validate/filter.js');
|
|
@@ -231,6 +231,17 @@ var getRowsColorByDuplicateValues = function getRowsColorByDuplicateValues(rows,
|
|
|
231
231
|
duplicate_rows_ids_map: duplicate_rows_ids_map
|
|
232
232
|
};
|
|
233
233
|
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Calculate rows color.
|
|
237
|
+
* @param {array} rows
|
|
238
|
+
* @param {object} view
|
|
239
|
+
* @param {object} table e.g. { id_row_map, ... }
|
|
240
|
+
* @param {object} value e.g. { tables, collaborators, ... }
|
|
241
|
+
* @param {string} username
|
|
242
|
+
* @param {userId} username
|
|
243
|
+
* @returns rows color, object
|
|
244
|
+
*/
|
|
234
245
|
var getRowsColor = function getRowsColor(rows, view, table, value) {
|
|
235
246
|
var _ref5 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
236
247
|
username = _ref5.username,
|