dtable-ui-component 0.3.5 → 0.3.6-beta.2
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/DateEditor/index.js +1 -1
- package/lib/DateEditor/mb-date-editor-popover/index.js +3 -3
- package/lib/DateFormatter/index.js +3 -15
- package/lib/DurationFormatter/index.js +1 -1
- package/lib/FormulaFormatter/index.js +1 -2
- package/lib/GeolocationFormatter/index.js +9 -4
- package/lib/LinkEditor/index.js +1 -1
- package/lib/LinkFormatter/index.js +3 -4
- package/lib/NumberEditor/index.js +1 -1
- package/lib/NumberFormatter/index.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +2 -6
- package/lib/RowExpandLinkFormatter/value-display-utils.js +10 -398
- package/lib/constants/index.js +2 -33
- package/lib/data/dtable-value.js +1 -6
- package/lib/index.js +1 -3
- package/lib/utils/utils.js +0 -14
- package/package.json +3 -1
- package/lib/RowExpandLinkFormatter/column-data-constants.js +0 -20
- package/lib/RowExpandLinkFormatter/date-utils.js +0 -127
- package/lib/RowExpandLinkFormatter/formula-constants.js +0 -9
- package/lib/RowExpandLinkFormatter/number-precision.js +0 -116
- package/lib/constants/cell-types.js +0 -29
- package/lib/utils/number-precision.js +0 -164
- package/lib/utils/value-format-utils.js +0 -587
package/lib/DateEditor/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import MediaQuery from 'react-responsive';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
|
-
import { getDateDisplayString } from '
|
|
8
|
+
import { getDateDisplayString } from '@seafile/dtable-utils';
|
|
9
9
|
import PCDateEditorPopover from './pc-date-editor-popover';
|
|
10
10
|
import MBDateEditorPopover from './mb-date-editor-popover';
|
|
11
11
|
import './index.css';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import _DatePicker from "antd-mobile/lib/date-picker";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
6
|
import React from 'react';
|
|
6
|
-
import { DatePicker } from 'antd-mobile';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
import Calendar from '@seafile/seafile-calendar';
|
|
9
9
|
import * as SeaDatePicker from '@seafile/seafile-calendar/lib/Picker';
|
|
@@ -212,7 +212,7 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
212
212
|
className: "mb-date-editor-input"
|
|
213
213
|
}, /*#__PURE__*/React.createElement("div", {
|
|
214
214
|
className: "date-input"
|
|
215
|
-
}, /*#__PURE__*/React.createElement(
|
|
215
|
+
}, /*#__PURE__*/React.createElement(_DatePicker, {
|
|
216
216
|
mode: "date",
|
|
217
217
|
locale: initDateEditorLanguage(lang),
|
|
218
218
|
value: this.state.value,
|
|
@@ -221,7 +221,7 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
221
221
|
className: "date-input-day"
|
|
222
222
|
}, datePickerValue && datePickerValue.format(leftFormat)))), showHourAndMinute && /*#__PURE__*/React.createElement("div", {
|
|
223
223
|
className: "date-input"
|
|
224
|
-
}, /*#__PURE__*/React.createElement(
|
|
224
|
+
}, /*#__PURE__*/React.createElement(_DatePicker, {
|
|
225
225
|
mode: "time",
|
|
226
226
|
locale: initDateEditorLanguage(lang),
|
|
227
227
|
value: this.state.value,
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
import { getDateDisplayString } from '
|
|
7
|
+
import { getDateDisplayString } from '@seafile/dtable-utils';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -13,21 +13,9 @@ var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
13
13
|
var _super = _createSuper(DateFormatter);
|
|
14
14
|
|
|
15
15
|
function DateFormatter() {
|
|
16
|
-
var _this;
|
|
17
|
-
|
|
18
16
|
_classCallCheck(this, DateFormatter);
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
args[_key] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
-
|
|
26
|
-
_this.formatDate = function (date, format) {
|
|
27
|
-
return getDateDisplayString(date, format);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return _this;
|
|
18
|
+
return _super.apply(this, arguments);
|
|
31
19
|
}
|
|
32
20
|
|
|
33
21
|
_createClass(DateFormatter, [{
|
|
@@ -40,7 +28,7 @@ var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
40
28
|
var classname = classnames('dtable-ui cell-formatter-container date-formatter', containerClassName);
|
|
41
29
|
|
|
42
30
|
if (date !== '') {
|
|
43
|
-
date =
|
|
31
|
+
date = getDateDisplayString(date, format);
|
|
44
32
|
}
|
|
45
33
|
|
|
46
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
import { getDurationDisplayString } from '
|
|
7
|
+
import { getDurationDisplayString } from '@seafile/dtable-utils';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var DurationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -4,12 +4,11 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { FORMULA_RESULT_TYPE,
|
|
7
|
+
import { CellType, FORMULA_RESULT_TYPE, getFormulaDisplayString } from '@seafile/dtable-utils';
|
|
8
8
|
import BaseFormatterConfig from '../formatterConfig/base-formatter-config';
|
|
9
9
|
import TextFormatter from '../TextFormatter';
|
|
10
10
|
import { isArrayFormalColumn, isSimpleCellFormatter, isFunction, getFormulaArrayValue, convertValueToDtableLongTextValue } from './utils';
|
|
11
11
|
import cellValueValidator from './cell-value-validator';
|
|
12
|
-
import { getFormulaDisplayString } from '../utils/value-format-utils';
|
|
13
12
|
import './index.css';
|
|
14
13
|
|
|
15
14
|
var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
import { getGeolocationDisplayString } from '
|
|
7
|
+
import { getGeolocationDisplayString } from '@seafile/dtable-utils';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -24,7 +24,8 @@ var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
24
24
|
var _this$props = this.props,
|
|
25
25
|
value = _this$props.value,
|
|
26
26
|
data = _this$props.data,
|
|
27
|
-
containerClassName = _this$props.containerClassName
|
|
27
|
+
containerClassName = _this$props.containerClassName,
|
|
28
|
+
isBaiduMap = _this$props.isBaiduMap;
|
|
28
29
|
var className = classnames('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
29
30
|
|
|
30
31
|
if (typeof value !== 'object') {
|
|
@@ -33,7 +34,10 @@ var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
33
34
|
|
|
34
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
36
|
className: className
|
|
36
|
-
}, getGeolocationDisplayString(value, data
|
|
37
|
+
}, getGeolocationDisplayString(value, data, {
|
|
38
|
+
isBaiduMap: isBaiduMap,
|
|
39
|
+
hyphen: ' '
|
|
40
|
+
}));
|
|
37
41
|
}
|
|
38
42
|
}]);
|
|
39
43
|
|
|
@@ -48,6 +52,7 @@ GeolocationFormatter.defaultProps = {
|
|
|
48
52
|
detail: ''
|
|
49
53
|
},
|
|
50
54
|
data: {},
|
|
51
|
-
containerClassName: ''
|
|
55
|
+
containerClassName: '',
|
|
56
|
+
isBaiduMap: false
|
|
52
57
|
};
|
|
53
58
|
export default GeolocationFormatter;
|
package/lib/LinkEditor/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import MediaQuery from 'react-responsive';
|
|
7
|
+
import { getNumberDisplayString, getDateDisplayString } from '@seafile/dtable-utils';
|
|
7
8
|
import { getLocale } from '../lang';
|
|
8
9
|
import { CellType } from '../constants';
|
|
9
|
-
import { getNumberDisplayString, getDateDisplayString } from '../utils/value-format-utils';
|
|
10
10
|
import EditEditorButton from '../EditEditorButton';
|
|
11
11
|
import LinkEditorOption from './link-editor-option';
|
|
12
12
|
import PCLinkEditorPopover from './pc-link-editor-popover';
|
|
@@ -5,8 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import
|
|
9
|
-
import { getNumberDisplayString, getDateDisplayString } from '../utils/value-format-utils';
|
|
8
|
+
import { CellType, getNumberDisplayString, getDateDisplayString } from '@seafile/dtable-utils';
|
|
10
9
|
|
|
11
10
|
// link value is get form parant's interface
|
|
12
11
|
var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -87,12 +86,12 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
87
86
|
data = linkedColumn.data; // todo: improve
|
|
88
87
|
|
|
89
88
|
switch (type) {
|
|
90
|
-
case
|
|
89
|
+
case CellType.NUMBER:
|
|
91
90
|
{
|
|
92
91
|
return getNumberDisplayString(value, data);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
case
|
|
94
|
+
case CellType.DATE:
|
|
96
95
|
{
|
|
97
96
|
var format = data.format;
|
|
98
97
|
return getDateDisplayString(value, format);
|
|
@@ -4,8 +4,8 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import isHotkey from 'is-hotkey';
|
|
7
|
+
import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '@seafile/dtable-utils';
|
|
7
8
|
import { NUMBER_TYPES } from '../constants';
|
|
8
|
-
import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '../utils/value-format-utils';
|
|
9
9
|
import { isMac } from '../utils/utils';
|
|
10
10
|
|
|
11
11
|
var NumberEditor = /*#__PURE__*/function (_React$Component) {
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
import { getNumberDisplayString } from '
|
|
7
|
+
import { getNumberDisplayString } from '@seafile/dtable-utils';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var NumberFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
|
+
import { isValidEmail } from '@seafile/dtable-utils';
|
|
6
7
|
import CollaboratorItem from '../CollaboratorItem';
|
|
7
8
|
|
|
8
9
|
var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
|
|
@@ -17,11 +18,6 @@ var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
|
|
|
17
18
|
|
|
18
19
|
_this = _super.call(this, _props);
|
|
19
20
|
|
|
20
|
-
_this.isValidEmail = function (email) {
|
|
21
|
-
var reg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,6}$/;
|
|
22
|
-
return reg.test(email);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
21
|
_this.calculateCollaboratorData = function (props) {
|
|
26
22
|
var _this$props = _this.props,
|
|
27
23
|
context = _this$props.context,
|
|
@@ -85,7 +81,7 @@ var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
|
|
|
85
81
|
return;
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
if (!
|
|
84
|
+
if (!isValidEmail(cellValue)) {
|
|
89
85
|
collaborator = {
|
|
90
86
|
name: cellValue,
|
|
91
87
|
avatar_url: defaultAvatarUrl
|
|
@@ -1,401 +1,13 @@
|
|
|
1
|
-
import { CellType } from '
|
|
2
|
-
import { isArrayFormalColumn } from './utils';
|
|
3
|
-
import NP from './number-precision';
|
|
4
|
-
import DateUtils from './date-utils';
|
|
5
|
-
import { DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS } from './column-data-constants';
|
|
6
|
-
import { FORMULA_RESULT_TYPE } from './formula-constants';
|
|
7
|
-
NP.enableBoundaryChecking(false);
|
|
8
|
-
var DEFAULT_NUMBER_FORMAT = 'number';
|
|
9
|
-
var COLLABORATOR_COLUMN_TYPES = [CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
|
|
1
|
+
import { CellType, getCellValueDisplayString } from '@seafile/dtable-utils';
|
|
10
2
|
var DOWNLOAD_NAME_COLUMN_TYPES = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.COLLABORATOR, CellType.CREATOR, CellType.AUTO_NUMBER];
|
|
11
|
-
var _separatorMap = {
|
|
12
|
-
'comma': ',',
|
|
13
|
-
'dot': '.',
|
|
14
|
-
'no': '',
|
|
15
|
-
'space': ' '
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
var _toThousands = function _toThousands(num, isCurrency, formatData) {
|
|
19
|
-
var _ref = formatData || {},
|
|
20
|
-
_ref$decimal = _ref.decimal,
|
|
21
|
-
decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
|
|
22
|
-
_ref$thousands = _ref.thousands,
|
|
23
|
-
thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
|
|
24
|
-
_ref$precision = _ref.precision,
|
|
25
|
-
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
26
|
-
_ref$enable_precision = _ref.enable_precision,
|
|
27
|
-
enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
|
|
28
|
-
|
|
29
|
-
var decimalString = _separatorMap[decimal];
|
|
30
|
-
var thousandsString = _separatorMap[thousands];
|
|
31
|
-
|
|
32
|
-
if ((num + '').indexOf('e') > -1) {
|
|
33
|
-
if (num < 1 && num > -1) {
|
|
34
|
-
var _decimalDigits = enable_precision ? precision : 8;
|
|
35
|
-
|
|
36
|
-
return num.toFixed(_decimalDigits);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return num;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
|
|
43
|
-
var value = parseFloat(num.toFixed(decimalDigits));
|
|
44
|
-
var isMinus = value < 0;
|
|
45
|
-
var integer = Math.trunc(value); // format decimal value
|
|
46
|
-
|
|
47
|
-
var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
|
|
48
|
-
|
|
49
|
-
if (isCurrency) {
|
|
50
|
-
if (!enable_precision) {
|
|
51
|
-
if (decimalValue.length === 2) {
|
|
52
|
-
decimalValue = decimalValue.padEnd(3, '0');
|
|
53
|
-
} else {
|
|
54
|
-
decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
decimalValue = decimalValue.replace(/./, decimalString); // format integer value
|
|
60
|
-
|
|
61
|
-
var result = [],
|
|
62
|
-
counter = 0;
|
|
63
|
-
integer = Math.abs(integer).toString();
|
|
64
|
-
|
|
65
|
-
for (var i = integer.length - 1; i >= 0; i--) {
|
|
66
|
-
counter++;
|
|
67
|
-
result.unshift(integer[i]);
|
|
68
|
-
|
|
69
|
-
if (!(counter % 3) && i !== 0) {
|
|
70
|
-
result.unshift(thousandsString);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (isMinus ? '-' : '') + result.join('') + decimalValue;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var _getDecimalDigits = function _getDecimalDigits(num) {
|
|
78
|
-
if (Number.isInteger(num)) {
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var valueArr = (num + '').split('.');
|
|
83
|
-
var digitsLength = valueArr[1] ? valueArr[1].length : 8;
|
|
84
|
-
return digitsLength > 8 ? 8 : digitsLength;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
|
|
88
|
-
// formatData: old version maybe 'null'
|
|
89
|
-
var type = Object.prototype.toString.call(value);
|
|
90
|
-
|
|
91
|
-
if (type !== '[object Number]') {
|
|
92
|
-
if (type === '[object String]' && value.startsWith('#')) {
|
|
93
|
-
return value;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (isNaN(value) || value === Infinity || value === -Infinity) return value + '';
|
|
100
|
-
|
|
101
|
-
var _ref2 = formatData || {},
|
|
102
|
-
_ref2$format = _ref2.format,
|
|
103
|
-
format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
|
|
104
|
-
|
|
105
|
-
switch (format) {
|
|
106
|
-
case 'number':
|
|
107
|
-
return _toThousands(value, false, formatData);
|
|
108
|
-
|
|
109
|
-
case 'percent':
|
|
110
|
-
{
|
|
111
|
-
return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
case 'yuan':
|
|
115
|
-
return "\uFFE5".concat(_toThousands(value, true, formatData));
|
|
116
|
-
|
|
117
|
-
case 'dollar':
|
|
118
|
-
return "$".concat(_toThousands(value, true, formatData));
|
|
119
|
-
|
|
120
|
-
case 'euro':
|
|
121
|
-
return "\u20AC".concat(_toThousands(value, true, formatData));
|
|
122
|
-
|
|
123
|
-
case 'custom_currency':
|
|
124
|
-
{
|
|
125
|
-
return "".concat(formatData.currency_symbol || '').concat(_toThousands(value, true, formatData));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
default:
|
|
129
|
-
return '' + value;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
var getCollaboratorsName = function getCollaboratorsName(value, collaborators) {
|
|
134
|
-
if (Array.isArray(value) && value.length > 0 && Array.isArray(collaborators)) {
|
|
135
|
-
var collaboratorsName = [];
|
|
136
|
-
value.forEach(function (item) {
|
|
137
|
-
var collaborator = collaborators.find(function (c) {
|
|
138
|
-
return c.email === item;
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
if (collaborator) {
|
|
142
|
-
collaboratorsName.push(collaborator.name);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return collaboratorsName.join(',');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return '';
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
var getOptionName = function getOptionName(options, targetOptionID) {
|
|
152
|
-
if (!targetOptionID || !options || !Array.isArray(options)) return null;
|
|
153
|
-
var option = options.find(function (option) {
|
|
154
|
-
return option.id === targetOptionID;
|
|
155
|
-
});
|
|
156
|
-
return option ? option.name : null;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
|
|
160
|
-
if (!cellVal || !options || !Array.isArray(options)) return null;
|
|
161
|
-
var selectedOptions = options.filter(function (option) {
|
|
162
|
-
return cellVal.includes(option.id);
|
|
163
|
-
});
|
|
164
|
-
if (selectedOptions.length === 0) return null;
|
|
165
|
-
return selectedOptions.map(function (option) {
|
|
166
|
-
return option.name;
|
|
167
|
-
}).join(', ');
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
var getLongtextDisplayString = function getLongtextDisplayString(value) {
|
|
171
|
-
var _ref3 = value || {},
|
|
172
|
-
text = _ref3.text;
|
|
173
|
-
|
|
174
|
-
if (!text) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return text;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
3
|
export var getCellDisplayValue = function getCellDisplayValue(record, column, collaborators) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return getNumberDisplayString(cellValue, data);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
case CellType.DATE:
|
|
195
|
-
{
|
|
196
|
-
if (!cellValue || typeof cellValue !== 'string') return '';
|
|
197
|
-
|
|
198
|
-
var _ref4 = data || {},
|
|
199
|
-
format = _ref4.format;
|
|
200
|
-
|
|
201
|
-
return DateUtils.format(cellValue, format);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
case CellType.COLLABORATOR:
|
|
205
|
-
{
|
|
206
|
-
if (!Array.isArray(cellValue)) return '';
|
|
207
|
-
return getCollaboratorsName(cellValue, collaborators);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
case CellType.CREATOR:
|
|
211
|
-
case CellType.LAST_MODIFIER:
|
|
212
|
-
{
|
|
213
|
-
if (!cellValue) return '';
|
|
214
|
-
if (cellValue === 'anonymous') return cellValue;
|
|
215
|
-
return getCollaboratorsName([cellValue], collaborators);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
case CellType.SINGLE_SELECT:
|
|
219
|
-
{
|
|
220
|
-
if (!data) return '';
|
|
221
|
-
var options = data.options;
|
|
222
|
-
return getOptionName(options, cellValue);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
case CellType.MULTIPLE_SELECT:
|
|
226
|
-
{
|
|
227
|
-
if (!data) return '';
|
|
228
|
-
|
|
229
|
-
var _data$options = data.options,
|
|
230
|
-
_options = _data$options === void 0 ? [] : _data$options;
|
|
231
|
-
|
|
232
|
-
return getMultipleOptionName(_options, cellValue);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
case CellType.FORMULA:
|
|
236
|
-
case CellType.LINK_FORMULA:
|
|
237
|
-
{
|
|
238
|
-
return getFormulaDisplayString(cellValue, data, collaborators);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
case CellType.LONG_TEXT:
|
|
242
|
-
{
|
|
243
|
-
return getLongtextDisplayString(cellValue);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
case CellType.DURATION:
|
|
247
|
-
{
|
|
248
|
-
return getDurationDisplayString(cellValue, data);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
case CellType.CTIME:
|
|
252
|
-
case CellType.MTIME:
|
|
253
|
-
{
|
|
254
|
-
return DateUtils.format(cellValue.replace('T', ' ').replace('Z', ''), 'YYYY-MM-DD HH:MM:SS');
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
default:
|
|
258
|
-
{
|
|
259
|
-
return cellValue ? cellValue + '' : '';
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData, collaborators) {
|
|
265
|
-
if (!columnData) return null;
|
|
266
|
-
var result_type = columnData.result_type;
|
|
267
|
-
|
|
268
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
269
|
-
return getNumberDisplayString(cellValue, columnData);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
273
|
-
var format = columnData.format;
|
|
274
|
-
return DateUtils.format(cellValue, format);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
278
|
-
var array_type = columnData.array_type,
|
|
279
|
-
array_data = columnData.array_data;
|
|
280
|
-
|
|
281
|
-
if (!array_type) {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
286
|
-
return cellValue;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (isArrayFormalColumn(array_type) && Array.isArray(cellValue)) {
|
|
290
|
-
return cellValue.map(function (val) {
|
|
291
|
-
return getCellDisplayValue({
|
|
292
|
-
'FORMULA_ARRAY': val
|
|
293
|
-
}, {
|
|
294
|
-
type: 'array_type',
|
|
295
|
-
key: 'FORMULA_ARRAY',
|
|
296
|
-
data: array_data
|
|
297
|
-
}, collaborators);
|
|
298
|
-
}).join(', ');
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return getCellDisplayValue({
|
|
302
|
-
'FORMULA_ARRAY': cellValue
|
|
303
|
-
}, {
|
|
304
|
-
type: 'array_type',
|
|
305
|
-
key: 'FORMULA_ARRAY',
|
|
306
|
-
data: array_data
|
|
307
|
-
}, collaborators);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
|
|
311
|
-
return cellValue + '';
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return cellValue;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
function getMathRoundedDuration(num, duration_format) {
|
|
318
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
319
|
-
|
|
320
|
-
if (decimalDigits < 1) {
|
|
321
|
-
return num;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
var ratio = Math.pow(10, decimalDigits);
|
|
325
|
-
return Math.round(num * ratio) / ratio;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function getDurationDecimalSuffix(duration_format, decimal) {
|
|
329
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
330
|
-
return decimal === 0 ? '.0' : '';
|
|
331
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
332
|
-
if (decimal === 0) {
|
|
333
|
-
return '.00';
|
|
334
|
-
} else if (decimal < 10) {
|
|
335
|
-
return '0';
|
|
336
|
-
}
|
|
337
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
338
|
-
if (decimal === 0) {
|
|
339
|
-
return '.000';
|
|
340
|
-
} else if (decimal < 10) {
|
|
341
|
-
return '00';
|
|
342
|
-
} else if (decimal < 100) {
|
|
343
|
-
return '0';
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return '';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
export var getDurationDisplayString = function getDurationDisplayString(value, data) {
|
|
351
|
-
if (!value && value !== 0) return '';
|
|
352
|
-
|
|
353
|
-
var _ref5 = data || {},
|
|
354
|
-
duration_format = _ref5.duration_format;
|
|
355
|
-
|
|
356
|
-
duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
|
|
357
|
-
|
|
358
|
-
if (DURATION_FORMATS.findIndex(function (format) {
|
|
359
|
-
return format.type === duration_format;
|
|
360
|
-
}) < 0) {
|
|
361
|
-
return '';
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (value === 0) {
|
|
365
|
-
return DURATION_ZERO_DISPLAY[duration_format];
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
var includeDecimal = duration_format.indexOf('.') > -1;
|
|
369
|
-
var positiveValue = Math.abs(value);
|
|
370
|
-
|
|
371
|
-
if (!includeDecimal) {
|
|
372
|
-
positiveValue = Math.round(positiveValue);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
positiveValue = getMathRoundedDuration(positiveValue, duration_format);
|
|
376
|
-
var decimalParts = (positiveValue + '').split('.');
|
|
377
|
-
var decimalPartsLen = decimalParts.length;
|
|
378
|
-
var decimal = 0;
|
|
379
|
-
|
|
380
|
-
if (decimalPartsLen > 1) {
|
|
381
|
-
decimal = decimalParts[decimalPartsLen - 1];
|
|
382
|
-
decimal = decimal ? decimal - 0 : 0;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
386
|
-
var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
|
|
387
|
-
var displayString = value < 0 ? '-' : '';
|
|
388
|
-
var hours = parseInt(positiveValue / 3600);
|
|
389
|
-
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
390
|
-
|
|
391
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM) {
|
|
392
|
-
displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
|
|
393
|
-
return displayString;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
|
|
397
|
-
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
398
|
-
seconds = seconds > 9 ? seconds : "0".concat(seconds);
|
|
399
|
-
displayString += "".concat(hours, ":").concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
400
|
-
return displayString;
|
|
4
|
+
if (!column || !DOWNLOAD_NAME_COLUMN_TYPES.includes(column.type)) return '';
|
|
5
|
+
var key = column.key,
|
|
6
|
+
type = column.type,
|
|
7
|
+
data = column.data;
|
|
8
|
+
return getCellValueDisplayString(record, type, key, {
|
|
9
|
+
data: data,
|
|
10
|
+
collaborators: collaborators,
|
|
11
|
+
geolocationHyphen: ' '
|
|
12
|
+
});
|
|
401
13
|
};
|