dtable-ui-component 4.3.7 → 4.3.8
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/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.js +92 -103
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.js +141 -159
- package/lib/SelectOptionGroup/option.js +24 -40
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +22 -43
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,74 +1,70 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import { getLocale } from '../../lang';
|
|
8
3
|
import MBEditorHeader from '../../MBEditorHeader';
|
|
9
4
|
import './index.css';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _this;
|
|
15
|
-
_classCallCheck(this, MBLinkEditorPopover);
|
|
16
|
-
_this = _super.call(this, props);
|
|
17
|
-
_this.handleHistaryBack = function (e) {
|
|
5
|
+
class MBLinkEditorPopover extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.handleHistaryBack = e => {
|
|
18
9
|
e.preventDefault();
|
|
19
|
-
|
|
10
|
+
this.props.onClosePopover();
|
|
20
11
|
};
|
|
21
|
-
|
|
22
|
-
if (
|
|
12
|
+
this.onContainerClick = event => {
|
|
13
|
+
if (this.editorPopover && this.editorPopover.contains(event.target)) {
|
|
23
14
|
event.stopPropagation();
|
|
24
15
|
event.nativeEvent.stopImmediatePropagation();
|
|
25
16
|
return false;
|
|
26
17
|
}
|
|
27
18
|
};
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
this.onChangeSearch = event => {
|
|
20
|
+
let {
|
|
21
|
+
searchVal
|
|
22
|
+
} = this.state;
|
|
30
23
|
if (searchVal === event.target.value) {
|
|
31
24
|
return;
|
|
32
25
|
}
|
|
33
26
|
searchVal = event.target.value;
|
|
34
|
-
|
|
35
|
-
searchVal
|
|
27
|
+
this.setState({
|
|
28
|
+
searchVal
|
|
36
29
|
});
|
|
37
30
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value
|
|
41
|
-
options
|
|
31
|
+
this.getSelectedOptions = () => {
|
|
32
|
+
let {
|
|
33
|
+
value,
|
|
34
|
+
options
|
|
35
|
+
} = this.props;
|
|
42
36
|
if (!Array.isArray(value)) {
|
|
43
37
|
return [];
|
|
44
38
|
}
|
|
45
|
-
return options.filter(
|
|
39
|
+
return options.filter(option => {
|
|
46
40
|
return value.indexOf(option.email) > -1;
|
|
47
41
|
});
|
|
48
42
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
this.getFilterOptions = () => {
|
|
44
|
+
let {
|
|
45
|
+
options
|
|
46
|
+
} = this.props;
|
|
47
|
+
let {
|
|
48
|
+
searchVal
|
|
49
|
+
} = this.state;
|
|
50
|
+
return searchVal ? options.filter(item => item.name.indexOf(searchVal) > -1) : options;
|
|
55
51
|
};
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
this.onSelectOption = option => {
|
|
53
|
+
this.props.onOptionItemToggle(option);
|
|
58
54
|
};
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
this.onRemoveOption = option => {
|
|
56
|
+
this.props.onOptionItemToggle(option);
|
|
61
57
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
this.renderFilteredOptions = options => {
|
|
59
|
+
let {
|
|
60
|
+
value
|
|
61
|
+
} = this.props;
|
|
62
|
+
return options.map((option, index) => {
|
|
63
|
+
let isSelect = value.some(item => item === option.id);
|
|
68
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
69
65
|
className: "mb-link-option-item",
|
|
70
66
|
key: index,
|
|
71
|
-
onMouseDown:
|
|
67
|
+
onMouseDown: this.onSelectOption.bind(this, option)
|
|
72
68
|
}, /*#__PURE__*/React.createElement("span", {
|
|
73
69
|
className: "mb-option-info"
|
|
74
70
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -79,67 +75,62 @@ var MBLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
79
75
|
}));
|
|
80
76
|
});
|
|
81
77
|
};
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
this.setEditorPopover = editorPopover => {
|
|
79
|
+
this.editorPopover = editorPopover;
|
|
84
80
|
};
|
|
85
|
-
|
|
81
|
+
this.state = {
|
|
86
82
|
searchVal: ''
|
|
87
83
|
};
|
|
88
|
-
return _this;
|
|
89
84
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
}]);
|
|
141
|
-
return MBLinkEditorPopover;
|
|
142
|
-
}(React.Component);
|
|
85
|
+
componentDidMount() {
|
|
86
|
+
history.pushState(null, null, '#'); // eslint-disable-line
|
|
87
|
+
window.addEventListener('popstate', this.handleHistaryBack, false);
|
|
88
|
+
}
|
|
89
|
+
componentWillUnmount() {
|
|
90
|
+
window.removeEventListener('popstate', this.handleHistaryBack, false);
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
const {
|
|
94
|
+
column
|
|
95
|
+
} = this.props;
|
|
96
|
+
const {
|
|
97
|
+
searchVal
|
|
98
|
+
} = this.state;
|
|
99
|
+
let filterOptions = this.getFilterOptions();
|
|
100
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
ref: this.setEditorPopover,
|
|
102
|
+
className: "dtable-ui-mb-editor-popover mb-link-editor-popover",
|
|
103
|
+
onClick: this.onContainerClick
|
|
104
|
+
}, /*#__PURE__*/React.createElement(MBEditorHeader, {
|
|
105
|
+
title: column.name,
|
|
106
|
+
leftContent: /*#__PURE__*/React.createElement("i", {
|
|
107
|
+
className: "dtable-font dtable-icon-return"
|
|
108
|
+
}),
|
|
109
|
+
rightContent: /*#__PURE__*/React.createElement("span", null, getLocale('Done')),
|
|
110
|
+
onLeftClick: this.props.onClosePopover,
|
|
111
|
+
onRightClick: this.props.onClosePopover
|
|
112
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: "dtable-ui-mb-editor-body dtable-ui-mb-link-editor-body"
|
|
114
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: "mb-search-link-items"
|
|
116
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
117
|
+
className: "form-control",
|
|
118
|
+
type: "text",
|
|
119
|
+
placeholder: getLocale('Find_an_option'),
|
|
120
|
+
value: searchVal,
|
|
121
|
+
onChange: this.onChangeSearch,
|
|
122
|
+
onClick: this.onInputClick
|
|
123
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: "mb-link-container"
|
|
125
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: "title"
|
|
127
|
+
}, getLocale('Choose_an_option')), /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
className: "content"
|
|
129
|
+
}, filterOptions.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: "search-result-none"
|
|
131
|
+
}, getLocale('No_options_available')), filterOptions.length > 0 && this.renderFilteredOptions(filterOptions)))));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
143
134
|
MBLinkEditorPopover.defaultProps = {
|
|
144
135
|
isReadOnly: false,
|
|
145
136
|
value: []
|
|
@@ -1,96 +1,88 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import { getLocale } from '../../lang';
|
|
8
3
|
import './index.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_this = _super.call(this, props);
|
|
16
|
-
_this.onValueChanged = function (event) {
|
|
17
|
-
var value = event.target.value;
|
|
18
|
-
_this.setState({
|
|
4
|
+
class PCLinkEditorPopover extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.onValueChanged = event => {
|
|
8
|
+
let value = event.target.value;
|
|
9
|
+
this.setState({
|
|
19
10
|
searchValue: value
|
|
20
11
|
});
|
|
21
12
|
};
|
|
22
|
-
|
|
13
|
+
this.onInputClick = event => {
|
|
23
14
|
event.nativeEvent.stopImmediatePropagation();
|
|
24
15
|
event.stopPropagation();
|
|
25
16
|
};
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
this.onOptionItemToggle = item => {
|
|
18
|
+
this.props.onOptionItemToggle(item);
|
|
28
19
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
this.getFilterOptions = () => {
|
|
21
|
+
let {
|
|
22
|
+
options
|
|
23
|
+
} = this.props;
|
|
24
|
+
let filter = this.state.searchValue.toLowerCase();
|
|
32
25
|
if (!filter) {
|
|
33
26
|
return options;
|
|
34
27
|
}
|
|
35
|
-
return options.filter(
|
|
28
|
+
return options.filter(option => {
|
|
36
29
|
return option.name.toString().toLowerCase().indexOf(filter) > -1;
|
|
37
30
|
});
|
|
38
31
|
};
|
|
39
|
-
|
|
32
|
+
this.state = {
|
|
40
33
|
searchValue: ''
|
|
41
34
|
};
|
|
42
|
-
return _this;
|
|
43
35
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
render() {
|
|
37
|
+
let options = this.getFilterOptions();
|
|
38
|
+
let {
|
|
39
|
+
popoverPosition,
|
|
40
|
+
selectedOptions
|
|
41
|
+
} = this.props;
|
|
42
|
+
let {
|
|
43
|
+
searchValue
|
|
44
|
+
} = this.state;
|
|
45
|
+
let popoverStyle = Object.assign({}, {
|
|
46
|
+
...popoverPosition
|
|
47
|
+
}, {
|
|
48
|
+
position: 'absolute'
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "dtable-ui-editor-popover dtable-ui-link-editor-popover",
|
|
52
|
+
style: popoverStyle
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "link-options-search"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
56
|
+
className: "form-control",
|
|
57
|
+
value: searchValue,
|
|
58
|
+
onChange: this.onValueChanged,
|
|
59
|
+
onClick: this.onInputClick,
|
|
60
|
+
placeholder: getLocale('Find_an_option')
|
|
61
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "link-options-container"
|
|
63
|
+
}, options.length > 0 && options.map((option, index) => {
|
|
64
|
+
let isSelect = selectedOptions.some(selectedOption => {
|
|
65
|
+
return selectedOption.id === option.id;
|
|
55
66
|
});
|
|
56
67
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
key: index,
|
|
69
|
+
className: "link-option-item",
|
|
70
|
+
onClick: this.onOptionItemToggle.bind(this, option)
|
|
59
71
|
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className: "
|
|
61
|
-
}, /*#__PURE__*/React.createElement("
|
|
62
|
-
className: "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
key: index,
|
|
75
|
-
className: "link-option-item",
|
|
76
|
-
onClick: _this2.onOptionItemToggle.bind(_this2, option)
|
|
77
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
78
|
-
className: "option-info"
|
|
79
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
-
className: "option-name",
|
|
81
|
-
title: option.name
|
|
82
|
-
}, option.name)), /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: "option-checked"
|
|
84
|
-
}, isSelect && /*#__PURE__*/React.createElement("i", {
|
|
85
|
-
className: "dtable-font dtable-icon-check-mark"
|
|
86
|
-
})));
|
|
87
|
-
}), options.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
88
|
-
className: "link-option-null"
|
|
89
|
-
}, getLocale('No_options_available'))));
|
|
90
|
-
}
|
|
91
|
-
}]);
|
|
92
|
-
return PCLinkEditorPopover;
|
|
93
|
-
}(React.Component);
|
|
72
|
+
className: "option-info"
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "option-name",
|
|
75
|
+
title: option.name
|
|
76
|
+
}, option.name)), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: "option-checked"
|
|
78
|
+
}, isSelect && /*#__PURE__*/React.createElement("i", {
|
|
79
|
+
className: "dtable-font dtable-icon-check-mark"
|
|
80
|
+
})));
|
|
81
|
+
}), options.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "link-option-null"
|
|
83
|
+
}, getLocale('No_options_available'))));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
94
86
|
PCLinkEditorPopover.defaultProps = {
|
|
95
87
|
popoverPosition: {},
|
|
96
88
|
options: []
|
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import classnames from 'classnames';
|
|
8
3
|
import { CellType, getNumberDisplayString, getDateDisplayString } from 'dtable-utils';
|
|
9
4
|
// link value is get form parant's interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _this;
|
|
15
|
-
_classCallCheck(this, LinkFormatter);
|
|
16
|
-
_this = _super.call(this, props);
|
|
17
|
-
_this.getLinkedCellValue = function (row) {
|
|
5
|
+
class LinkFormatter extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.getLinkedCellValue = row => {
|
|
18
9
|
if (!row) return [];
|
|
19
|
-
|
|
20
|
-
column
|
|
21
|
-
currentTableId
|
|
22
|
-
linkMetaData
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
const {
|
|
11
|
+
column,
|
|
12
|
+
currentTableId,
|
|
13
|
+
linkMetaData
|
|
14
|
+
} = this.props;
|
|
15
|
+
const {
|
|
16
|
+
link_id,
|
|
17
|
+
table_id,
|
|
18
|
+
other_table_id
|
|
19
|
+
} = column.data || {};
|
|
20
|
+
this.linkID = link_id;
|
|
21
|
+
this.tableID = currentTableId === table_id ? table_id : other_table_id;
|
|
22
|
+
this.otherTableID = this.tableID === table_id ? other_table_id : table_id;
|
|
23
|
+
return linkMetaData.getLinkedCellValue(this.linkID, this.tableID, this.otherTableID, row._id);
|
|
31
24
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
enableOpenLinkedRow
|
|
35
|
-
linkMetaData
|
|
25
|
+
this.expandLinkedTableRow = row => {
|
|
26
|
+
let {
|
|
27
|
+
enableOpenLinkedRow,
|
|
28
|
+
linkMetaData
|
|
29
|
+
} = this.props;
|
|
36
30
|
if (enableOpenLinkedRow) {
|
|
37
|
-
linkMetaData.expandLinkedTableRow(row,
|
|
31
|
+
linkMetaData.expandLinkedTableRow(row, this.otherTableID);
|
|
38
32
|
}
|
|
39
33
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
column
|
|
43
|
-
linkMetaData
|
|
44
|
-
|
|
34
|
+
this.getDisplayValues = () => {
|
|
35
|
+
let {
|
|
36
|
+
column,
|
|
37
|
+
linkMetaData
|
|
38
|
+
} = this.props;
|
|
39
|
+
let {
|
|
40
|
+
value: rowIds
|
|
41
|
+
} = this.state;
|
|
45
42
|
if (rowIds && Array.isArray(rowIds) && rowIds.length > 0) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
let linkedTable = linkMetaData.getLinkedTable(this.otherTableID);
|
|
44
|
+
let linkedRows = linkMetaData.getLinkedRows(this.otherTableID, rowIds);
|
|
45
|
+
let result = linkedRows.map((row, index) => {
|
|
46
|
+
let {
|
|
47
|
+
display_column_key: displayColumnKey
|
|
48
|
+
} = column.data;
|
|
49
|
+
let displayValue = this.getDisplayValue(linkedTable, row, displayColumnKey);
|
|
51
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
51
|
key: index,
|
|
53
52
|
className: "link-item",
|
|
54
|
-
onClick:
|
|
53
|
+
onClick: this.expandLinkedTableRow.bind(this, row)
|
|
55
54
|
}, /*#__PURE__*/React.createElement("div", {
|
|
56
55
|
className: "link-name",
|
|
57
56
|
title: displayValue
|
|
@@ -61,13 +60,13 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
61
60
|
}
|
|
62
61
|
return null;
|
|
63
62
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
this.getDisplayValue = (linkedTable, row, displayColumnKey) => {
|
|
64
|
+
let value = row[displayColumnKey];
|
|
65
|
+
let linkedColumn = linkedTable.columns.find(column => column.key === displayColumnKey);
|
|
66
|
+
let {
|
|
67
|
+
type,
|
|
68
|
+
data
|
|
69
|
+
} = linkedColumn;
|
|
71
70
|
// todo: improve
|
|
72
71
|
switch (type) {
|
|
73
72
|
case CellType.NUMBER:
|
|
@@ -76,44 +75,43 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
76
75
|
}
|
|
77
76
|
case CellType.DATE:
|
|
78
77
|
{
|
|
79
|
-
|
|
78
|
+
let {
|
|
79
|
+
format
|
|
80
|
+
} = data;
|
|
80
81
|
return getDateDisplayString(value, format);
|
|
81
82
|
}
|
|
82
83
|
default:
|
|
83
84
|
return value;
|
|
84
85
|
}
|
|
85
86
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
value:
|
|
87
|
+
this.linkID = '';
|
|
88
|
+
this.tableID = '';
|
|
89
|
+
this.otherTableID = '';
|
|
90
|
+
this.state = {
|
|
91
|
+
value: this.getLinkedCellValue(props.row)
|
|
91
92
|
};
|
|
92
|
-
return _this;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "render",
|
|
106
|
-
value: function render() {
|
|
107
|
-
var containerClassName = this.props.containerClassName;
|
|
108
|
-
var classname = classnames('dtable-ui cell-formatter-container link-formatter', containerClassName);
|
|
109
|
-
var displayValues = this.getDisplayValues();
|
|
110
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: classname
|
|
112
|
-
}, displayValues);
|
|
94
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
95
|
+
const {
|
|
96
|
+
row: nextRow
|
|
97
|
+
} = nextProps;
|
|
98
|
+
if (nextRow._id !== this.props.row._id) {
|
|
99
|
+
this.setState({
|
|
100
|
+
value: this.getLinkedCellValue(nextRow)
|
|
101
|
+
});
|
|
113
102
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
const {
|
|
106
|
+
containerClassName
|
|
107
|
+
} = this.props;
|
|
108
|
+
const classname = classnames('dtable-ui cell-formatter-container link-formatter', containerClassName);
|
|
109
|
+
let displayValues = this.getDisplayValues();
|
|
110
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: classname
|
|
112
|
+
}, displayValues);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
117
115
|
LinkFormatter.defaultProps = {
|
|
118
116
|
enableOpenLinkedRow: false,
|
|
119
117
|
currentTableId: '',
|
|
@@ -2,9 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import HtmlLongTextFormatter from '../HtmlLongTextFormatter';
|
|
3
3
|
import SimpleLongTextFormatter from '../SimpleLongTextFormatter';
|
|
4
4
|
function LongTextFormatter(props) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const {
|
|
6
|
+
isSample,
|
|
7
|
+
value,
|
|
8
|
+
containerClassName
|
|
9
|
+
} = props;
|
|
8
10
|
if (isSample) {
|
|
9
11
|
return /*#__PURE__*/React.createElement(SimpleLongTextFormatter, {
|
|
10
12
|
value: value,
|