@seafile/sdoc-editor 1.0.31 → 1.0.33
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/basic-sdk/assets/css/dropdown-menu.css +5 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/helpers.js +11 -1
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.css +1 -1
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.js +9 -4
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/index.js +8 -6
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/collaborator-wrapper.js +101 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/index.js +15 -12
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/index.css +41 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/index.js +275 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/utils.js +73 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/helpers.js +10 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/index.js +11 -6
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.css +171 -6
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.js +313 -18
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.css +7 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/record-item.js +2 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +33 -4
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/filters-list.css +1 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover.js +5 -12
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/index.js +7 -30
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/hide-column-popover.js +5 -12
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/index.js +8 -52
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/sort-setter/index.js +10 -34
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/sort-setter/sort-popover.js +6 -12
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +11 -1
- package/dist/constants/index.js +3 -1
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +8 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +24 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/creator-formatter.js +0 -124
|
@@ -2,6 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import { Editor, Transforms, Range } from '@seafile/slate';
|
|
3
3
|
import slugid from 'slugid';
|
|
4
4
|
import { BLOCKQUOTE, CHECK_LIST_ITEM, COLUMN, IMAGE, ORDERED_LIST, PARAGRAPH, TABLE_CELL, UNORDERED_LIST } from '../../constants/element-type';
|
|
5
|
+
import { INSERT_POSITION } from '../../constants';
|
|
5
6
|
import { focusEditor, getNodeType } from '../../core';
|
|
6
7
|
import Column from './model';
|
|
7
8
|
import * as CellType from './constants/cell-types';
|
|
@@ -46,10 +47,19 @@ export const getColumnType = editor => {
|
|
|
46
47
|
const [n] = match;
|
|
47
48
|
return getNodeType(n);
|
|
48
49
|
};
|
|
49
|
-
export const insertSeaTableColumn = (editor, active, option)
|
|
50
|
+
export const insertSeaTableColumn = function (editor, active, option) {
|
|
51
|
+
let insertPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : INSERT_POSITION.CURRENT;
|
|
50
52
|
if (!active) {
|
|
51
53
|
const column = new Column(option);
|
|
52
54
|
column.id = slugid.nice();
|
|
55
|
+
if (insertPosition === INSERT_POSITION.AFTER) {
|
|
56
|
+
const path = Editor.path(editor, editor.selection);
|
|
57
|
+
path && Transforms.insertNodes(editor, _objectSpread({}, column), {
|
|
58
|
+
at: [path[0] + 1]
|
|
59
|
+
});
|
|
60
|
+
focusEditor(editor);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
53
63
|
Transforms.insertNodes(editor, _objectSpread({}, column));
|
|
54
64
|
}
|
|
55
65
|
focusEditor(editor);
|
|
@@ -6,8 +6,10 @@ import './column-list-menu.css';
|
|
|
6
6
|
const NOT_SUPPORT_COLUMN_TYPES = ['button', 'file'];
|
|
7
7
|
export default function ColumnListMenu(_ref) {
|
|
8
8
|
let {
|
|
9
|
-
editor
|
|
9
|
+
editor,
|
|
10
|
+
insertPosition
|
|
10
11
|
} = _ref;
|
|
12
|
+
const computedBottom = insertPosition ? '0px' : '';
|
|
11
13
|
const columns = useMemo(() => {
|
|
12
14
|
if (!editor.columns) return [];
|
|
13
15
|
return editor.columns.filter(column => !NOT_SUPPORT_COLUMN_TYPES.includes(column.type));
|
|
@@ -27,10 +29,13 @@ export default function ColumnListMenu(_ref) {
|
|
|
27
29
|
};
|
|
28
30
|
const onMousedown = useCallback(option => {
|
|
29
31
|
const active = isActive(editor);
|
|
30
|
-
insertSeaTableColumn(editor, active, option);
|
|
31
|
-
}, [editor]);
|
|
32
|
+
insertSeaTableColumn(editor, active, option, insertPosition);
|
|
33
|
+
}, [editor, insertPosition]);
|
|
32
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
-
className: "column-list-menu"
|
|
35
|
+
className: "column-list-menu",
|
|
36
|
+
style: {
|
|
37
|
+
bottom: computedBottom
|
|
38
|
+
}
|
|
34
39
|
}, options.map(option => {
|
|
35
40
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
41
|
key: option.value,
|
|
@@ -7,7 +7,8 @@ import { isMenuDisabled } from '../helpers';
|
|
|
7
7
|
const SeaTableColumnMenu = _ref => {
|
|
8
8
|
let {
|
|
9
9
|
editor,
|
|
10
|
-
readonly
|
|
10
|
+
readonly,
|
|
11
|
+
insertPosition
|
|
11
12
|
} = _ref;
|
|
12
13
|
const disabled = isMenuDisabled(editor, readonly);
|
|
13
14
|
const menuConfig = MENUS_CONFIG_MAP[ELEMENT_TYPE.COLUMN];
|
|
@@ -17,16 +18,17 @@ const SeaTableColumnMenu = _ref => {
|
|
|
17
18
|
className: "pr-2"
|
|
18
19
|
}, !disabled && /*#__PURE__*/React.createElement("i", {
|
|
19
20
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
20
|
-
})
|
|
21
|
+
}), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
21
22
|
target: menuConfig.id,
|
|
22
|
-
className: "sdoc-menu-popover sdoc-dropdown-menu sdoc-sub-dropdown-menu",
|
|
23
23
|
trigger: "hover",
|
|
24
24
|
placement: "right-start",
|
|
25
25
|
hideArrow: true,
|
|
26
|
-
fade: false
|
|
26
|
+
fade: false,
|
|
27
|
+
popperClassName: "seatable-column-popover"
|
|
27
28
|
}, /*#__PURE__*/React.createElement(ColumnListMenu, {
|
|
28
29
|
editor: editor,
|
|
29
|
-
readonly: readonly
|
|
30
|
-
|
|
30
|
+
readonly: readonly,
|
|
31
|
+
insertPosition: insertPosition
|
|
32
|
+
}))));
|
|
31
33
|
};
|
|
32
34
|
export default SeaTableColumnMenu;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _CreatorFormatter from "dtable-ui-component/lib/CreatorFormatter";
|
|
2
|
+
import _CollaboratorFormatter from "dtable-ui-component/lib/CollaboratorFormatter";
|
|
3
|
+
import _Loading from "dtable-ui-component/lib/Loading";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import EventBus from '../../../../utils/event-bus';
|
|
7
|
+
import { EXTERNAL_EVENT } from '../../../../../constants';
|
|
8
|
+
function withCollaborators(Component) {
|
|
9
|
+
return class Wrapper extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
_defineProperty(this, "getFormattedCellValue", () => {
|
|
13
|
+
const {
|
|
14
|
+
value
|
|
15
|
+
} = this.props;
|
|
16
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const isSingleValue = value && !Array.isArray(value);
|
|
20
|
+
const formattedCellValue = isSingleValue ? [value] : value;
|
|
21
|
+
return formattedCellValue;
|
|
22
|
+
});
|
|
23
|
+
_defineProperty(this, "onCollaboratorsChanged", emailUserMap => {
|
|
24
|
+
const {
|
|
25
|
+
isLoading
|
|
26
|
+
} = this.state;
|
|
27
|
+
if (!isLoading) return;
|
|
28
|
+
const cellValue = this.getFormattedCellValue();
|
|
29
|
+
if (!cellValue) {
|
|
30
|
+
this.setState({
|
|
31
|
+
isLoading: false,
|
|
32
|
+
collaborators: []
|
|
33
|
+
});
|
|
34
|
+
// this.unsubscribeUsersChanged();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const collaborators = cellValue.map(email => emailUserMap[email]).filter(Boolean);
|
|
38
|
+
if (collaborators.length === cellValue.length) {
|
|
39
|
+
this.setState({
|
|
40
|
+
isLoading: false,
|
|
41
|
+
collaborators: collaborators
|
|
42
|
+
});
|
|
43
|
+
// this.unsubscribeUsersChanged();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// nothing todo
|
|
48
|
+
});
|
|
49
|
+
this.state = {
|
|
50
|
+
isLoading: true,
|
|
51
|
+
collaborators: []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async componentDidMount() {
|
|
55
|
+
// TODO: Cheating, non-compliant operations
|
|
56
|
+
const {
|
|
57
|
+
collaboratorManager
|
|
58
|
+
} = window.seafile || window.seafileConfig;
|
|
59
|
+
const cellValue = this.getFormattedCellValue();
|
|
60
|
+
if (!cellValue) {
|
|
61
|
+
this.setState({
|
|
62
|
+
isLoading: false,
|
|
63
|
+
collaborators: []
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const emailUserMap = await collaboratorManager.getEmailUserMap(cellValue);
|
|
68
|
+
if (emailUserMap) {
|
|
69
|
+
const collaborators = cellValue.map(email => emailUserMap[email]);
|
|
70
|
+
this.setState({
|
|
71
|
+
isLoading: false,
|
|
72
|
+
collaborators: collaborators
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const eventBus = EventBus.getInstance();
|
|
77
|
+
this.unsubscribeUsersChanged = eventBus.subscribe(EXTERNAL_EVENT.COLLABORATORS_UPDATED, this.onCollaboratorsChanged);
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
const {
|
|
81
|
+
isLoading,
|
|
82
|
+
collaborators
|
|
83
|
+
} = this.state;
|
|
84
|
+
if (isLoading) {
|
|
85
|
+
return /*#__PURE__*/React.createElement(_Loading, null);
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
value,
|
|
89
|
+
containerClassName
|
|
90
|
+
} = this.props;
|
|
91
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
92
|
+
collaborators: collaborators,
|
|
93
|
+
value: value,
|
|
94
|
+
containerClassName: containerClassName
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const CustomCollaboratorFormatter = withCollaborators(_CollaboratorFormatter);
|
|
100
|
+
const CustomCreatorFormatter = withCollaborators(_CreatorFormatter);
|
|
101
|
+
export { CustomCollaboratorFormatter, CustomCreatorFormatter };
|
|
@@ -6,7 +6,6 @@ import _EmailFormatter from "dtable-ui-component/lib/EmailFormatter";
|
|
|
6
6
|
import _UrlFormatter from "dtable-ui-component/lib/UrlFormatter";
|
|
7
7
|
import _AutoNumberFormatter from "dtable-ui-component/lib/AutoNumberFormatter";
|
|
8
8
|
import _FormulaFormatter from "dtable-ui-component/lib/FormulaFormatter";
|
|
9
|
-
import _CreatorFormatter from "dtable-ui-component/lib/CreatorFormatter";
|
|
10
9
|
import _MTimeFormatter from "dtable-ui-component/lib/MTimeFormatter";
|
|
11
10
|
import _CTimeFormatter from "dtable-ui-component/lib/CTimeFormatter";
|
|
12
11
|
import _CheckboxFormatter from "dtable-ui-component/lib/CheckboxFormatter";
|
|
@@ -18,12 +17,13 @@ import _GeolocationFormatter from "dtable-ui-component/lib/GeolocationFormatter"
|
|
|
18
17
|
import _FileFormatter from "dtable-ui-component/lib/FileFormatter";
|
|
19
18
|
import _ImageFormatter from "dtable-ui-component/lib/ImageFormatter";
|
|
20
19
|
import _SimpleLongTextFormatter from "dtable-ui-component/lib/SimpleLongTextFormatter";
|
|
21
|
-
import _CollaboratorFormatter from "dtable-ui-component/lib/CollaboratorFormatter";
|
|
22
20
|
import _TextFormatter from "dtable-ui-component/lib/TextFormatter";
|
|
23
21
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
24
22
|
import React, { Fragment } from 'react';
|
|
25
23
|
import { CellType, SELECT_OPTION_COLORS } from 'dtable-utils';
|
|
26
24
|
import { withTranslation } from 'react-i18next';
|
|
25
|
+
import { CustomCollaboratorFormatter, CustomCreatorFormatter } from './collaborator-wrapper';
|
|
26
|
+
import LinkFormatter from './link-formatter';
|
|
27
27
|
class CellFormatter extends React.Component {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments);
|
|
@@ -64,13 +64,11 @@ class CellFormatter extends React.Component {
|
|
|
64
64
|
}
|
|
65
65
|
case CellType.COLLABORATOR:
|
|
66
66
|
{
|
|
67
|
-
// TODO
|
|
68
67
|
if (!Array.isArray(cellValue) || cellValue.length === 0) return this.renderEmptyFormatter();
|
|
69
68
|
cellValue = cellValue.filter(item => item);
|
|
70
69
|
if (cellValue.length === 0) return this.renderEmptyFormatter();
|
|
71
|
-
return /*#__PURE__*/React.createElement(
|
|
70
|
+
return /*#__PURE__*/React.createElement(CustomCollaboratorFormatter, {
|
|
72
71
|
value: cellValue,
|
|
73
|
-
collaborators: collaborators,
|
|
74
72
|
containerClassName: containerClassName
|
|
75
73
|
});
|
|
76
74
|
}
|
|
@@ -173,12 +171,10 @@ class CellFormatter extends React.Component {
|
|
|
173
171
|
case CellType.CREATOR:
|
|
174
172
|
case CellType.LAST_MODIFIER:
|
|
175
173
|
{
|
|
176
|
-
|
|
177
|
-
return /*#__PURE__*/React.createElement(
|
|
174
|
+
if (cellValue.length === 0) return this.renderEmptyFormatter();
|
|
175
|
+
return /*#__PURE__*/React.createElement(CustomCreatorFormatter, {
|
|
178
176
|
value: cellValue,
|
|
179
|
-
|
|
180
|
-
containerClassName: containerClassName,
|
|
181
|
-
renderEmptyFormatter: this.renderEmptyFormatter
|
|
177
|
+
containerClassName: containerClassName
|
|
182
178
|
});
|
|
183
179
|
}
|
|
184
180
|
case CellType.FORMULA:
|
|
@@ -194,8 +190,15 @@ class CellFormatter extends React.Component {
|
|
|
194
190
|
}
|
|
195
191
|
case CellType.LINK:
|
|
196
192
|
{
|
|
197
|
-
|
|
198
|
-
return
|
|
193
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) return this.renderEmptyFormatter();
|
|
194
|
+
return /*#__PURE__*/React.createElement(LinkFormatter, {
|
|
195
|
+
value: cellValue,
|
|
196
|
+
column: column,
|
|
197
|
+
collaborators: collaborators,
|
|
198
|
+
containerClassName: containerClassName,
|
|
199
|
+
renderEmptyFormatter: this.renderEmptyFormatter,
|
|
200
|
+
t: this.props.t
|
|
201
|
+
});
|
|
199
202
|
}
|
|
200
203
|
case CellType.AUTO_NUMBER:
|
|
201
204
|
{
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* link */
|
|
2
|
+
.seatable-view-body-column-cell .document-link-formatter {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
flex-wrap: nowrap;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.seatable-view-body-column-cell .document-link-formatter .document-link-item {
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
height: 20px;
|
|
14
|
+
margin-right: 4px;
|
|
15
|
+
padding: 0 6px;
|
|
16
|
+
font-size: 13px;
|
|
17
|
+
max-width: 100%;
|
|
18
|
+
background: #eceff4;
|
|
19
|
+
border-radius: 3px;
|
|
20
|
+
align-items: center;
|
|
21
|
+
vertical-align: middle;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
line-height: 20px;
|
|
26
|
+
width: fit-content;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.seatable-view-body-column-cell .document-link-formatter .document-checkbox-item {
|
|
30
|
+
width: fit-content;
|
|
31
|
+
margin-right: 10px;
|
|
32
|
+
line-height: 36px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.seatable-view-body-column-cell .document-link-formatter .document-long-text-item {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
margin-right: 10px;
|
|
38
|
+
font-size: 13px;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
flex-shrink: 0;
|
|
41
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import _DepartmentSingleSelectFormatter from "dtable-ui-component/lib/DepartmentSingleSelectFormatter";
|
|
2
|
+
import _LongTextFormatter from "dtable-ui-component/lib/LongTextFormatter";
|
|
3
|
+
import _CheckboxFormatter from "dtable-ui-component/lib/CheckboxFormatter";
|
|
4
|
+
import _MultipleSelectFormatter from "dtable-ui-component/lib/MultipleSelectFormatter";
|
|
5
|
+
import _MTimeFormatter from "dtable-ui-component/lib/MTimeFormatter";
|
|
6
|
+
import _CTimeFormatter from "dtable-ui-component/lib/CTimeFormatter";
|
|
7
|
+
import _DateFormatter from "dtable-ui-component/lib/DateFormatter";
|
|
8
|
+
import _NumberFormatter from "dtable-ui-component/lib/NumberFormatter";
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { CellType, FORMULA_RESULT_TYPE, getDurationDisplayString, getGeolocationDisplayString, getMultipleOptionName } from 'dtable-utils';
|
|
11
|
+
import { CustomCreatorFormatter } from '../collaborator-wrapper';
|
|
12
|
+
import { getCellDisplayValue, getFormulaArrayValue, isArrayFormalColumn } from './utils';
|
|
13
|
+
function LinkFormatter(props) {
|
|
14
|
+
const {
|
|
15
|
+
column,
|
|
16
|
+
value,
|
|
17
|
+
containerClassName,
|
|
18
|
+
collaborators
|
|
19
|
+
} = props;
|
|
20
|
+
const {
|
|
21
|
+
data
|
|
22
|
+
} = column;
|
|
23
|
+
if (!Array.isArray(value) || value.length === 0) return props.renderEmptyFormatter();
|
|
24
|
+
let {
|
|
25
|
+
display_column: displayColumn
|
|
26
|
+
} = data || {};
|
|
27
|
+
if (!displayColumn) return props.renderEmptyFormatter();
|
|
28
|
+
const {
|
|
29
|
+
type: displayColumnType,
|
|
30
|
+
data: displayColumnData
|
|
31
|
+
} = displayColumn;
|
|
32
|
+
const cellValue = getFormulaArrayValue(value, !isArrayFormalColumn(displayColumnType));
|
|
33
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) return props.renderEmptyFormatter();
|
|
34
|
+
switch (displayColumnType) {
|
|
35
|
+
case CellType.TEXT:
|
|
36
|
+
case CellType.AUTO_NUMBER:
|
|
37
|
+
case CellType.EMAIL:
|
|
38
|
+
case CellType.URL:
|
|
39
|
+
{
|
|
40
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: containerClassName
|
|
42
|
+
}, cellValue.map((value, index) => {
|
|
43
|
+
if (!value) return null;
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
46
|
+
className: "document-link-item"
|
|
47
|
+
}, value);
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
case CellType.NUMBER:
|
|
51
|
+
{
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: containerClassName
|
|
54
|
+
}, cellValue.map((value, index) => {
|
|
55
|
+
if (!value && value !== 0) return null;
|
|
56
|
+
return /*#__PURE__*/React.createElement(_NumberFormatter, {
|
|
57
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
58
|
+
containerClassName: "document-link-item",
|
|
59
|
+
data: displayColumnData || {},
|
|
60
|
+
value: value
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
case CellType.DATE:
|
|
65
|
+
{
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: containerClassName
|
|
68
|
+
}, cellValue.map((value, index) => {
|
|
69
|
+
if (!value || typeof value !== 'string') return null;
|
|
70
|
+
const {
|
|
71
|
+
format
|
|
72
|
+
} = displayColumnData || {};
|
|
73
|
+
return /*#__PURE__*/React.createElement(_DateFormatter, {
|
|
74
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
75
|
+
value: value,
|
|
76
|
+
format: format,
|
|
77
|
+
containerClassName: "document-link-item"
|
|
78
|
+
});
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
case CellType.CTIME:
|
|
82
|
+
{
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: containerClassName
|
|
85
|
+
}, cellValue.map((value, index) => {
|
|
86
|
+
if (!value) return null;
|
|
87
|
+
return /*#__PURE__*/React.createElement(_CTimeFormatter, {
|
|
88
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
89
|
+
value: value,
|
|
90
|
+
containerClassName: "document-link-item"
|
|
91
|
+
});
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
case CellType.MTIME:
|
|
95
|
+
{
|
|
96
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: containerClassName
|
|
98
|
+
}, cellValue.map((value, index) => {
|
|
99
|
+
if (!value) return null;
|
|
100
|
+
return /*#__PURE__*/React.createElement(_MTimeFormatter, {
|
|
101
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
102
|
+
value: value,
|
|
103
|
+
containerClassName: "document-link-item"
|
|
104
|
+
});
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
case CellType.DURATION:
|
|
108
|
+
{
|
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: containerClassName
|
|
111
|
+
}, cellValue.map((value, index) => {
|
|
112
|
+
if (!value) return null;
|
|
113
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
115
|
+
className: "document-link-item"
|
|
116
|
+
}, getDurationDisplayString(value, displayColumnData));
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
case CellType.CREATOR:
|
|
120
|
+
case CellType.LAST_MODIFIER:
|
|
121
|
+
{
|
|
122
|
+
return /*#__PURE__*/React.createElement(CustomCreatorFormatter, {
|
|
123
|
+
value: cellValue
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
case CellType.SINGLE_SELECT:
|
|
127
|
+
{
|
|
128
|
+
if (!cellValue || cellValue.length === 0) {
|
|
129
|
+
return props.renderEmptyFormatter();
|
|
130
|
+
}
|
|
131
|
+
const options = displayColumnData && Array.isArray(displayColumnData.options) ? displayColumnData.options : [];
|
|
132
|
+
return /*#__PURE__*/React.createElement(_MultipleSelectFormatter, {
|
|
133
|
+
value: cellValue,
|
|
134
|
+
options: options || [],
|
|
135
|
+
containerClassName: "dtable-dataset-".concat(displayColumnType, "-formatter")
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
case CellType.MULTIPLE_SELECT:
|
|
139
|
+
{
|
|
140
|
+
if (!cellValue || cellValue.length === 0) {
|
|
141
|
+
return props.renderEmptyFormatter();
|
|
142
|
+
}
|
|
143
|
+
const options = displayColumnData && Array.isArray(displayColumnData.options) ? displayColumnData.options : [];
|
|
144
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
className: containerClassName
|
|
146
|
+
}, cellValue.map((value, index) => {
|
|
147
|
+
if (!value) return null;
|
|
148
|
+
const valueDisplayString = Array.isArray(value) ? getMultipleOptionName(options, value) : getMultipleOptionName(options, [value]);
|
|
149
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
151
|
+
className: "document-link-item"
|
|
152
|
+
}, valueDisplayString);
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
case CellType.COLLABORATOR:
|
|
156
|
+
{
|
|
157
|
+
if (!cellValue || cellValue.length === 0) {
|
|
158
|
+
return props.renderEmptyFormatter();
|
|
159
|
+
}
|
|
160
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: containerClassName
|
|
162
|
+
}, cellValue.map((value, index) => {
|
|
163
|
+
if (!value) return null;
|
|
164
|
+
const valueDisplayString = Array.isArray(value) ? getCellDisplayValue({
|
|
165
|
+
[displayColumn.key]: value
|
|
166
|
+
}, displayColumn, collaborators) : getCellDisplayValue({
|
|
167
|
+
[displayColumn.key]: [value]
|
|
168
|
+
}, displayColumn, collaborators);
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
171
|
+
className: "document-link-item"
|
|
172
|
+
}, valueDisplayString);
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
case CellType.CHECKBOX:
|
|
176
|
+
{
|
|
177
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: containerClassName
|
|
179
|
+
}, cellValue.map((value, index) => {
|
|
180
|
+
return /*#__PURE__*/React.createElement(_CheckboxFormatter, {
|
|
181
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
182
|
+
value: Boolean(value),
|
|
183
|
+
containerClassName: "document-".concat(displayColumnType, "-item")
|
|
184
|
+
});
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
case CellType.GEOLOCATION:
|
|
188
|
+
{
|
|
189
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
190
|
+
className: containerClassName
|
|
191
|
+
}, cellValue.map((value, index) => {
|
|
192
|
+
if (!value) return null;
|
|
193
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
195
|
+
className: "document-link-item"
|
|
196
|
+
}, getGeolocationDisplayString(value, displayColumnData, {
|
|
197
|
+
hyphen: ' '
|
|
198
|
+
}));
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
case CellType.LONG_TEXT:
|
|
202
|
+
{
|
|
203
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
className: containerClassName
|
|
205
|
+
}, cellValue.map((value, index) => {
|
|
206
|
+
if (!value) return null;
|
|
207
|
+
return /*#__PURE__*/React.createElement(_LongTextFormatter, {
|
|
208
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
209
|
+
value: value,
|
|
210
|
+
containerClassName: "document-".concat(displayColumnType, "-item")
|
|
211
|
+
});
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
case CellType.FORMULA:
|
|
215
|
+
case CellType.LINK_FORMULA:
|
|
216
|
+
{
|
|
217
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
218
|
+
className: containerClassName
|
|
219
|
+
}, cellValue.map((value, index) => {
|
|
220
|
+
if (!value) return null;
|
|
221
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
222
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
223
|
+
className: "document-link-item"
|
|
224
|
+
}, getCellDisplayValue({
|
|
225
|
+
[displayColumn.key]: value
|
|
226
|
+
}, displayColumn, collaborators));
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
case FORMULA_RESULT_TYPE.BOOL:
|
|
230
|
+
{
|
|
231
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: containerClassName
|
|
233
|
+
}, cellValue.map((value, index) => {
|
|
234
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
235
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
236
|
+
className: "document-link-item"
|
|
237
|
+
}, value + '');
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
case FORMULA_RESULT_TYPE.STRING:
|
|
241
|
+
{
|
|
242
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
243
|
+
className: containerClassName
|
|
244
|
+
}, cellValue.map((value, index) => {
|
|
245
|
+
if (!value) return null;
|
|
246
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
247
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
248
|
+
className: "document-link-item"
|
|
249
|
+
}, value);
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
case CellType.DEPARTMENT_SINGLE_SELECT:
|
|
253
|
+
{
|
|
254
|
+
const {
|
|
255
|
+
userId,
|
|
256
|
+
departments = []
|
|
257
|
+
} = window.seafile || window.seafileConfig;
|
|
258
|
+
if (!userId) return null;
|
|
259
|
+
return cellValue.map((item, index) => {
|
|
260
|
+
return /*#__PURE__*/React.createElement(_DepartmentSingleSelectFormatter, {
|
|
261
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
262
|
+
tip: props.t('Deleted_department'),
|
|
263
|
+
value: item,
|
|
264
|
+
departments: departments,
|
|
265
|
+
containerClassName: containerClassName
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
default:
|
|
270
|
+
{
|
|
271
|
+
return props.renderEmptyFormatter();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export default LinkFormatter;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CellType, getCellValueDisplayString } from 'dtable-utils';
|
|
2
|
+
export const isValidCellValue = value => {
|
|
3
|
+
if (value === undefined) return false;
|
|
4
|
+
if (value === null) return false;
|
|
5
|
+
if (value === '') return false;
|
|
6
|
+
if (JSON.stringify(value) === '{}') return false;
|
|
7
|
+
if (JSON.stringify(value) === '[]') return false;
|
|
8
|
+
return true;
|
|
9
|
+
};
|
|
10
|
+
export const getCellDisplayValue = (record, column, collaborators) => {
|
|
11
|
+
const {
|
|
12
|
+
type,
|
|
13
|
+
data,
|
|
14
|
+
key
|
|
15
|
+
} = column;
|
|
16
|
+
return getCellValueDisplayString(record, type, key, {
|
|
17
|
+
data,
|
|
18
|
+
collaborators,
|
|
19
|
+
geolocationHyphen: ' '
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const getTwoDimensionArrayValue = value => {
|
|
23
|
+
if (!Array.isArray(value)) return [];
|
|
24
|
+
return value.map(item => {
|
|
25
|
+
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
26
|
+
return item;
|
|
27
|
+
}
|
|
28
|
+
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
29
|
+
const {
|
|
30
|
+
display_value
|
|
31
|
+
} = item;
|
|
32
|
+
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
33
|
+
return display_value.map(i => {
|
|
34
|
+
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
35
|
+
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
36
|
+
const {
|
|
37
|
+
display_value
|
|
38
|
+
} = i;
|
|
39
|
+
return display_value;
|
|
40
|
+
}
|
|
41
|
+
return i;
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export const getFormulaArrayValue = function (value) {
|
|
46
|
+
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
47
|
+
if (!Array.isArray(value)) return [];
|
|
48
|
+
if (!isFlat) return getTwoDimensionArrayValue(value);
|
|
49
|
+
return value.map(item => {
|
|
50
|
+
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
51
|
+
return item;
|
|
52
|
+
}
|
|
53
|
+
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
54
|
+
const {
|
|
55
|
+
display_value
|
|
56
|
+
} = item;
|
|
57
|
+
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
58
|
+
return display_value.map(i => {
|
|
59
|
+
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
60
|
+
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
61
|
+
const {
|
|
62
|
+
display_value
|
|
63
|
+
} = i;
|
|
64
|
+
return display_value;
|
|
65
|
+
}
|
|
66
|
+
return i;
|
|
67
|
+
});
|
|
68
|
+
}).flat().filter(item => isValidCellValue(item));
|
|
69
|
+
};
|
|
70
|
+
export function isArrayFormalColumn(columnType) {
|
|
71
|
+
const multipleValueTypes = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
72
|
+
return multipleValueTypes.includes(columnType);
|
|
73
|
+
}
|