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