dtable-ui-component 0.1.84 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/DTablePopover/index.js +115 -0
- package/lib/DTablePopover/utils.js +5 -0
- package/lib/DTableSelect/index.js +140 -0
- package/lib/DTableSwitch/index.js +27 -0
- package/lib/FormulaFormatter/index.js +7 -7
- package/lib/index.js +5 -1
- package/package.json +2 -1
- package/es/app.css +0 -20
- package/es/app.js +0 -91
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +0 -104
- package/es/components/cell-editor/collaborator-editor.js +0 -236
- package/es/components/cell-editor/date-editor.js +0 -151
- package/es/components/cell-editor/index.js +0 -9
- package/es/components/cell-editor/link-editor.js +0 -303
- package/es/components/cell-editor/multiple-select-editor.js +0 -237
- package/es/components/cell-editor/number-editor.js +0 -154
- package/es/components/cell-editor/single-select-editor.js +0 -202
- package/es/components/cell-editor/text-editor.js +0 -122
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
- package/es/components/cell-factory/cell-formatter-factory.js +0 -25
- package/es/components/cell-formatter/auto-number-formatter.js +0 -35
- package/es/components/cell-formatter/button-formatter.js +0 -55
- package/es/components/cell-formatter/checkbox-formatter.js +0 -44
- package/es/components/cell-formatter/collaborator-formatter.js +0 -91
- package/es/components/cell-formatter/creator-formatter.js +0 -87
- package/es/components/cell-formatter/ctime-formatter.js +0 -57
- package/es/components/cell-formatter/date-formatter.js +0 -59
- package/es/components/cell-formatter/duration-formatter.js +0 -37
- package/es/components/cell-formatter/email-formatter.js +0 -35
- package/es/components/cell-formatter/file-formatter.js +0 -63
- package/es/components/cell-formatter/formatter-config.js +0 -31
- package/es/components/cell-formatter/formula-formatter.js +0 -164
- package/es/components/cell-formatter/geolocation-formatter.js +0 -52
- package/es/components/cell-formatter/image-formatter.js +0 -153
- package/es/components/cell-formatter/index.js +0 -27
- package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
- package/es/components/cell-formatter/link-formatter.js +0 -144
- package/es/components/cell-formatter/long-text-formatter.js +0 -106
- package/es/components/cell-formatter/mtime-formatter.js +0 -57
- package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
- package/es/components/cell-formatter/number-formatter.js +0 -46
- package/es/components/cell-formatter/rate-formatter.js +0 -79
- package/es/components/cell-formatter/single-select-formatter.js +0 -69
- package/es/components/cell-formatter/text-formatter.js +0 -55
- package/es/components/cell-formatter/url-formatter.js +0 -35
- package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
- package/es/components/common/collaborator-item.js +0 -63
- package/es/components/common/edit-editor-button.js +0 -56
- package/es/components/common/images-lazy-load.js +0 -150
- package/es/components/common/link-editor-option.js +0 -113
- package/es/components/common/mobile/mb-editor-header.js +0 -48
- package/es/components/common/modal-portal.js +0 -44
- package/es/components/common/select-editor-option.js +0 -106
- package/es/components/common/select-item.js +0 -58
- package/es/components/file-uploader/index.js +0 -53
- package/es/components/loading.js +0 -7
- package/es/components/toast/alert.js +0 -150
- package/es/components/toast/index.js +0 -3
- package/es/components/toast/toast.js +0 -179
- package/es/components/toast/toastManager.js +0 -170
- package/es/components/toast/toaster.js +0 -76
- package/es/constants/cell-types.js +0 -25
- package/es/constants/index.js +0 -48
- package/es/css/cell-editor.css +0 -614
- package/es/css/cell-formatter.css +0 -241
- package/es/css/custom-rc-calendar.css +0 -118
- package/es/css/image-previewer-ligntbox.css +0 -87
- package/es/css/loading.css +0 -54
- package/es/index.js +0 -6
- package/es/lang/index.js +0 -50
- package/es/locals/de.js +0 -2
- package/es/locals/en.js +0 -17
- package/es/locals/fr.js +0 -2
- package/es/locals/zh-CN.js +0 -17
- package/es/utils/cell-value-validator.js +0 -32
- package/es/utils/column-utils.js +0 -7
- package/es/utils/editor-utils.js +0 -71
- package/es/utils/normalize-long-text-value.js +0 -68
- package/es/utils/number-precision.js +0 -163
- package/es/utils/utils.js +0 -116
- package/es/utils/value-format-utils.js +0 -495
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import NP from './number-precision';
|
|
3
|
-
import { NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
|
|
4
|
-
import * as CellType from '../constants/cell-types';
|
|
5
|
-
NP.enableBoundaryChecking(false);
|
|
6
|
-
var _separatorMap = {
|
|
7
|
-
'comma': ',',
|
|
8
|
-
'dot': '.',
|
|
9
|
-
'no': '',
|
|
10
|
-
'space': ' '
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
var _toThousands = function _toThousands(num, isCurrency, formatData) {
|
|
14
|
-
var _ref = formatData || {},
|
|
15
|
-
_ref$decimal = _ref.decimal,
|
|
16
|
-
decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
|
|
17
|
-
_ref$thousands = _ref.thousands,
|
|
18
|
-
thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
|
|
19
|
-
_ref$precision = _ref.precision,
|
|
20
|
-
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
21
|
-
_ref$enable_precision = _ref.enable_precision,
|
|
22
|
-
enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
|
|
23
|
-
|
|
24
|
-
var decimalString = _separatorMap[decimal];
|
|
25
|
-
var thousandsString = _separatorMap[thousands];
|
|
26
|
-
var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
|
|
27
|
-
var value = parseFloat(num.toFixed(decimalDigits));
|
|
28
|
-
var integer = Math.trunc(value);
|
|
29
|
-
var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
|
|
30
|
-
|
|
31
|
-
if (isCurrency) {
|
|
32
|
-
if (decimalValue.length === 2) {
|
|
33
|
-
decimalValue = decimalValue.padEnd(3, '0');
|
|
34
|
-
} else {
|
|
35
|
-
decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (enable_precision) {
|
|
39
|
-
decimalValue = precision === 0 ? '' : decimalValue.slice(0, precision + 1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
decimalValue = decimalValue.replace(/./, decimalString);
|
|
44
|
-
var result = [],
|
|
45
|
-
counter = 0;
|
|
46
|
-
integer = Object.is(integer, -0) ? ['-', '0'] : integer.toString().split('');
|
|
47
|
-
|
|
48
|
-
for (var i = integer.length - 1; i >= 0; i--) {
|
|
49
|
-
counter++;
|
|
50
|
-
result.unshift(integer[i]);
|
|
51
|
-
|
|
52
|
-
if (!(counter % 3) && i !== 0) {
|
|
53
|
-
result.unshift(thousandsString);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return result.join('') + decimalValue;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var _getDecimalDigits = function _getDecimalDigits(num) {
|
|
61
|
-
if (Number.isInteger(num)) {
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var valueArr = (num + '').split('.');
|
|
66
|
-
var digitsLength = valueArr[1] ? valueArr[1].length : 8;
|
|
67
|
-
return digitsLength > 8 ? 8 : digitsLength;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
|
|
71
|
-
// formatData: old version maybe 'null'
|
|
72
|
-
var type = Object.prototype.toString.call(value);
|
|
73
|
-
|
|
74
|
-
if (type !== '[object Number]') {
|
|
75
|
-
if (type === '[object String]' && value.startsWith('#')) {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isNaN(value) || value === Infinity || value === -Infinity || (value + '').indexOf('e') > -1) return value + '';
|
|
83
|
-
|
|
84
|
-
var _ref2 = formatData || {},
|
|
85
|
-
_ref2$format = _ref2.format,
|
|
86
|
-
format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
|
|
87
|
-
|
|
88
|
-
switch (format) {
|
|
89
|
-
case 'number':
|
|
90
|
-
return _toThousands(value, false, formatData);
|
|
91
|
-
|
|
92
|
-
case 'percent':
|
|
93
|
-
{
|
|
94
|
-
return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
case 'yuan':
|
|
98
|
-
return "\uFFE5".concat(_toThousands(value, true, formatData));
|
|
99
|
-
|
|
100
|
-
case 'dollar':
|
|
101
|
-
return "$".concat(_toThousands(value, true, formatData));
|
|
102
|
-
|
|
103
|
-
case 'euro':
|
|
104
|
-
return "\u20AC".concat(_toThousands(value, true, formatData));
|
|
105
|
-
|
|
106
|
-
case 'duration':
|
|
107
|
-
{
|
|
108
|
-
return getDurationDisplayString(value, formatData.duration_format);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
default:
|
|
112
|
-
return '' + value;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
export var formatStringToNumber = function formatStringToNumber(value) {
|
|
116
|
-
var isIncludePercent = value.indexOf('%') > -1;
|
|
117
|
-
var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
|
|
118
|
-
|
|
119
|
-
if (isIncludePercent && !isNaN(newData)) {
|
|
120
|
-
return newData / 100;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return isNaN(newData) ? '' : newData;
|
|
124
|
-
};
|
|
125
|
-
export var formatNumberString = function formatNumberString(value, format) {
|
|
126
|
-
var formattedValue = '';
|
|
127
|
-
|
|
128
|
-
switch (format) {
|
|
129
|
-
case NUMBER_TYPES.NUMBER:
|
|
130
|
-
case NUMBER_TYPES.NUMBER_WITH_COMMAS:
|
|
131
|
-
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case NUMBER_TYPES.PERCENT:
|
|
135
|
-
formattedValue = value.replace(/[^.-\d,%]/g, '');
|
|
136
|
-
break;
|
|
137
|
-
|
|
138
|
-
case NUMBER_TYPES.YUAN:
|
|
139
|
-
formattedValue = value.replace(/[^.-\d¥,]/g, '');
|
|
140
|
-
break;
|
|
141
|
-
|
|
142
|
-
case NUMBER_TYPES.DOLLAR:
|
|
143
|
-
formattedValue = value.replace(/[^.-\d$,]/g, '');
|
|
144
|
-
break;
|
|
145
|
-
|
|
146
|
-
case NUMBER_TYPES.EURO:
|
|
147
|
-
formattedValue = value.replace(/[^.-\d€,]/g, '');
|
|
148
|
-
break;
|
|
149
|
-
|
|
150
|
-
default:
|
|
151
|
-
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return formattedValue;
|
|
155
|
-
};
|
|
156
|
-
export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
157
|
-
var formattedValue = '';
|
|
158
|
-
|
|
159
|
-
if (!value) {
|
|
160
|
-
// value === '', value === undefine, value === null
|
|
161
|
-
return formattedValue;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var date = moment(value);
|
|
165
|
-
if (!date.isValid()) return value;
|
|
166
|
-
|
|
167
|
-
switch (format) {
|
|
168
|
-
case 'D/M/YYYY':
|
|
169
|
-
case 'DD/MM/YYYY':
|
|
170
|
-
var formatValue = date.format('YYYY-MM-DD');
|
|
171
|
-
var formatValueList = formatValue.split('-');
|
|
172
|
-
return "".concat(formatValueList[2], "/").concat(formatValueList[1], "/").concat(formatValueList[0]);
|
|
173
|
-
|
|
174
|
-
case 'D/M/YYYY HH:mm':
|
|
175
|
-
case 'DD/MM/YYYY HH:mm':
|
|
176
|
-
var formatValues = date.format('YYYY-MM-DD HH:mm');
|
|
177
|
-
var formatValuesList = formatValues.split(' ');
|
|
178
|
-
var formatDateList = formatValuesList[0].split('-');
|
|
179
|
-
return "".concat(formatDateList[2], "/").concat(formatDateList[1], "/").concat(formatDateList[0], " ").concat(formatValuesList[1]);
|
|
180
|
-
|
|
181
|
-
case 'M/D/YYYY':
|
|
182
|
-
return date.format('M/D/YYYY');
|
|
183
|
-
|
|
184
|
-
case 'M/D/YYYY HH:mm':
|
|
185
|
-
return date.format('M/D/YYYY HH:mm');
|
|
186
|
-
|
|
187
|
-
case 'YYYY-MM-DD':
|
|
188
|
-
return date.format('YYYY-MM-DD');
|
|
189
|
-
|
|
190
|
-
case 'YYYY-MM-DD HH:mm':
|
|
191
|
-
return date.format('YYYY-MM-DD HH:mm');
|
|
192
|
-
|
|
193
|
-
default:
|
|
194
|
-
return value;
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
|
|
198
|
-
if (!value && value !== 0) return '';
|
|
199
|
-
duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
|
|
200
|
-
|
|
201
|
-
if (DURATION_FORMATS.findIndex(function (format) {
|
|
202
|
-
return format.type === duration_format;
|
|
203
|
-
}) < 0) {
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (value === 0) {
|
|
208
|
-
return DURATION_ZERO_DISPLAY[duration_format];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
var includeDecimal = duration_format.indexOf('.') > -1;
|
|
212
|
-
var positiveValue = Math.abs(value);
|
|
213
|
-
|
|
214
|
-
if (!includeDecimal) {
|
|
215
|
-
positiveValue = Math.round(positiveValue);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
positiveValue = getMathRoundedDuration(positiveValue, duration_format);
|
|
219
|
-
var decimalParts = (positiveValue + '').split('.');
|
|
220
|
-
var decimalPartsLen = decimalParts.length;
|
|
221
|
-
var decimal = 0;
|
|
222
|
-
|
|
223
|
-
if (decimalPartsLen > 1) {
|
|
224
|
-
decimal = decimalParts[decimalPartsLen - 1];
|
|
225
|
-
decimal = decimal ? decimal - 0 : 0;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
229
|
-
var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
|
|
230
|
-
var displayString = value < 0 ? '-' : '';
|
|
231
|
-
var hours = parseInt(positiveValue / 3600);
|
|
232
|
-
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
233
|
-
|
|
234
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM) {
|
|
235
|
-
displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
|
|
236
|
-
return displayString;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
|
|
240
|
-
|
|
241
|
-
if (hours > 0) {
|
|
242
|
-
displayString += "".concat(hours, ":");
|
|
243
|
-
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
seconds = seconds > 9 ? seconds : "0".concat(seconds);
|
|
247
|
-
displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
248
|
-
return displayString;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
|
|
252
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
253
|
-
|
|
254
|
-
if (decimalDigits < 1) {
|
|
255
|
-
return num;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
var ratio = Math.pow(10, decimalDigits);
|
|
259
|
-
return Math.round(num * ratio) / ratio;
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
|
|
263
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
264
|
-
return decimal === 0 ? '.0' : '';
|
|
265
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
266
|
-
if (decimal === 0) {
|
|
267
|
-
return '.00';
|
|
268
|
-
} else if (decimal < 10) {
|
|
269
|
-
return '0';
|
|
270
|
-
}
|
|
271
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
272
|
-
if (decimal === 0) {
|
|
273
|
-
return '.000';
|
|
274
|
-
} else if (decimal < 10) {
|
|
275
|
-
return '00';
|
|
276
|
-
} else if (decimal < 100) {
|
|
277
|
-
return '0';
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return '';
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export var getOptionName = function getOptionName(options, targetOptionID) {
|
|
285
|
-
if (!targetOptionID || !options || !Array.isArray(options)) return null;
|
|
286
|
-
var option = options.find(function (option) {
|
|
287
|
-
return option.id === targetOptionID;
|
|
288
|
-
});
|
|
289
|
-
return option ? option.name : null;
|
|
290
|
-
};
|
|
291
|
-
export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
|
|
292
|
-
if (!cellVal || !options || !Array.isArray(options)) return null;
|
|
293
|
-
var selectedOptions = options.filter(function (option) {
|
|
294
|
-
return cellVal.includes(option.id);
|
|
295
|
-
});
|
|
296
|
-
if (selectedOptions.length === 0) return null;
|
|
297
|
-
return selectedOptions.map(function (option) {
|
|
298
|
-
return option.name;
|
|
299
|
-
}).join(', ');
|
|
300
|
-
};
|
|
301
|
-
export var getLongtextDisplayString = function getLongtextDisplayString(value) {
|
|
302
|
-
var _ref3 = value || {},
|
|
303
|
-
text = _ref3.text;
|
|
304
|
-
|
|
305
|
-
if (!text) {
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return text;
|
|
310
|
-
};
|
|
311
|
-
export var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
|
|
312
|
-
if (cellVal) {
|
|
313
|
-
var collaboratorsName = [];
|
|
314
|
-
cellVal.forEach(function (v) {
|
|
315
|
-
var collaborator = collaborators.find(function (c) {
|
|
316
|
-
return c.email === v;
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
if (collaborator) {
|
|
320
|
-
collaboratorsName.push(collaborator.name);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
if (collaboratorsName.length === 0) {
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return collaboratorsName.join(', ');
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return null;
|
|
332
|
-
};
|
|
333
|
-
export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
|
|
334
|
-
var _ref4 = columnData || {},
|
|
335
|
-
geo_format = _ref4.geo_format;
|
|
336
|
-
|
|
337
|
-
var cellValue = value || {};
|
|
338
|
-
|
|
339
|
-
if (!value) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (geo_format === 'lng_lat' && value.lng && value.lat) {
|
|
344
|
-
return "".concat(cellValue.lng, ", ").concat(cellValue.lat);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (geo_format === 'country_region' && cellValue.country_region) {
|
|
348
|
-
return value.country_region || '';
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
var province = cellValue.province,
|
|
352
|
-
city = cellValue.city,
|
|
353
|
-
district = cellValue.district,
|
|
354
|
-
detail = cellValue.detail;
|
|
355
|
-
|
|
356
|
-
if (geo_format === 'province') {
|
|
357
|
-
return "".concat(province || '');
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (geo_format === 'province_city') {
|
|
361
|
-
return "".concat(province || '').concat(city || '');
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
|
|
365
|
-
};
|
|
366
|
-
export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
|
|
367
|
-
var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
368
|
-
_ref5$collaborators = _ref5.collaborators,
|
|
369
|
-
collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
|
|
370
|
-
|
|
371
|
-
if (!columnData) {
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var result_type = columnData.result_type;
|
|
376
|
-
|
|
377
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
378
|
-
return getNumberDisplayString(cellValue, columnData);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
382
|
-
var format = columnData.format;
|
|
383
|
-
return getDateDisplayString(cellValue, format);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
387
|
-
var array_type = columnData.array_type,
|
|
388
|
-
array_data = columnData.array_data;
|
|
389
|
-
|
|
390
|
-
if (!array_type) {
|
|
391
|
-
return null;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
395
|
-
return cellValue;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
|
|
399
|
-
return cellValue.map(function (val) {
|
|
400
|
-
return getCellValueDisplayString(val, array_type, {
|
|
401
|
-
data: array_data,
|
|
402
|
-
collaborators: collaborators
|
|
403
|
-
});
|
|
404
|
-
}).join(', ');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return getCellValueDisplayString(cellValue, array_type, {
|
|
408
|
-
data: array_data,
|
|
409
|
-
collaborators: collaborators
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
|
|
414
|
-
return cellValue + '';
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return cellValue;
|
|
418
|
-
};
|
|
419
|
-
export function getCellValueDisplayString(cellValue, type) {
|
|
420
|
-
var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
421
|
-
data = _ref6.data,
|
|
422
|
-
_ref6$collaborators = _ref6.collaborators,
|
|
423
|
-
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
|
|
424
|
-
|
|
425
|
-
var newData = data || {};
|
|
426
|
-
|
|
427
|
-
switch (type) {
|
|
428
|
-
case CellType.GEOLOCATION:
|
|
429
|
-
{
|
|
430
|
-
return getGeolocationDisplayString(cellValue, data);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
case CellType.SINGLE_SELECT:
|
|
434
|
-
{
|
|
435
|
-
if (!data) return '';
|
|
436
|
-
var options = newData.options;
|
|
437
|
-
return getOptionName(options, cellValue);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
case CellType.MULTIPLE_SELECT:
|
|
441
|
-
{
|
|
442
|
-
if (!data) return '';
|
|
443
|
-
var _options = newData.options;
|
|
444
|
-
return getMultipleOptionName(_options, cellValue);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
case CellType.FORMULA:
|
|
448
|
-
case CellType.LINK_FORMULA:
|
|
449
|
-
{
|
|
450
|
-
return getFormulaDisplayString(cellValue, newData, {
|
|
451
|
-
collaborators: collaborators
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
case CellType.LONG_TEXT:
|
|
456
|
-
{
|
|
457
|
-
return getLongtextDisplayString(cellValue);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
case CellType.NUMBER:
|
|
461
|
-
{
|
|
462
|
-
return getNumberDisplayString(cellValue, newData);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
case CellType.DATE:
|
|
466
|
-
{
|
|
467
|
-
var _ref7 = newData || {},
|
|
468
|
-
_ref7$format = _ref7.format,
|
|
469
|
-
format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
|
|
470
|
-
|
|
471
|
-
return getDateDisplayString(cellValue, format);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
case CellType.CREATOR:
|
|
475
|
-
case CellType.LAST_MODIFIER:
|
|
476
|
-
{
|
|
477
|
-
return cellValue === 'anonymous' ? cellValue : getCollaboratorsName(collaborators, [cellValue]);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
case CellType.COLLABORATOR:
|
|
481
|
-
{
|
|
482
|
-
return getCollaboratorsName(collaborators, cellValue);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
case CellType.DURATION:
|
|
486
|
-
{
|
|
487
|
-
return getDurationDisplayString(cellValue, data);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
default:
|
|
491
|
-
{
|
|
492
|
-
return cellValue ? cellValue + '' : '';
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|