dtable-ui-component 4.4.3-2 → 4.4.3-alpha1
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 +7 -14
- package/lib/ButtonFormatter/index.js +9 -16
- package/lib/CTimeFormatter/index.js +9 -16
- package/lib/CheckboxEditor/index.js +8 -15
- package/lib/CheckboxFormatter/index.js +8 -15
- package/lib/CollaboratorEditor/index.js +21 -29
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +25 -32
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +18 -25
- package/lib/CollaboratorFormatter/index.js +12 -19
- package/lib/CollaboratorItem/index.js +10 -17
- package/lib/CreatorFormatter/index.js +12 -19
- package/lib/DTableCommonAddTool/index.js +6 -13
- package/lib/DTableCustomizeCollaboratorSelect/index.js +18 -26
- package/lib/DTableCustomizeSelect/index.js +15 -23
- package/lib/DTableFiltersPopover/constants/index.js +33 -38
- package/lib/DTableFiltersPopover/index.js +31 -38
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +46 -53
- package/lib/DTableFiltersPopover/utils/index.js +99 -128
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +26 -34
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +25 -33
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-item.js +120 -128
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +18 -26
- package/lib/DTableFiltersPopover/widgets/rate-item.js +8 -15
- package/lib/DTablePopover/index.js +8 -15
- package/lib/DTablePopover/utils.js +2 -9
- package/lib/DTableRadio/index.js +10 -17
- package/lib/DTableSearchInput/index.js +13 -21
- package/lib/DTableSearchInput/utils.js +2 -9
- package/lib/DTableSelect/dtable-select-label.js +6 -13
- package/lib/DTableSelect/index.js +10 -18
- package/lib/DTableSelect/utils.js +10 -20
- package/lib/DTableSwitch/index.js +7 -14
- package/lib/DateEditor/index.js +22 -30
- package/lib/DateEditor/mb-date-editor-popover/index.js +47 -55
- package/lib/DateEditor/pc-date-editor-popover.js +20 -27
- package/lib/DateFormatter/index.js +9 -16
- package/lib/Department-editor/constants.js +1 -7
- package/lib/Department-editor/department-multiple-select/index.js +24 -32
- package/lib/Department-editor/department-single-select.js +33 -41
- package/lib/Department-editor/index.js +14 -22
- package/lib/Department-editor/selected-departments/index.js +25 -32
- package/lib/Department-editor/utils.js +3 -11
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -16
- package/lib/DigitalSignFormatter/index.js +15 -23
- package/lib/DigitalSignFormatter/utils.js +3 -11
- package/lib/DurationFormatter/index.js +9 -16
- package/lib/EditEditorButton/index.js +5 -12
- package/lib/EmailFormatter/index.js +7 -14
- package/lib/FieldDisplaySetting/field-item.js +14 -21
- package/lib/FieldDisplaySetting/index.js +19 -27
- package/lib/FileEditor/index.js +8 -15
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/FileFormatter/index.js +11 -19
- package/lib/FileItemFormatter/index.js +6 -14
- package/lib/FileItemFormatter/utils.js +2 -9
- package/lib/FileUploader/index.js +4 -11
- package/lib/FormulaFormatter/cell-value-validator.js +18 -24
- package/lib/FormulaFormatter/index.js +32 -39
- package/lib/FormulaFormatter/utils.js +13 -29
- package/lib/GeolocationFormatter/index.js +9 -16
- package/lib/HtmlLongTextFormatter/index.js +9 -17
- package/lib/HtmlLongTextFormatter/markdown2html.js +47 -0
- package/lib/HtmlLongTextFormatter/unified/index.js +400 -0
- package/lib/HtmlLongTextFormatter/vfile/core.js +155 -0
- package/lib/HtmlLongTextFormatter/vfile/index.js +40 -0
- package/lib/ImageFormatter/images-lazy-load.js +9 -16
- package/lib/ImageFormatter/index.js +16 -24
- package/lib/ImageFormatter/utils.js +2 -9
- package/lib/ImagePreviewerLightbox/index.js +12 -19
- package/lib/ImagePreviewerLightbox/utils.js +3 -11
- package/lib/LastModifierFormatter/index.js +12 -19
- package/lib/LinkEditor/index.js +25 -33
- package/lib/LinkEditor/link-editor-option.js +8 -15
- package/lib/LinkEditor/mb-link-editor-popover/index.js +23 -30
- package/lib/LinkEditor/pc-link-editor-popover/index.js +17 -24
- package/lib/LinkFormatter/index.js +13 -20
- package/lib/Loading/index.js +4 -11
- package/lib/LongTextFormatter/index.js +6 -13
- package/lib/MBEditorHeader/index.js +7 -14
- package/lib/MTimeFormatter/index.js +9 -16
- package/lib/ModalPortal/index.js +5 -12
- package/lib/MultipleSelectEditor/index.js +17 -25
- package/lib/MultipleSelectFormatter/index.js +10 -17
- package/lib/NotificationPopover/index.js +16 -24
- package/lib/NumberEditor/index.js +18 -25
- package/lib/NumberFormatter/index.js +9 -16
- package/lib/RateFormatter/index.js +8 -15
- package/lib/RoleStatusEditor/index.js +14 -22
- package/lib/RowExpandEmailFormatter/index.js +10 -17
- package/lib/RowExpandFileFormatter/index.js +8 -16
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +18 -27
- package/lib/RowExpandFormatter/index.js +78 -86
- package/lib/RowExpandFormulaFormatter/index.js +34 -42
- package/lib/RowExpandImageFormatter/index.js +10 -19
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +18 -27
- package/lib/RowExpandImageFormatter/utils.js +2 -9
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +7 -16
- package/lib/RowExpandLinkFormatter/index.js +37 -46
- package/lib/RowExpandLinkFormatter/utils.js +6 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +5 -12
- package/lib/RowExpandRateFormatter/index.js +8 -15
- package/lib/RowExpandUrlFormatter/index.js +14 -21
- package/lib/SelectItem/index.js +4 -12
- package/lib/SelectOptionGroup/KeyCodes.js +1 -7
- package/lib/SelectOptionGroup/index.js +33 -32
- package/lib/SelectOptionGroup/option.js +4 -19
- package/lib/SimpleLongTextFormatter/index.js +20 -27
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +1 -7
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +8 -15
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +7 -14
- package/lib/SingleSelectEditor/index.js +18 -26
- package/lib/SingleSelectFormatter/index.js +9 -16
- package/lib/TextEditor/index.js +7 -14
- package/lib/TextFormatter/index.js +7 -14
- package/lib/UrlFormatter/index.js +7 -14
- package/lib/cellFormatterFactory/index.js +4 -11
- package/lib/common/ClickOutside.js +4 -12
- package/lib/common/delete-tip.js +12 -20
- package/lib/common/modal-portal.js +5 -13
- package/lib/constants/index.js +9 -28
- package/lib/data/dtable-value.js +6 -11
- package/lib/formatterConfig/base-formatter-config.js +46 -53
- package/lib/formatterConfig/index.js +9 -16
- package/lib/hooks/common-hooks.js +4 -11
- package/lib/index.js +75 -432
- package/lib/lang/index.js +13 -24
- package/lib/locals/de.js +1 -7
- package/lib/locals/en.js +1 -7
- package/lib/locals/fr.js +1 -7
- package/lib/locals/zh-CN.js +1 -7
- package/lib/select-editor/index.js +4 -27
- package/lib/select-editor/mb-select-editor-popover/index.js +33 -41
- package/lib/select-editor/pc-select-editor-popover/index.js +19 -26
- package/lib/select-editor/select-editor-option.js +8 -15
- package/lib/toaster/alert.js +11 -18
- package/lib/toaster/index.js +3 -10
- package/lib/toaster/toast.js +8 -16
- package/lib/toaster/toastManager.js +5 -13
- package/lib/toaster/toaster.js +7 -15
- package/lib/utils/dayjs.js +4 -11
- package/lib/utils/editor-utils.js +5 -15
- package/lib/utils/event-bus.js +1 -7
- package/lib/utils/utils.js +6 -17
- package/package.json +77 -63
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "FilterItemUtils", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _filterItemUtils.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.isFilterTermArray = exports.isCheckboxColumn = exports.getUpdatedFilterByTermModifier = exports.getUpdatedFilterBySpecialTerm = exports.getUpdatedFilterBySelectSingle = exports.getUpdatedFilterBySelectMultiple = exports.getUpdatedFilterByRate = exports.getUpdatedFilterByPredicate = exports.getUpdatedFilterByNormalTerm = exports.getUpdatedFilterByCreator = exports.getUpdatedFilterByColumn = exports.getUpdatedFilterByCollaborator = exports.getFormulaColumnFilter = exports.getFilterByColumn = exports.getDateColumnFormat = exports.getColumnOptions = exports.getColumnByKey = exports.generateDefaultUser = void 0;
|
|
14
|
-
var _dtableUtils = require("dtable-utils");
|
|
15
|
-
var _filterItemUtils = _interopRequireDefault(require("./filter-item-utils"));
|
|
16
|
-
var _constants = require("../constants");
|
|
1
|
+
import { FILTER_PREDICATE_TYPE, FILTER_COLUMN_OPTIONS, filterTermModifierNotWithin, filterTermModifierIsWithin, CellType, isDateColumn, isNumericColumn, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, DEFAULT_DATE_FORMAT } from 'dtable-utils';
|
|
2
|
+
import FilterItemUtils from './filter-item-utils';
|
|
3
|
+
import { FORMULA_COLUMN_TYPES, SPECIAL_TERM_TYPE, ARRAY_PREDICATE, STRING_PREDICATE, DATE_EMPTY_LABEL_MAP, MULTIPLE_SELECTOR_COLUMNS } from '../constants';
|
|
17
4
|
const isArrayFilterTermByArrayType = array_type => {
|
|
18
|
-
return
|
|
5
|
+
return COLLABORATOR_COLUMN_TYPES.includes(array_type) || array_type === CellType.SINGLE_SELECT || array_type === CellType.MULTIPLE_SELECT;
|
|
19
6
|
};
|
|
20
|
-
const isFilterTermArray = (column, filterPredicate) => {
|
|
7
|
+
export const isFilterTermArray = (column, filterPredicate) => {
|
|
21
8
|
const {
|
|
22
9
|
type,
|
|
23
10
|
data
|
|
24
11
|
} = column;
|
|
25
|
-
if (
|
|
12
|
+
if (MULTIPLE_SELECTOR_COLUMNS.includes(type)) {
|
|
26
13
|
return true;
|
|
27
14
|
}
|
|
28
|
-
if (type ===
|
|
15
|
+
if (type === CellType.SINGLE_SELECT && [FILTER_PREDICATE_TYPE.IS_ANY_OF, FILTER_PREDICATE_TYPE.IS_NONE_OF].includes(filterPredicate)) {
|
|
29
16
|
return true;
|
|
30
17
|
}
|
|
31
|
-
if (
|
|
18
|
+
if (FORMULA_COLUMN_TYPES.includes(type)) {
|
|
32
19
|
const {
|
|
33
20
|
result_type,
|
|
34
21
|
array_type
|
|
35
22
|
} = data || {};
|
|
36
|
-
if (result_type !==
|
|
23
|
+
if (result_type !== FORMULA_RESULT_TYPE.ARRAY) return false;
|
|
37
24
|
return isArrayFilterTermByArrayType(array_type);
|
|
38
25
|
}
|
|
39
|
-
if (type ===
|
|
26
|
+
if (type === CellType.LINK) {
|
|
40
27
|
const {
|
|
41
28
|
array_type
|
|
42
29
|
} = data || {};
|
|
@@ -44,9 +31,8 @@ const isFilterTermArray = (column, filterPredicate) => {
|
|
|
44
31
|
}
|
|
45
32
|
return false;
|
|
46
33
|
};
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const multipleSelectType = [_dtableUtils.FILTER_PREDICATE_TYPE.CONTAINS, _dtableUtils.FILTER_PREDICATE_TYPE.NOT_CONTAIN];
|
|
34
|
+
export const getUpdatedFilterByCreator = (filter, collaborator) => {
|
|
35
|
+
const multipleSelectType = [FILTER_PREDICATE_TYPE.CONTAINS, FILTER_PREDICATE_TYPE.NOT_CONTAIN];
|
|
50
36
|
let {
|
|
51
37
|
filter_predicate,
|
|
52
38
|
filter_term: filterTerm
|
|
@@ -70,11 +56,10 @@ const getUpdatedFilterByCreator = (filter, collaborator) => {
|
|
|
70
56
|
filter_term: filterTerm
|
|
71
57
|
});
|
|
72
58
|
};
|
|
73
|
-
|
|
74
|
-
const getUpdatedFilterBySelectSingle = (filter, columnOption) => {
|
|
59
|
+
export const getUpdatedFilterBySelectSingle = (filter, columnOption) => {
|
|
75
60
|
let new_filter_term;
|
|
76
61
|
// if predicate is any of / is none of, filter_term is array; else filter_term is string
|
|
77
|
-
if (filter.filter_predicate ===
|
|
62
|
+
if (filter.filter_predicate === FILTER_PREDICATE_TYPE.IS_ANY_OF || filter.filter_predicate === FILTER_PREDICATE_TYPE.IS_NONE_OF) {
|
|
78
63
|
new_filter_term = Array.isArray(filter.filter_term) ? [...filter.filter_term] : [];
|
|
79
64
|
const index = new_filter_term.indexOf(columnOption.id);
|
|
80
65
|
if (index === -1) {
|
|
@@ -89,8 +74,7 @@ const getUpdatedFilterBySelectSingle = (filter, columnOption) => {
|
|
|
89
74
|
filter_term: new_filter_term
|
|
90
75
|
});
|
|
91
76
|
};
|
|
92
|
-
|
|
93
|
-
const getUpdatedFilterBySelectMultiple = (filter, columnOption) => {
|
|
77
|
+
export const getUpdatedFilterBySelectMultiple = (filter, columnOption) => {
|
|
94
78
|
let filterTerm = filter.filter_term ? filter.filter_term : [];
|
|
95
79
|
let index = filterTerm.indexOf(columnOption.id);
|
|
96
80
|
if (index > -1) {
|
|
@@ -102,8 +86,7 @@ const getUpdatedFilterBySelectMultiple = (filter, columnOption) => {
|
|
|
102
86
|
filter_term: filterTerm
|
|
103
87
|
});
|
|
104
88
|
};
|
|
105
|
-
|
|
106
|
-
const getUpdatedFilterByCollaborator = (filter, collaborator) => {
|
|
89
|
+
export const getUpdatedFilterByCollaborator = (filter, collaborator) => {
|
|
107
90
|
let filterTerm = filter.filter_term ? filter.filter_term.slice(0) : [];
|
|
108
91
|
let selectedEmail = collaborator.email;
|
|
109
92
|
let collaborator_index = filterTerm.indexOf(selectedEmail);
|
|
@@ -116,8 +99,7 @@ const getUpdatedFilterByCollaborator = (filter, collaborator) => {
|
|
|
116
99
|
filter_term: filterTerm
|
|
117
100
|
});
|
|
118
101
|
};
|
|
119
|
-
|
|
120
|
-
const getUpdatedFilterByRate = (filter, value) => {
|
|
102
|
+
export const getUpdatedFilterByRate = (filter, value) => {
|
|
121
103
|
if (filter.filter_term === value) {
|
|
122
104
|
return;
|
|
123
105
|
}
|
|
@@ -125,30 +107,28 @@ const getUpdatedFilterByRate = (filter, value) => {
|
|
|
125
107
|
filter_term: value
|
|
126
108
|
});
|
|
127
109
|
};
|
|
128
|
-
|
|
129
|
-
const getColumnOptions = column => {
|
|
110
|
+
export const getColumnOptions = column => {
|
|
130
111
|
const {
|
|
131
112
|
type,
|
|
132
113
|
data
|
|
133
114
|
} = column;
|
|
134
|
-
if (
|
|
115
|
+
if (FORMULA_COLUMN_TYPES.includes(type)) {
|
|
135
116
|
return getFormulaColumnFilterOptions(column);
|
|
136
117
|
}
|
|
137
|
-
if (type ===
|
|
118
|
+
if (type === CellType.LINK) {
|
|
138
119
|
const {
|
|
139
120
|
array_type
|
|
140
121
|
} = data || {};
|
|
141
|
-
if (array_type ===
|
|
142
|
-
return
|
|
122
|
+
if (array_type === FORMULA_RESULT_TYPE.BOOL) {
|
|
123
|
+
return FILTER_COLUMN_OPTIONS[CellType.CHECKBOX];
|
|
143
124
|
}
|
|
144
|
-
if (array_type ===
|
|
145
|
-
return
|
|
125
|
+
if (array_type === FORMULA_RESULT_TYPE.STRING) {
|
|
126
|
+
return FILTER_COLUMN_OPTIONS[CellType.TEXT];
|
|
146
127
|
}
|
|
147
128
|
return getFilterOptionsByArrayType(array_type);
|
|
148
129
|
}
|
|
149
|
-
return
|
|
130
|
+
return FILTER_COLUMN_OPTIONS[type] || {};
|
|
150
131
|
};
|
|
151
|
-
exports.getColumnOptions = getColumnOptions;
|
|
152
132
|
const getFormulaColumnFilterOptions = column => {
|
|
153
133
|
const {
|
|
154
134
|
data
|
|
@@ -157,54 +137,54 @@ const getFormulaColumnFilterOptions = column => {
|
|
|
157
137
|
result_type,
|
|
158
138
|
array_type
|
|
159
139
|
} = data || {};
|
|
160
|
-
if (result_type ===
|
|
161
|
-
return
|
|
140
|
+
if (result_type === FORMULA_RESULT_TYPE.BOOL) {
|
|
141
|
+
return FILTER_COLUMN_OPTIONS[CellType.CHECKBOX];
|
|
162
142
|
}
|
|
163
|
-
if (result_type ===
|
|
164
|
-
return
|
|
143
|
+
if (result_type === FORMULA_RESULT_TYPE.STRING) {
|
|
144
|
+
return FILTER_COLUMN_OPTIONS[CellType.TEXT];
|
|
165
145
|
}
|
|
166
|
-
if ([
|
|
167
|
-
return
|
|
146
|
+
if ([FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.DATE].includes(result_type)) {
|
|
147
|
+
return FILTER_COLUMN_OPTIONS[result_type];
|
|
168
148
|
}
|
|
169
|
-
if (result_type ===
|
|
149
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
170
150
|
return getFilterOptionsByArrayType(array_type);
|
|
171
151
|
}
|
|
172
|
-
return
|
|
152
|
+
return FILTER_COLUMN_OPTIONS[CellType.TEXT];
|
|
173
153
|
};
|
|
174
154
|
const getFilterOptionsByArrayType = array_type => {
|
|
175
155
|
if (!array_type) {
|
|
176
156
|
return {};
|
|
177
157
|
}
|
|
178
158
|
let checkType = array_type;
|
|
179
|
-
if (
|
|
180
|
-
checkType =
|
|
181
|
-
} else if (array_type ===
|
|
182
|
-
checkType =
|
|
183
|
-
} else if (
|
|
184
|
-
checkType =
|
|
185
|
-
} else if (
|
|
159
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
160
|
+
checkType = CellType.COLLABORATOR;
|
|
161
|
+
} else if (array_type === CellType.SINGLE_SELECT) {
|
|
162
|
+
checkType = CellType.MULTIPLE_SELECT;
|
|
163
|
+
} else if (DATE_COLUMN_OPTIONS.includes(array_type)) {
|
|
164
|
+
checkType = CellType.DATE;
|
|
165
|
+
} else if (isNumericColumn({
|
|
186
166
|
type: array_type
|
|
187
167
|
})) {
|
|
188
|
-
checkType =
|
|
168
|
+
checkType = CellType.NUMBER;
|
|
189
169
|
}
|
|
190
170
|
|
|
191
171
|
// only support: is
|
|
192
|
-
if (checkType ===
|
|
193
|
-
return
|
|
172
|
+
if (checkType === CellType.CHECKBOX || checkType === CellType.BOOL) {
|
|
173
|
+
return FILTER_COLUMN_OPTIONS[CellType.CHECKBOX];
|
|
194
174
|
}
|
|
195
|
-
let filterOptions =
|
|
175
|
+
let filterOptions = FILTER_COLUMN_OPTIONS[checkType] || FILTER_COLUMN_OPTIONS[CellType.TEXT];
|
|
196
176
|
let {
|
|
197
177
|
filterPredicateList
|
|
198
178
|
} = filterOptions;
|
|
199
|
-
if (filterPredicateList && !filterPredicateList.includes(
|
|
200
|
-
filterPredicateList.push(
|
|
179
|
+
if (filterPredicateList && !filterPredicateList.includes(FILTER_PREDICATE_TYPE.EMPTY)) {
|
|
180
|
+
filterPredicateList.push(FILTER_PREDICATE_TYPE.EMPTY);
|
|
201
181
|
}
|
|
202
|
-
if (filterPredicateList && !filterPredicateList.includes(
|
|
203
|
-
filterPredicateList.push(
|
|
182
|
+
if (filterPredicateList && !filterPredicateList.includes(FILTER_PREDICATE_TYPE.NOT_EMPTY)) {
|
|
183
|
+
filterPredicateList.push(FILTER_PREDICATE_TYPE.NOT_EMPTY);
|
|
204
184
|
}
|
|
205
185
|
return filterOptions;
|
|
206
186
|
};
|
|
207
|
-
const getFilterByColumn = function (column, value) {
|
|
187
|
+
export const getFilterByColumn = function (column, value) {
|
|
208
188
|
let {
|
|
209
189
|
textDefaultPredicate
|
|
210
190
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
@@ -218,7 +198,7 @@ const getFilterByColumn = function (column, value) {
|
|
|
218
198
|
} = getColumnOptions(column, value);
|
|
219
199
|
if (!filterPredicateList) return;
|
|
220
200
|
let filterPredicate = filterPredicateList[0];
|
|
221
|
-
if (textDefaultPredicate && columnType ===
|
|
201
|
+
if (textDefaultPredicate && columnType === CellType.TEXT && filterPredicateList.includes(textDefaultPredicate)) {
|
|
222
202
|
filterPredicate = textDefaultPredicate;
|
|
223
203
|
}
|
|
224
204
|
let updatedFilter = Object.assign({}, filter, {
|
|
@@ -231,12 +211,12 @@ const getFilterByColumn = function (column, value) {
|
|
|
231
211
|
updatedFilter.filter_term = '';
|
|
232
212
|
|
|
233
213
|
// checkbox
|
|
234
|
-
if (columnType ===
|
|
214
|
+
if (columnType === CellType.CHECKBOX) {
|
|
235
215
|
updatedFilter.filter_term = false;
|
|
236
216
|
return updatedFilter;
|
|
237
217
|
}
|
|
238
218
|
// rate
|
|
239
|
-
if (columnType ===
|
|
219
|
+
if (columnType === CellType.RATE) {
|
|
240
220
|
const {
|
|
241
221
|
rate_max_number
|
|
242
222
|
} = columnData;
|
|
@@ -249,14 +229,14 @@ const getFilterByColumn = function (column, value) {
|
|
|
249
229
|
return updatedFilter;
|
|
250
230
|
}
|
|
251
231
|
// date | ctime | mtime
|
|
252
|
-
if (
|
|
253
|
-
let filterTermModifier = filterPredicate ===
|
|
232
|
+
if (isDateColumn(column)) {
|
|
233
|
+
let filterTermModifier = filterPredicate === FILTER_PREDICATE_TYPE.IS_WITHIN ? filterTermModifierIsWithin[0] : filterTermModifierNotWithin[0];
|
|
254
234
|
updatedFilter.filter_term_modifier = filterTermModifier;
|
|
255
235
|
updatedFilter.filter_term = '';
|
|
256
236
|
return updatedFilter;
|
|
257
237
|
}
|
|
258
238
|
// formula | link-formula
|
|
259
|
-
if (
|
|
239
|
+
if (FORMULA_COLUMN_TYPES.includes(columnType)) {
|
|
260
240
|
const newUpdatedFilter = getFormulaColumnFilter(column, value, filter);
|
|
261
241
|
if (newUpdatedFilter) {
|
|
262
242
|
updatedFilter.filter_term = newUpdatedFilter.filter_term;
|
|
@@ -264,17 +244,17 @@ const getFilterByColumn = function (column, value) {
|
|
|
264
244
|
return updatedFilter;
|
|
265
245
|
}
|
|
266
246
|
// link
|
|
267
|
-
if (columnType ===
|
|
247
|
+
if (columnType === CellType.LINK) {
|
|
268
248
|
let {
|
|
269
249
|
array_type,
|
|
270
250
|
array_data
|
|
271
251
|
} = columnData || {};
|
|
272
252
|
if (array_type) {
|
|
273
|
-
if (array_type ===
|
|
274
|
-
array_type =
|
|
253
|
+
if (array_type === FORMULA_RESULT_TYPE.BOOL) {
|
|
254
|
+
array_type = CellType.CHECKBOX;
|
|
275
255
|
}
|
|
276
|
-
if (array_type ===
|
|
277
|
-
array_type =
|
|
256
|
+
if (array_type === FORMULA_RESULT_TYPE.STRING) {
|
|
257
|
+
array_type = CellType.TEXT;
|
|
278
258
|
}
|
|
279
259
|
const linkedColumn = {
|
|
280
260
|
key: column.key,
|
|
@@ -290,8 +270,7 @@ const getFilterByColumn = function (column, value) {
|
|
|
290
270
|
}
|
|
291
271
|
return updatedFilter;
|
|
292
272
|
};
|
|
293
|
-
|
|
294
|
-
const getFormulaColumnFilter = (column, value, filter) => {
|
|
273
|
+
export const getFormulaColumnFilter = (column, value, filter) => {
|
|
295
274
|
const {
|
|
296
275
|
data
|
|
297
276
|
} = column;
|
|
@@ -300,7 +279,7 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
300
279
|
array_type,
|
|
301
280
|
array_data
|
|
302
281
|
} = data || {};
|
|
303
|
-
if (result_type ===
|
|
282
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
304
283
|
const linkedColumn = {
|
|
305
284
|
key: column.key,
|
|
306
285
|
type: array_type,
|
|
@@ -309,11 +288,11 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
309
288
|
return getFilterByColumn(linkedColumn, value, filter);
|
|
310
289
|
}
|
|
311
290
|
// result_type: string | number | bool | date
|
|
312
|
-
if (result_type ===
|
|
313
|
-
array_type =
|
|
291
|
+
if (result_type === FORMULA_RESULT_TYPE.BOOL) {
|
|
292
|
+
array_type = CellType.CHECKBOX;
|
|
314
293
|
}
|
|
315
|
-
if (result_type ===
|
|
316
|
-
array_type =
|
|
294
|
+
if (result_type === FORMULA_RESULT_TYPE.STRING) {
|
|
295
|
+
array_type = CellType.TEXT;
|
|
317
296
|
}
|
|
318
297
|
const linkedColumn = {
|
|
319
298
|
key: column.key,
|
|
@@ -327,33 +306,32 @@ const getFormulaColumnFilter = (column, value, filter) => {
|
|
|
327
306
|
// text, long-text, number, single-select, date, ctime, mtime, formula, link, geolocation : string
|
|
328
307
|
// checkbox : boolean
|
|
329
308
|
// multiple-select, collaborator, creator, last modifier : array
|
|
330
|
-
|
|
331
|
-
const getUpdatedFilterByColumn = (filters, value, filterIndex, column) => {
|
|
309
|
+
|
|
310
|
+
export const getUpdatedFilterByColumn = (filters, value, filterIndex, column) => {
|
|
332
311
|
const filter = filters[filterIndex];
|
|
333
312
|
if (filter.column_key === column.key) {
|
|
334
313
|
return;
|
|
335
314
|
}
|
|
336
315
|
return getFilterByColumn(column, value, filter);
|
|
337
316
|
};
|
|
338
|
-
|
|
339
|
-
const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
317
|
+
export const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
340
318
|
let updatedFilter = Object.assign({}, filter, {
|
|
341
319
|
filter_predicate: filterPredicate
|
|
342
320
|
});
|
|
343
321
|
let {
|
|
344
322
|
type: columnType
|
|
345
323
|
} = column;
|
|
346
|
-
if (columnType ===
|
|
324
|
+
if (columnType === CellType.CHECKBOX) {
|
|
347
325
|
updatedFilter.filter_term = false;
|
|
348
326
|
return updatedFilter;
|
|
349
327
|
}
|
|
350
|
-
if ([
|
|
351
|
-
if (
|
|
352
|
-
if (
|
|
328
|
+
if ([CellType.SINGLE_SELECT, CellType.DEPARTMENT_SINGLE_SELECT].includes(columnType)) {
|
|
329
|
+
if (ARRAY_PREDICATE[filterPredicate]) {
|
|
330
|
+
if (ARRAY_PREDICATE[filter.filter_predicate] !== ARRAY_PREDICATE[filterPredicate]) {
|
|
353
331
|
updatedFilter.filter_term = [];
|
|
354
332
|
}
|
|
355
|
-
} else if (
|
|
356
|
-
if (
|
|
333
|
+
} else if (STRING_PREDICATE[filterPredicate]) {
|
|
334
|
+
if (STRING_PREDICATE[filter.filter_predicate] !== STRING_PREDICATE[filterPredicate]) {
|
|
357
335
|
updatedFilter.filter_term = '';
|
|
358
336
|
}
|
|
359
337
|
} else {
|
|
@@ -361,26 +339,25 @@ const getUpdatedFilterByPredicate = (filter, column, filterPredicate) => {
|
|
|
361
339
|
}
|
|
362
340
|
return updatedFilter;
|
|
363
341
|
}
|
|
364
|
-
if ([
|
|
365
|
-
if (
|
|
342
|
+
if ([CellType.CREATOR, CellType.LAST_MODIFIER].includes(columnType)) {
|
|
343
|
+
if (STRING_PREDICATE[filter.filter_predicate] !== STRING_PREDICATE[filterPredicate] || filterPredicate === FILTER_PREDICATE_TYPE.INCLUDE_ME) {
|
|
366
344
|
updatedFilter.filter_term = [];
|
|
367
345
|
}
|
|
368
346
|
}
|
|
369
347
|
if (isFilterTermArray(column, filterPredicate)) {
|
|
370
|
-
if (
|
|
348
|
+
if (DATE_EMPTY_LABEL_MAP[filterPredicate] || filterPredicate === FILTER_PREDICATE_TYPE.INCLUDE_ME) {
|
|
371
349
|
updatedFilter.filter_term = [];
|
|
372
350
|
}
|
|
373
351
|
return updatedFilter;
|
|
374
352
|
}
|
|
375
|
-
if (
|
|
376
|
-
let filterTermModifier = filterPredicate ===
|
|
353
|
+
if (isDateColumn(column)) {
|
|
354
|
+
let filterTermModifier = filterPredicate === FILTER_PREDICATE_TYPE.IS_WITHIN ? filterTermModifierIsWithin[0] : filterTermModifierNotWithin[0];
|
|
377
355
|
updatedFilter.filter_term_modifier = filterTermModifier;
|
|
378
356
|
return updatedFilter;
|
|
379
357
|
}
|
|
380
358
|
return updatedFilter;
|
|
381
359
|
};
|
|
382
|
-
|
|
383
|
-
const getUpdatedFilterByTermModifier = (filters, filterIndex, filterTermModifier) => {
|
|
360
|
+
export const getUpdatedFilterByTermModifier = (filters, filterIndex, filterTermModifier) => {
|
|
384
361
|
const filter = filters[filterIndex];
|
|
385
362
|
if (filter.filter_term_modifier === filterTermModifier) {
|
|
386
363
|
return;
|
|
@@ -389,11 +366,10 @@ const getUpdatedFilterByTermModifier = (filters, filterIndex, filterTermModifier
|
|
|
389
366
|
filter_term_modifier: filterTermModifier
|
|
390
367
|
});
|
|
391
368
|
};
|
|
392
|
-
|
|
393
|
-
const getUpdatedFilterByNormalTerm = (filters, column, filterIndex, event) => {
|
|
369
|
+
export const getUpdatedFilterByNormalTerm = (filters, column, filterIndex, event) => {
|
|
394
370
|
const filter = filters[filterIndex];
|
|
395
371
|
let filterTerm;
|
|
396
|
-
if (column.type ===
|
|
372
|
+
if (column.type === CellType.CHECKBOX) {
|
|
397
373
|
filterTerm = event.target.checked;
|
|
398
374
|
} else {
|
|
399
375
|
filterTerm = event.target.value;
|
|
@@ -405,27 +381,26 @@ const getUpdatedFilterByNormalTerm = (filters, column, filterIndex, event) => {
|
|
|
405
381
|
filter_term: filterTerm
|
|
406
382
|
});
|
|
407
383
|
};
|
|
408
|
-
|
|
409
|
-
const getUpdatedFilterBySpecialTerm = (filters, filterIndex, type, value) => {
|
|
384
|
+
export const getUpdatedFilterBySpecialTerm = (filters, filterIndex, type, value) => {
|
|
410
385
|
const filter = filters[filterIndex];
|
|
411
386
|
switch (type) {
|
|
412
|
-
case
|
|
387
|
+
case SPECIAL_TERM_TYPE.CREATOR:
|
|
413
388
|
{
|
|
414
389
|
return getUpdatedFilterByCreator(filter, value);
|
|
415
390
|
}
|
|
416
|
-
case
|
|
391
|
+
case SPECIAL_TERM_TYPE.SINGLE_SELECT:
|
|
417
392
|
{
|
|
418
393
|
return getUpdatedFilterBySelectSingle(filter, value);
|
|
419
394
|
}
|
|
420
|
-
case
|
|
395
|
+
case SPECIAL_TERM_TYPE.MULTIPLE_SELECT:
|
|
421
396
|
{
|
|
422
397
|
return getUpdatedFilterBySelectMultiple(filter, value);
|
|
423
398
|
}
|
|
424
|
-
case
|
|
399
|
+
case SPECIAL_TERM_TYPE.COLLABORATOR:
|
|
425
400
|
{
|
|
426
401
|
return getUpdatedFilterByCollaborator(filter, value);
|
|
427
402
|
}
|
|
428
|
-
case
|
|
403
|
+
case SPECIAL_TERM_TYPE.RATE:
|
|
429
404
|
{
|
|
430
405
|
return getUpdatedFilterByRate(filter, value);
|
|
431
406
|
}
|
|
@@ -435,41 +410,37 @@ const getUpdatedFilterBySpecialTerm = (filters, filterIndex, type, value) => {
|
|
|
435
410
|
}
|
|
436
411
|
}
|
|
437
412
|
};
|
|
438
|
-
|
|
439
|
-
const getColumnByKey = (columns, columnKey) => {
|
|
413
|
+
export const getColumnByKey = (columns, columnKey) => {
|
|
440
414
|
if (!Array.isArray(columns) || !columnKey) return null;
|
|
441
415
|
return columns.find(column => column.key === columnKey);
|
|
442
416
|
};
|
|
443
|
-
|
|
444
|
-
const isCheckboxColumn = column => {
|
|
417
|
+
export const isCheckboxColumn = column => {
|
|
445
418
|
let {
|
|
446
419
|
type,
|
|
447
420
|
data
|
|
448
421
|
} = column;
|
|
449
|
-
if (
|
|
422
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
450
423
|
const {
|
|
451
424
|
result_type,
|
|
452
425
|
array_type
|
|
453
426
|
} = data || {};
|
|
454
|
-
if (result_type ===
|
|
455
|
-
return array_type ===
|
|
427
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
428
|
+
return array_type === CellType.CHECKBOX;
|
|
456
429
|
}
|
|
457
430
|
return false;
|
|
458
431
|
}
|
|
459
|
-
return type ===
|
|
432
|
+
return type === CellType.CHECKBOX;
|
|
460
433
|
};
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
const format = column && column.data && column.data.format ? column.data.format : _dtableUtils.DEFAULT_DATE_FORMAT;
|
|
434
|
+
export const getDateColumnFormat = column => {
|
|
435
|
+
const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
|
|
464
436
|
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
465
437
|
return format;
|
|
466
438
|
};
|
|
467
|
-
exports.getDateColumnFormat = getDateColumnFormat;
|
|
468
439
|
const getMediaUrl = () => {
|
|
469
440
|
var _window, _window$dtable, _window2, _window2$dtablePlugin;
|
|
470
441
|
return ((_window = window) === null || _window === void 0 ? void 0 : (_window$dtable = _window.dtable) === null || _window$dtable === void 0 ? void 0 : _window$dtable.mediaUrl) || ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$dtablePlugin = _window2.dtablePluginConfig) === null || _window2$dtablePlugin === void 0 ? void 0 : _window2$dtablePlugin.mediaUrl) || '/media/';
|
|
471
442
|
};
|
|
472
|
-
const generateDefaultUser = name => {
|
|
443
|
+
export const generateDefaultUser = name => {
|
|
473
444
|
const mediaUrl = getMediaUrl();
|
|
474
445
|
const defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
|
|
475
446
|
return {
|
|
@@ -478,4 +449,4 @@ const generateDefaultUser = name => {
|
|
|
478
449
|
avatar_url: defaultAvatarUrl
|
|
479
450
|
};
|
|
480
451
|
};
|
|
481
|
-
|
|
452
|
+
export { FilterItemUtils };
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _dtableUtils = require("dtable-utils");
|
|
11
|
-
var _DTableCustomizeSelect = _interopRequireDefault(require("../../../DTableCustomizeSelect"));
|
|
12
|
-
var _lang = require("../../../lang");
|
|
13
|
-
require("./index.css");
|
|
14
|
-
class CollaboratorFilter extends _react.Component {
|
|
1
|
+
import React, { Component, Fragment } from 'react';
|
|
2
|
+
import { FILTER_PREDICATE_TYPE } from 'dtable-utils';
|
|
3
|
+
import DTableCustomizeSelect from '../../../DTableCustomizeSelect';
|
|
4
|
+
import { getLocale } from '../../../lang';
|
|
5
|
+
import './index.css';
|
|
6
|
+
class CollaboratorFilter extends Component {
|
|
15
7
|
constructor(props) {
|
|
16
8
|
super(props);
|
|
17
9
|
this.createCollaboratorOptions = (filterIndex, collaborators, filterTerm) => {
|
|
@@ -22,28 +14,28 @@ class CollaboratorFilter extends _react.Component {
|
|
|
22
14
|
filterIndex,
|
|
23
15
|
columnOption: collaborator
|
|
24
16
|
},
|
|
25
|
-
label: /*#__PURE__*/
|
|
17
|
+
label: /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
26
18
|
className: "select-option-name option-collaborator"
|
|
27
|
-
}, /*#__PURE__*/
|
|
19
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
28
20
|
className: "collaborator-container"
|
|
29
|
-
}, /*#__PURE__*/
|
|
21
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
22
|
className: "collaborator"
|
|
31
|
-
}, /*#__PURE__*/
|
|
23
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
32
24
|
className: "collaborator-avatar-container"
|
|
33
|
-
}, /*#__PURE__*/
|
|
25
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
34
26
|
className: "collaborator-avatar",
|
|
35
27
|
alt: collaborator.name,
|
|
36
28
|
src: collaborator.avatar_url
|
|
37
|
-
})), /*#__PURE__*/
|
|
29
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
38
30
|
className: "collaborator-name text-truncate",
|
|
39
31
|
style: {
|
|
40
32
|
maxWidth: '200px'
|
|
41
33
|
},
|
|
42
34
|
title: collaborator.name,
|
|
43
35
|
"aria-label": collaborator.name
|
|
44
|
-
}, collaborator.name))), /*#__PURE__*/
|
|
36
|
+
}, collaborator.name))), /*#__PURE__*/React.createElement("div", {
|
|
45
37
|
className: "collaborator-check-icon"
|
|
46
|
-
}, isSelected && /*#__PURE__*/
|
|
38
|
+
}, isSelected && /*#__PURE__*/React.createElement("i", {
|
|
47
39
|
className: "option-edit dtable-font dtable-icon-check-mark"
|
|
48
40
|
}))))
|
|
49
41
|
};
|
|
@@ -55,7 +47,7 @@ class CollaboratorFilter extends _react.Component {
|
|
|
55
47
|
columnOption: collaborator
|
|
56
48
|
});
|
|
57
49
|
};
|
|
58
|
-
this.supportMultipleSelectOptions = [
|
|
50
|
+
this.supportMultipleSelectOptions = [FILTER_PREDICATE_TYPE.HAS_ANY_OF, FILTER_PREDICATE_TYPE.HAS_ALL_OF, FILTER_PREDICATE_TYPE.HAS_NONE_OF, FILTER_PREDICATE_TYPE.IS_EXACTLY];
|
|
59
51
|
}
|
|
60
52
|
render() {
|
|
61
53
|
let {
|
|
@@ -69,35 +61,35 @@ class CollaboratorFilter extends _react.Component {
|
|
|
69
61
|
let selectedCollaborators = Array.isArray(filterTerm) && filterTerm.length > 0 && filterTerm.map(item => {
|
|
70
62
|
let collaborator = collaborators.find(c => c.email === item);
|
|
71
63
|
if (!collaborator) return null;
|
|
72
|
-
return /*#__PURE__*/
|
|
64
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
65
|
key: item,
|
|
74
66
|
className: "collaborator"
|
|
75
|
-
}, /*#__PURE__*/
|
|
67
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
76
68
|
className: "collaborator-avatar-container"
|
|
77
|
-
}, /*#__PURE__*/
|
|
69
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
78
70
|
className: "collaborator-avatar",
|
|
79
71
|
alt: collaborator.name,
|
|
80
72
|
src: collaborator.avatar_url
|
|
81
|
-
})), /*#__PURE__*/
|
|
73
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
82
74
|
className: "collaborator-name text-truncate",
|
|
83
75
|
title: collaborator.name,
|
|
84
76
|
"aria-label": collaborator.name
|
|
85
|
-
}, collaborator.name), /*#__PURE__*/
|
|
77
|
+
}, collaborator.name), /*#__PURE__*/React.createElement("span", {
|
|
86
78
|
className: "remove-container"
|
|
87
|
-
}, /*#__PURE__*/
|
|
79
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
88
80
|
className: "remove-icon",
|
|
89
81
|
onClick: e => {
|
|
90
82
|
this.onClick(e, collaborator);
|
|
91
83
|
}
|
|
92
|
-
}, /*#__PURE__*/
|
|
84
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
93
85
|
className: "dtable-font dtable-icon-fork-number"
|
|
94
86
|
}))));
|
|
95
87
|
});
|
|
96
88
|
let value = selectedCollaborators ? {
|
|
97
|
-
label: /*#__PURE__*/
|
|
89
|
+
label: /*#__PURE__*/React.createElement(React.Fragment, null, selectedCollaborators)
|
|
98
90
|
} : {};
|
|
99
91
|
let options = Array.isArray(filterTerm) ? this.createCollaboratorOptions(filterIndex, collaborators, filterTerm) : [];
|
|
100
|
-
return /*#__PURE__*/
|
|
92
|
+
return /*#__PURE__*/React.createElement(DTableCustomizeSelect, {
|
|
101
93
|
className: "selector-collaborator",
|
|
102
94
|
value: value,
|
|
103
95
|
onSelectOption: this.props.onSelectCollaborator,
|
|
@@ -106,9 +98,9 @@ class CollaboratorFilter extends _react.Component {
|
|
|
106
98
|
isLocked: this.props.isLocked,
|
|
107
99
|
supportMultipleSelect: isSupportMultipleSelect,
|
|
108
100
|
searchable: true,
|
|
109
|
-
searchPlaceholder:
|
|
101
|
+
searchPlaceholder: getLocale('Find_a_collaborator'),
|
|
110
102
|
isShowSelected: false
|
|
111
103
|
});
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
|
-
|
|
106
|
+
export default CollaboratorFilter;
|