sea-chart 1.1.21 → 1.1.22-alpha.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/dist/components/data-process-setter/data-setting-header.js +11 -0
- package/dist/components/data-process-setter/hide-column-setter.js +79 -0
- package/dist/components/data-process-setter/index.js +4 -0
- package/dist/components/data-process-setter/sort-setter.js +75 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +60 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +38 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +208 -0
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +71 -0
- package/dist/components/popover/sort-popover/sort-popover.css +83 -0
- package/dist/components/popover/sort-popover/sort-popover.js +290 -0
- package/dist/components/types-dialog/index.js +5 -2
- package/dist/constants/common-constants.js +3 -1
- package/dist/constants/index.js +1 -1
- package/dist/constants/type-image.js +2 -1
- package/dist/constants/type.js +5 -3
- package/dist/context.js +1 -1
- package/dist/locale/lang/de.js +17 -2
- package/dist/locale/lang/en.js +16 -1
- package/dist/locale/lang/es.js +16 -1
- package/dist/locale/lang/fr.js +17 -2
- package/dist/locale/lang/pt.js +16 -1
- package/dist/locale/lang/ru.js +16 -1
- package/dist/locale/lang/zh_CN.js +16 -1
- package/dist/model/index.js +3 -1
- package/dist/model/table-element.js +22 -0
- package/dist/settings/data-settings.js +5 -0
- package/dist/settings/table-element-settings/components/data-filter.css +17 -0
- package/dist/settings/table-element-settings/components/data-filter.js +89 -0
- package/dist/settings/table-element-settings/data-settings.js +100 -0
- package/dist/settings/table-element-settings/index.css +190 -0
- package/dist/settings/table-element-settings/index.js +2 -0
- package/dist/settings/widgets/chart-type/index.js +3 -1
- package/dist/settings/widgets/common-data-settings.js +1 -0
- package/dist/settings/widgets/data-filter/index.css +1 -1
- package/dist/utils/chart-utils/base-utils.js +7 -1
- package/dist/utils/chart-utils/index.js +5 -5
- package/dist/utils/chart-utils/original-data-utils/index.js +2 -2
- package/dist/utils/chart-utils/sql-statistics-utils.js +10 -4
- package/dist/utils/chart.js +9 -1
- package/dist/utils/hotkey.js +5 -0
- package/dist/utils/row-utils.js +10 -1
- package/dist/utils/sql/chart-data-sql.js +4 -0
- package/dist/utils/sql/column-2-sql-column.js +4 -0
- package/dist/view/index.css +5 -1
- package/dist/view/index.js +56 -14
- package/dist/view/wrapper/bar-group.js +1 -1
- package/dist/view/wrapper/index.js +7 -0
- package/dist/view/wrapper/table-element/components/dataset-utils.js +123 -0
- package/dist/view/wrapper/table-element/components/formatter.js +309 -0
- package/dist/view/wrapper/table-element/components/formula-formatter.js +36 -0
- package/dist/view/wrapper/table-element/components/link-formatter.js +269 -0
- package/dist/view/wrapper/table-element/components/record.js +67 -0
- package/dist/view/wrapper/table-element/components/records-body.js +117 -0
- package/dist/view/wrapper/table-element/components/records-header/index.js +41 -0
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +51 -0
- package/dist/view/wrapper/table-element/components/records.js +117 -0
- package/dist/view/wrapper/table-element/components/resize-column-handle/index.css +11 -0
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +48 -0
- package/dist/view/wrapper/table-element/components/value-display-utils.js +13 -0
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.css +12 -0
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +36 -0
- package/dist/view/wrapper/table-element/css/index.css +239 -0
- package/dist/view/wrapper/table-element/index.js +101 -0
- package/package.json +1 -1
package/dist/view/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import { isEqual } from 'lodash-es';
|
|
5
5
|
import context from '../context';
|
|
6
6
|
import intl from '../intl';
|
|
7
7
|
import eventBus from '../utils/event-bus';
|
|
@@ -20,6 +20,21 @@ class View extends React.PureComponent {
|
|
|
20
20
|
this.refreshChart = () => {
|
|
21
21
|
this.calculateStatistic();
|
|
22
22
|
};
|
|
23
|
+
this.handleModifyRecord = _ref => {
|
|
24
|
+
var _chart$config, _chart$config2;
|
|
25
|
+
let {
|
|
26
|
+
table_id
|
|
27
|
+
} = _ref;
|
|
28
|
+
const {
|
|
29
|
+
chart
|
|
30
|
+
} = this.props;
|
|
31
|
+
if (((_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.table_id) && table_id === ((_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.table_id)) {
|
|
32
|
+
this.calculateStatistic();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
this.handleDeleteRecord = data => {
|
|
36
|
+
this.handleModifyRecord(data);
|
|
37
|
+
};
|
|
23
38
|
this.callback = (errorMessage, tipMessage, data) => {
|
|
24
39
|
if (errorMessage) {
|
|
25
40
|
this.setState({
|
|
@@ -57,7 +72,6 @@ class View extends React.PureComponent {
|
|
|
57
72
|
};
|
|
58
73
|
this.calculateStatistic = function () {
|
|
59
74
|
let isNeedRequestData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
60
|
-
let data_sources = arguments.length > 1 ? arguments[1] : undefined;
|
|
61
75
|
const {
|
|
62
76
|
tables,
|
|
63
77
|
chart,
|
|
@@ -90,14 +104,14 @@ class View extends React.PureComponent {
|
|
|
90
104
|
collaborators
|
|
91
105
|
}, {
|
|
92
106
|
...data,
|
|
93
|
-
data_sources
|
|
107
|
+
data_sources: null
|
|
108
|
+
}, _this.callback);
|
|
109
|
+
} else {
|
|
110
|
+
ChartUtils.calculateChart(chart, {
|
|
111
|
+
tables,
|
|
112
|
+
collaborators
|
|
94
113
|
}, _this.callback);
|
|
95
|
-
return;
|
|
96
114
|
}
|
|
97
|
-
ChartUtils.calculateChart(chart, {
|
|
98
|
-
tables,
|
|
99
|
-
collaborators
|
|
100
|
-
}, _this.callback);
|
|
101
115
|
};
|
|
102
116
|
this.state = {
|
|
103
117
|
isCalculated: false,
|
|
@@ -111,7 +125,15 @@ class View extends React.PureComponent {
|
|
|
111
125
|
intl.setLang(lang);
|
|
112
126
|
}
|
|
113
127
|
componentDidMount() {
|
|
128
|
+
var _window$app;
|
|
129
|
+
const {
|
|
130
|
+
isCalculateByView
|
|
131
|
+
} = this.props;
|
|
114
132
|
this.unsubscribeReFreshChart = eventBus.subscribe(CommonEventTypes.REFRESH_CHARTS, this.refreshChart);
|
|
133
|
+
if (((_window$app = window.app) === null || _window$app === void 0 ? void 0 : _window$app.eventBus) && isCalculateByView) {
|
|
134
|
+
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_UPDATED, this.handleModifyRecord);
|
|
135
|
+
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_DELETED, this.handleDeleteRecord);
|
|
136
|
+
}
|
|
115
137
|
const {
|
|
116
138
|
hasUnSaved
|
|
117
139
|
} = this.props;
|
|
@@ -131,19 +153,25 @@ class View extends React.PureComponent {
|
|
|
131
153
|
chart,
|
|
132
154
|
hasUnSaved: nextUnSaved
|
|
133
155
|
} = nextProps;
|
|
156
|
+
const {
|
|
157
|
+
config: oldConfig
|
|
158
|
+
} = oldChart;
|
|
159
|
+
const {
|
|
160
|
+
config
|
|
161
|
+
} = chart;
|
|
134
162
|
const {
|
|
135
163
|
data
|
|
136
164
|
} = this.state;
|
|
137
165
|
context.api = this.props.api;
|
|
138
166
|
|
|
139
167
|
// universal-apps will not trigger calculation of the chart before the chart config saved
|
|
140
|
-
// after
|
|
168
|
+
// after saving, hasUnSaved was set to false, then start calculation
|
|
141
169
|
const needCalc = hasUnSaved === true && nextUnSaved === false;
|
|
142
170
|
if (needCalc && !data) {
|
|
143
171
|
this.calculateStatistic();
|
|
144
172
|
return;
|
|
145
173
|
}
|
|
146
|
-
if (
|
|
174
|
+
if (isEqual(config, oldConfig)) return;
|
|
147
175
|
this.setState({
|
|
148
176
|
isCalculated: false
|
|
149
177
|
}, () => {
|
|
@@ -169,7 +197,7 @@ class View extends React.PureComponent {
|
|
|
169
197
|
});
|
|
170
198
|
}
|
|
171
199
|
render() {
|
|
172
|
-
var
|
|
200
|
+
var _title$text, _chart$config3;
|
|
173
201
|
const {
|
|
174
202
|
chart,
|
|
175
203
|
className,
|
|
@@ -191,7 +219,19 @@ class View extends React.PureComponent {
|
|
|
191
219
|
errorMessage,
|
|
192
220
|
tipMessage
|
|
193
221
|
} = this.state;
|
|
194
|
-
|
|
222
|
+
let {
|
|
223
|
+
style_config,
|
|
224
|
+
config
|
|
225
|
+
} = chart;
|
|
226
|
+
if (!style_config) style_config = {};
|
|
227
|
+
if (!config) config = {};
|
|
228
|
+
const {
|
|
229
|
+
type: chartType
|
|
230
|
+
} = config;
|
|
231
|
+
const {
|
|
232
|
+
title
|
|
233
|
+
} = style_config;
|
|
234
|
+
const hasTitle = title && ((_title$text = title.text) === null || _title$text === void 0 ? void 0 : _title$text.length);
|
|
195
235
|
const validClassName = classnames('sea-chart-formatter', className);
|
|
196
236
|
const tipBackgroundColorClassName = 'sea-chart-formatter-tip';
|
|
197
237
|
if (!isCalculated) {
|
|
@@ -217,13 +257,15 @@ class View extends React.PureComponent {
|
|
|
217
257
|
return /*#__PURE__*/React.createElement("div", {
|
|
218
258
|
className: validClassName
|
|
219
259
|
}, /*#__PURE__*/React.createElement("div", {
|
|
220
|
-
className: classnames('sea-chart-formatter-container', "sea-chart-".concat(chart === null || chart === void 0 ? void 0 : (_chart$
|
|
260
|
+
className: classnames('sea-chart-formatter-container', "sea-chart-".concat(chart === null || chart === void 0 ? void 0 : (_chart$config3 = chart.config) === null || _chart$config3 === void 0 ? void 0 : _chart$config3.type, "-formatter-container"), {
|
|
221
261
|
'big_screen_plugin': isBigScreenPlugin
|
|
222
262
|
})
|
|
223
263
|
}, !hideTitle && /*#__PURE__*/React.createElement(Title, {
|
|
224
264
|
chart: chart
|
|
225
265
|
}), /*#__PURE__*/React.createElement("div", {
|
|
226
|
-
className:
|
|
266
|
+
className: classnames('sea-chart-cavans-container', {
|
|
267
|
+
'has-title': hasTitle
|
|
268
|
+
})
|
|
227
269
|
}, /*#__PURE__*/React.createElement(Wrapper, {
|
|
228
270
|
chart: chart,
|
|
229
271
|
data: data,
|
|
@@ -96,7 +96,7 @@ class BarGroup extends ChartComponent {
|
|
|
96
96
|
} else {
|
|
97
97
|
const maxCountGroup = maxBy(newData, 'currentGroupCount');
|
|
98
98
|
// y-axis label width:6 + 10
|
|
99
|
-
singleBarWidth = Math.round(chartWidth / (2 * newData.length * maxCountGroup.currentGroupCount));
|
|
99
|
+
singleBarWidth = maxCountGroup && Math.round(chartWidth / (2 * newData.length * maxCountGroup.currentGroupCount));
|
|
100
100
|
}
|
|
101
101
|
singleBarRadius = Math.min(singleBarWidth / 5, 10);
|
|
102
102
|
this.drawLabels(newData);
|
|
@@ -26,6 +26,7 @@ import HeatMap from './heat-map';
|
|
|
26
26
|
import Mirror from './mirror';
|
|
27
27
|
import Trend from './trend';
|
|
28
28
|
import Funnel from './funnel';
|
|
29
|
+
import TableElement from './table-element';
|
|
29
30
|
const Wrapper = _ref => {
|
|
30
31
|
let {
|
|
31
32
|
dtableStoreValue,
|
|
@@ -84,6 +85,12 @@ const Wrapper = _ref => {
|
|
|
84
85
|
isBigScreenPlugin
|
|
85
86
|
};
|
|
86
87
|
switch (type) {
|
|
88
|
+
case CHART_TYPE.TABLE_ELEMENT:
|
|
89
|
+
{
|
|
90
|
+
return /*#__PURE__*/React.createElement(TableElement, Object.assign({}, baseProps, {
|
|
91
|
+
canvasStyle: canvasStyle
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
87
94
|
case CHART_TYPE.TABLE:
|
|
88
95
|
{
|
|
89
96
|
if (!result) return null;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { CellType } from 'dtable-utils';
|
|
2
|
+
import { getPreviewContent } from '@seafile/seafile-editor';
|
|
3
|
+
export const DATASET_NOT_SUPPORT_COLUMN_TYPES = [CellType.BUTTON];
|
|
4
|
+
export const getCellRecordWidth = function (column) {
|
|
5
|
+
let isSample = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
6
|
+
let {
|
|
7
|
+
type,
|
|
8
|
+
data
|
|
9
|
+
} = column;
|
|
10
|
+
switch (type) {
|
|
11
|
+
case CellType.DATE:
|
|
12
|
+
{
|
|
13
|
+
let isShowHourAndMinute = data && data.format && data.format.indexOf('HH:mm') > -1;
|
|
14
|
+
return isShowHourAndMinute ? 160 : 110;
|
|
15
|
+
}
|
|
16
|
+
case CellType.LONG_TEXT:
|
|
17
|
+
case CellType.AUTO_NUMBER:
|
|
18
|
+
case CellType.URL:
|
|
19
|
+
case CellType.EMAIL:
|
|
20
|
+
{
|
|
21
|
+
return 200;
|
|
22
|
+
}
|
|
23
|
+
case CellType.CHECKBOX:
|
|
24
|
+
{
|
|
25
|
+
return 80;
|
|
26
|
+
}
|
|
27
|
+
case CellType.NUMBER:
|
|
28
|
+
{
|
|
29
|
+
return 120;
|
|
30
|
+
}
|
|
31
|
+
case CellType.CTIME:
|
|
32
|
+
case CellType.MTIME:
|
|
33
|
+
{
|
|
34
|
+
return 170;
|
|
35
|
+
}
|
|
36
|
+
case CellType.RATE:
|
|
37
|
+
{
|
|
38
|
+
const {
|
|
39
|
+
rate_max_number
|
|
40
|
+
} = data || {};
|
|
41
|
+
const rateMaxNumber = rate_max_number || 5;
|
|
42
|
+
return 16 * rateMaxNumber + 20;
|
|
43
|
+
}
|
|
44
|
+
case CellType.IMAGE:
|
|
45
|
+
case CellType.FILE:
|
|
46
|
+
{
|
|
47
|
+
return isSample ? 60 : 160;
|
|
48
|
+
}
|
|
49
|
+
default:
|
|
50
|
+
{
|
|
51
|
+
return 160;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export const getFormulaArrayValue = function (value) {
|
|
56
|
+
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
57
|
+
if (!Array.isArray(value)) return [];
|
|
58
|
+
if (!isFlat) return getTwoDimensionArrayValue(value);
|
|
59
|
+
return value.map(item => {
|
|
60
|
+
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
61
|
+
return item;
|
|
62
|
+
}
|
|
63
|
+
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
64
|
+
const {
|
|
65
|
+
display_value
|
|
66
|
+
} = item;
|
|
67
|
+
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
68
|
+
return display_value.map(i => {
|
|
69
|
+
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
70
|
+
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
71
|
+
const {
|
|
72
|
+
display_value
|
|
73
|
+
} = i;
|
|
74
|
+
return display_value;
|
|
75
|
+
}
|
|
76
|
+
return i;
|
|
77
|
+
});
|
|
78
|
+
}).flat().filter(item => isValidCellValue(item));
|
|
79
|
+
};
|
|
80
|
+
export const convertValueToDtableLongTextValue = value => {
|
|
81
|
+
const valueType = Object.prototype.toString.call(value);
|
|
82
|
+
if (value && valueType === '[object String]') {
|
|
83
|
+
return getPreviewContent(value);
|
|
84
|
+
}
|
|
85
|
+
if (valueType === '[object Object]') {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
return '';
|
|
89
|
+
};
|
|
90
|
+
export const isValidCellValue = value => {
|
|
91
|
+
if (value === undefined) return false;
|
|
92
|
+
if (value === null) return false;
|
|
93
|
+
if (value === '') return false;
|
|
94
|
+
if (JSON.stringify(value) === '{}') return false;
|
|
95
|
+
if (JSON.stringify(value) === '[]') return false;
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
export const getTwoDimensionArrayValue = value => {
|
|
99
|
+
if (!Array.isArray(value)) return [];
|
|
100
|
+
return value.map(item => {
|
|
101
|
+
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
102
|
+
return item;
|
|
103
|
+
}
|
|
104
|
+
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
105
|
+
const {
|
|
106
|
+
display_value
|
|
107
|
+
} = item;
|
|
108
|
+
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
109
|
+
return display_value.map(i => {
|
|
110
|
+
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
111
|
+
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
112
|
+
const {
|
|
113
|
+
display_value
|
|
114
|
+
} = i;
|
|
115
|
+
return display_value;
|
|
116
|
+
}
|
|
117
|
+
return i;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
export function isArrayFormalColumn(columnType) {
|
|
122
|
+
return [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR].includes(columnType);
|
|
123
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
|
|
2
|
+
import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
|
|
3
|
+
import _DurationFormatter from "dtable-ui-component/lib/DurationFormatter";
|
|
4
|
+
import _EmailFormatter from "dtable-ui-component/lib/EmailFormatter";
|
|
5
|
+
import _UrlFormatter from "dtable-ui-component/lib/UrlFormatter";
|
|
6
|
+
import _AutoNumberFormatter from "dtable-ui-component/lib/AutoNumberFormatter";
|
|
7
|
+
import _LastModifierFormatter from "dtable-ui-component/lib/LastModifierFormatter";
|
|
8
|
+
import _CreatorFormatter from "dtable-ui-component/lib/CreatorFormatter";
|
|
9
|
+
import _MTimeFormatter from "dtable-ui-component/lib/MTimeFormatter";
|
|
10
|
+
import _CTimeFormatter from "dtable-ui-component/lib/CTimeFormatter";
|
|
11
|
+
import _CheckboxFormatter from "dtable-ui-component/lib/CheckboxFormatter";
|
|
12
|
+
import _DepartmentSingleSelectFormatter from "dtable-ui-component/lib/DepartmentSingleSelectFormatter";
|
|
13
|
+
import _SingleSelectFormatter from "dtable-ui-component/lib/SingleSelectFormatter";
|
|
14
|
+
import _MultipleSelectFormatter from "dtable-ui-component/lib/MultipleSelectFormatter";
|
|
15
|
+
import _DateFormatter from "dtable-ui-component/lib/DateFormatter";
|
|
16
|
+
import _NumberFormatter from "dtable-ui-component/lib/NumberFormatter";
|
|
17
|
+
import _GeolocationFormatter from "dtable-ui-component/lib/GeolocationFormatter";
|
|
18
|
+
import _FileFormatter from "dtable-ui-component/lib/FileFormatter";
|
|
19
|
+
import _ImageFormatter from "dtable-ui-component/lib/ImageFormatter";
|
|
20
|
+
import _LongTextFormatter from "dtable-ui-component/lib/LongTextFormatter";
|
|
21
|
+
import _CollaboratorFormatter from "dtable-ui-component/lib/CollaboratorFormatter";
|
|
22
|
+
import _TextFormatter from "dtable-ui-component/lib/TextFormatter";
|
|
23
|
+
import React, { Fragment } from 'react';
|
|
24
|
+
import { CellType } from 'dtable-utils';
|
|
25
|
+
import DtableFormulaFormatter from './formula-formatter';
|
|
26
|
+
import LinkFormatter from './link-formatter';
|
|
27
|
+
class Formatter extends React.Component {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.renderEmptyFormatter = () => {
|
|
31
|
+
const {
|
|
32
|
+
empty
|
|
33
|
+
} = this.props;
|
|
34
|
+
const {
|
|
35
|
+
component
|
|
36
|
+
} = empty || {};
|
|
37
|
+
if (component) return component;
|
|
38
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
className: "row-cell-value-empty"
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
this.downloadImage = url => {
|
|
43
|
+
let seafileFileIndex = url.indexOf('seafile-connector');
|
|
44
|
+
if (seafileFileIndex > -1) return;
|
|
45
|
+
window.location.href = url + '?dl=1';
|
|
46
|
+
};
|
|
47
|
+
this.renderFormatter = () => {
|
|
48
|
+
let {
|
|
49
|
+
column,
|
|
50
|
+
cellValue,
|
|
51
|
+
collaborators,
|
|
52
|
+
isSample,
|
|
53
|
+
isRowExpand,
|
|
54
|
+
departments
|
|
55
|
+
} = this.props;
|
|
56
|
+
const {
|
|
57
|
+
type: columnType
|
|
58
|
+
} = column || {};
|
|
59
|
+
const containerClassName = "table-element-".concat(columnType, "-formatter");
|
|
60
|
+
switch (columnType) {
|
|
61
|
+
case CellType.TEXT:
|
|
62
|
+
{
|
|
63
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
64
|
+
return /*#__PURE__*/React.createElement(_TextFormatter, {
|
|
65
|
+
value: cellValue,
|
|
66
|
+
containerClassName: containerClassName
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
case CellType.COLLABORATOR:
|
|
70
|
+
{
|
|
71
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) return this.renderEmptyFormatter();
|
|
72
|
+
cellValue = cellValue.filter(item => item);
|
|
73
|
+
if (cellValue.length === 0) return this.renderEmptyFormatter();
|
|
74
|
+
this.props.queryUsers(cellValue);
|
|
75
|
+
return /*#__PURE__*/React.createElement(_CollaboratorFormatter, {
|
|
76
|
+
value: cellValue,
|
|
77
|
+
collaborators: collaborators,
|
|
78
|
+
containerClassName: containerClassName
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
case CellType.LONG_TEXT:
|
|
82
|
+
{
|
|
83
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
84
|
+
return /*#__PURE__*/React.createElement(_LongTextFormatter, {
|
|
85
|
+
isSample: !isRowExpand,
|
|
86
|
+
value: cellValue,
|
|
87
|
+
containerClassName: containerClassName
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
case CellType.IMAGE:
|
|
91
|
+
{
|
|
92
|
+
if (!cellValue || Array.isArray(cellValue) && cellValue.length === 0) return this.renderEmptyFormatter();
|
|
93
|
+
return /*#__PURE__*/React.createElement(_ImageFormatter, {
|
|
94
|
+
value: cellValue,
|
|
95
|
+
containerClassName: containerClassName,
|
|
96
|
+
isSample: isSample,
|
|
97
|
+
isSupportPreview: true,
|
|
98
|
+
readOnly: true,
|
|
99
|
+
downloadImage: this.downloadImage
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
case CellType.FILE:
|
|
103
|
+
{
|
|
104
|
+
if (!cellValue || Array.isArray(cellValue) && cellValue.length === 0) return this.renderEmptyFormatter();
|
|
105
|
+
return /*#__PURE__*/React.createElement(_FileFormatter, {
|
|
106
|
+
value: cellValue,
|
|
107
|
+
containerClassName: containerClassName,
|
|
108
|
+
isSample: isSample
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
case CellType.GEOLOCATION:
|
|
112
|
+
{
|
|
113
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
114
|
+
return /*#__PURE__*/React.createElement(_GeolocationFormatter, {
|
|
115
|
+
value: cellValue,
|
|
116
|
+
data: column.data || {},
|
|
117
|
+
containerClassName: containerClassName
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
case CellType.NUMBER:
|
|
121
|
+
{
|
|
122
|
+
if (!cellValue && cellValue !== 0) return this.renderEmptyFormatter();
|
|
123
|
+
return /*#__PURE__*/React.createElement(_NumberFormatter, {
|
|
124
|
+
value: cellValue,
|
|
125
|
+
data: column.data || {},
|
|
126
|
+
containerClassName: containerClassName
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
case CellType.DATE:
|
|
130
|
+
{
|
|
131
|
+
if (!cellValue || typeof cellValue !== 'string') return this.renderEmptyFormatter();
|
|
132
|
+
const {
|
|
133
|
+
data
|
|
134
|
+
} = column;
|
|
135
|
+
const {
|
|
136
|
+
format
|
|
137
|
+
} = data || {};
|
|
138
|
+
return /*#__PURE__*/React.createElement(_DateFormatter, {
|
|
139
|
+
value: cellValue,
|
|
140
|
+
format: format,
|
|
141
|
+
containerClassName: containerClassName
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
case CellType.MULTIPLE_SELECT:
|
|
145
|
+
{
|
|
146
|
+
if (!cellValue || cellValue.length === 0) return this.renderEmptyFormatter();
|
|
147
|
+
const {
|
|
148
|
+
data
|
|
149
|
+
} = column;
|
|
150
|
+
const {
|
|
151
|
+
options
|
|
152
|
+
} = data || {};
|
|
153
|
+
return /*#__PURE__*/React.createElement(_MultipleSelectFormatter, {
|
|
154
|
+
value: cellValue,
|
|
155
|
+
options: options || [],
|
|
156
|
+
containerClassName: containerClassName
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
case CellType.SINGLE_SELECT:
|
|
160
|
+
{
|
|
161
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
162
|
+
const {
|
|
163
|
+
data
|
|
164
|
+
} = column;
|
|
165
|
+
const {
|
|
166
|
+
options
|
|
167
|
+
} = data || {};
|
|
168
|
+
return /*#__PURE__*/React.createElement(_SingleSelectFormatter, {
|
|
169
|
+
value: cellValue,
|
|
170
|
+
options: options || [],
|
|
171
|
+
containerClassName: containerClassName
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
case CellType.DEPARTMENT_SINGLE_SELECT:
|
|
175
|
+
{
|
|
176
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
177
|
+
return /*#__PURE__*/React.createElement(_DepartmentSingleSelectFormatter, {
|
|
178
|
+
value: cellValue,
|
|
179
|
+
departments: departments || []
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
case CellType.CHECKBOX:
|
|
183
|
+
{
|
|
184
|
+
return /*#__PURE__*/React.createElement(_CheckboxFormatter, {
|
|
185
|
+
value: cellValue,
|
|
186
|
+
containerClassName: containerClassName
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
case CellType.CTIME:
|
|
190
|
+
{
|
|
191
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
192
|
+
return /*#__PURE__*/React.createElement(_CTimeFormatter, {
|
|
193
|
+
value: cellValue,
|
|
194
|
+
containerClassName: containerClassName
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
case CellType.MTIME:
|
|
198
|
+
{
|
|
199
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
200
|
+
return /*#__PURE__*/React.createElement(_MTimeFormatter, {
|
|
201
|
+
value: cellValue,
|
|
202
|
+
containerClassName: containerClassName
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
case CellType.CREATOR:
|
|
206
|
+
{
|
|
207
|
+
this.props.queryUsers([cellValue]);
|
|
208
|
+
return /*#__PURE__*/React.createElement(_CreatorFormatter, {
|
|
209
|
+
collaborators: collaborators,
|
|
210
|
+
value: cellValue
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
case CellType.LAST_MODIFIER:
|
|
214
|
+
{
|
|
215
|
+
this.props.queryUsers([cellValue]);
|
|
216
|
+
return /*#__PURE__*/React.createElement(_LastModifierFormatter, {
|
|
217
|
+
collaborators: collaborators,
|
|
218
|
+
value: cellValue
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
case CellType.AUTO_NUMBER:
|
|
222
|
+
{
|
|
223
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
224
|
+
return /*#__PURE__*/React.createElement(_AutoNumberFormatter, {
|
|
225
|
+
value: cellValue,
|
|
226
|
+
containerClassName: containerClassName
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
case CellType.URL:
|
|
230
|
+
{
|
|
231
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
232
|
+
return /*#__PURE__*/React.createElement(_UrlFormatter, {
|
|
233
|
+
value: cellValue,
|
|
234
|
+
containerClassName: containerClassName
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
case CellType.EMAIL:
|
|
238
|
+
{
|
|
239
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
240
|
+
return /*#__PURE__*/React.createElement(_EmailFormatter, {
|
|
241
|
+
value: cellValue,
|
|
242
|
+
containerClassName: containerClassName
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
case CellType.DURATION:
|
|
246
|
+
{
|
|
247
|
+
if (!cellValue) return this.renderEmptyFormatter();
|
|
248
|
+
return /*#__PURE__*/React.createElement(_DurationFormatter, {
|
|
249
|
+
value: cellValue,
|
|
250
|
+
format: column.data.duration_format,
|
|
251
|
+
containerClassName: containerClassName
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
case CellType.RATE:
|
|
255
|
+
{
|
|
256
|
+
return /*#__PURE__*/React.createElement(_RateFormatter, {
|
|
257
|
+
value: cellValue,
|
|
258
|
+
data: column.data || {},
|
|
259
|
+
containerClassName: containerClassName
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
case CellType.BUTTON:
|
|
263
|
+
{
|
|
264
|
+
return /*#__PURE__*/React.createElement(_ButtonFormatter, {
|
|
265
|
+
data: column.data || {},
|
|
266
|
+
containerClassName: containerClassName
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
case CellType.FORMULA:
|
|
270
|
+
case CellType.LINK_FORMULA:
|
|
271
|
+
{
|
|
272
|
+
return /*#__PURE__*/React.createElement(DtableFormulaFormatter, {
|
|
273
|
+
value: cellValue,
|
|
274
|
+
column: column,
|
|
275
|
+
collaborators: collaborators,
|
|
276
|
+
containerClassName: containerClassName,
|
|
277
|
+
queryUsers: this.props.queryUsers,
|
|
278
|
+
renderEmptyFormatter: this.renderEmptyFormatter
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
case CellType.LINK:
|
|
282
|
+
{
|
|
283
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) return this.renderEmptyFormatter();
|
|
284
|
+
return /*#__PURE__*/React.createElement(LinkFormatter, {
|
|
285
|
+
value: cellValue,
|
|
286
|
+
column: column,
|
|
287
|
+
collaborators: collaborators,
|
|
288
|
+
containerClassName: containerClassName,
|
|
289
|
+
renderEmptyFormatter: this.renderEmptyFormatter,
|
|
290
|
+
getOptionColors: this.props.getOptionColors,
|
|
291
|
+
getUserCommonInfo: this.props.getUserCommonInfo,
|
|
292
|
+
queryUsers: this.props.queryUsers
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
default:
|
|
296
|
+
return this.renderEmptyFormatter();
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
render() {
|
|
301
|
+
return /*#__PURE__*/React.createElement(Fragment, null, this.renderFormatter());
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
Formatter.defaultProps = {
|
|
305
|
+
isSample: false,
|
|
306
|
+
isRowExpand: false,
|
|
307
|
+
queryUsers: () => {}
|
|
308
|
+
};
|
|
309
|
+
export default Formatter;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _FormulaFormatter from "dtable-ui-component/lib/FormulaFormatter";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE } from 'dtable-utils';
|
|
4
|
+
import { convertValueToDtableLongTextValue } from './dataset-utils';
|
|
5
|
+
function DtableFormulaFormatter(props) {
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
column,
|
|
9
|
+
collaborators,
|
|
10
|
+
containerClassName
|
|
11
|
+
} = props;
|
|
12
|
+
if (!value && value !== 0 && value !== false) {
|
|
13
|
+
return props.renderEmptyFormatter();
|
|
14
|
+
}
|
|
15
|
+
const {
|
|
16
|
+
result_type,
|
|
17
|
+
array_type
|
|
18
|
+
} = column.data || {};
|
|
19
|
+
let cellValue = value;
|
|
20
|
+
if (Array.isArray(cellValue)) {
|
|
21
|
+
if (array_type === CellType.LONG_TEXT) {
|
|
22
|
+
cellValue = cellValue.map(item => convertValueToDtableLongTextValue(item));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY && COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
26
|
+
// need query user if not loaded
|
|
27
|
+
props.queryUsers(Array.isArray(cellValue) ? cellValue : [cellValue]);
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/React.createElement(_FormulaFormatter, {
|
|
30
|
+
value: cellValue,
|
|
31
|
+
column: column,
|
|
32
|
+
collaborators: collaborators,
|
|
33
|
+
containerClassName: containerClassName
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export default DtableFormulaFormatter;
|