dtable-utils 4.3.5 → 4.3.7
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/index.js +1 -1
- package/es/archive/clause-module/search.js +185 -0
- package/es/archive/clause-module/update.js +121 -0
- package/es/archive/sql-generator/filter-condition.js +15 -7
- package/es/cell-value-get/auto-number.js +17 -0
- package/es/cell-value-get/collaborator.js +14 -1
- package/es/cell-value-set/auto-number.js +85 -0
- package/es/cell-value-set/checkbox.js +5 -0
- package/es/cell-value-set/duration.js +56 -0
- package/es/cell-value-set/geolocation.js +68 -0
- package/es/cell-value-set/image.js +20 -0
- package/es/cell-value-set/long-text.js +27 -0
- package/es/cell-value-set/multiple-select.js +81 -0
- package/es/cell-value-set/number.js +16 -1
- package/es/cell-value-set/single-select.js +47 -0
- package/es/column/file.js +13 -0
- package/es/column/long-text.js +68 -0
- package/es/constants/auto-number.js +7 -0
- package/es/constants/column.js +2 -1
- package/es/constants/formula.js +2 -1
- package/es/constants/limit.js +7 -1
- package/es/constants/permission.js +7 -0
- package/es/filter/filter-column/long-text.js +6 -1
- package/es/helper/patch-utils.js +38 -0
- package/es/index.js +19 -4
- package/es/row/convert.js +201 -2
- package/es/view/summaries.js +11 -2
- package/lib/archive/clause-module/search.js +200 -0
- package/lib/archive/clause-module/update.js +126 -0
- package/lib/archive/sql-generator/filter-condition.js +15 -7
- package/lib/cell-value-get/auto-number.js +21 -0
- package/lib/cell-value-get/collaborator.js +14 -0
- package/lib/cell-value-set/auto-number.js +94 -0
- package/lib/cell-value-set/checkbox.js +9 -0
- package/lib/cell-value-set/duration.js +60 -0
- package/lib/cell-value-set/geolocation.js +72 -0
- package/lib/cell-value-set/image.js +24 -0
- package/lib/cell-value-set/long-text.js +31 -0
- package/lib/cell-value-set/multiple-select.js +86 -0
- package/lib/cell-value-set/number.js +16 -0
- package/lib/cell-value-set/single-select.js +51 -0
- package/lib/column/file.js +21 -0
- package/lib/column/long-text.js +72 -0
- package/lib/constants/auto-number.js +12 -0
- package/lib/constants/column.js +2 -0
- package/lib/constants/formula.js +2 -0
- package/lib/constants/limit.js +8 -0
- package/lib/constants/permission.js +11 -0
- package/lib/filter/filter-column/long-text.js +6 -1
- package/lib/helper/patch-utils.js +47 -0
- package/lib/index.js +64 -20
- package/lib/row/convert.js +204 -0
- package/lib/view/summaries.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import getPreviewContent from '../column/long-text.js';
|
|
2
|
+
import '../constants/column.js';
|
|
3
|
+
import '../constants/filter/filter-column-options.js';
|
|
4
|
+
import '../constants/filter/filter-modifier.js';
|
|
5
|
+
import '../constants/filter/filter-predicate.js';
|
|
6
|
+
import '../constants/filter/filter-is-within.js';
|
|
7
|
+
import '../constants/formula.js';
|
|
8
|
+
import '../constants/sort.js';
|
|
9
|
+
import '../constants/group.js';
|
|
10
|
+
import { LONG_TEXT_CELL_VALUE_LIMIT } from '../constants/limit.js';
|
|
11
|
+
|
|
12
|
+
var formatTextToLongText = function formatTextToLongText(text) {
|
|
13
|
+
var cellValue = text && text.slice(0, LONG_TEXT_CELL_VALUE_LIMIT);
|
|
14
|
+
var _getPreviewContent = getPreviewContent(cellValue),
|
|
15
|
+
preview = _getPreviewContent.preview,
|
|
16
|
+
images = _getPreviewContent.images,
|
|
17
|
+
links = _getPreviewContent.links;
|
|
18
|
+
var value = {
|
|
19
|
+
text: cellValue,
|
|
20
|
+
preview: preview,
|
|
21
|
+
images: images,
|
|
22
|
+
links: links
|
|
23
|
+
};
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { formatTextToLongText };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import '../constants/column.js';
|
|
2
|
+
import '../constants/filter/filter-column-options.js';
|
|
3
|
+
import '../constants/filter/filter-modifier.js';
|
|
4
|
+
import '../constants/filter/filter-predicate.js';
|
|
5
|
+
import '../constants/filter/filter-is-within.js';
|
|
6
|
+
import '../constants/formula.js';
|
|
7
|
+
import { SELECT_OPTION_COLORS } from '../constants/select-option.js';
|
|
8
|
+
import '../constants/sort.js';
|
|
9
|
+
import '../constants/group.js';
|
|
10
|
+
import { generateOptionID } from '../column/option.js';
|
|
11
|
+
import '@babel/runtime/helpers/typeof';
|
|
12
|
+
import { formatTextToSingleOption } from './single-select.js';
|
|
13
|
+
|
|
14
|
+
var formatTextToMultipleOption = function formatTextToMultipleOption(value, column) {
|
|
15
|
+
var formatValue = typeof value === 'number' ? value + '' : value;
|
|
16
|
+
if (!formatValue || !formatValue.trim()) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var optionName = formatValue.trim();
|
|
20
|
+
var options = null;
|
|
21
|
+
if (column.data) {
|
|
22
|
+
options = column.data && column.data.options;
|
|
23
|
+
} else {
|
|
24
|
+
column.data = {};
|
|
25
|
+
}
|
|
26
|
+
if (!options || !Array.isArray(options)) {
|
|
27
|
+
column.data.options = [];
|
|
28
|
+
options = [];
|
|
29
|
+
}
|
|
30
|
+
// is exist
|
|
31
|
+
var option = options.find(function (option) {
|
|
32
|
+
return option.name === optionName;
|
|
33
|
+
});
|
|
34
|
+
if (option) {
|
|
35
|
+
return [option.id];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// not exist
|
|
39
|
+
var optionNames = optionName.split(' ');
|
|
40
|
+
var optionIds = optionNames.map(function (optionName) {
|
|
41
|
+
return formatTextToSingleOption(optionName, column);
|
|
42
|
+
});
|
|
43
|
+
return optionIds;
|
|
44
|
+
};
|
|
45
|
+
var formatValueToMultipleOption = function formatValueToMultipleOption(value, column) {
|
|
46
|
+
if (!value || !Array.isArray(value)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
var options;
|
|
50
|
+
if (column.data) {
|
|
51
|
+
options = column.data && column.data.options;
|
|
52
|
+
} else {
|
|
53
|
+
column.data = {};
|
|
54
|
+
}
|
|
55
|
+
if (!options || !Array.isArray(options)) {
|
|
56
|
+
column.data.options = [];
|
|
57
|
+
options = [];
|
|
58
|
+
}
|
|
59
|
+
var selectOptions = value.map(function (optionName) {
|
|
60
|
+
var option = options.find(function (option) {
|
|
61
|
+
return option.name === optionName;
|
|
62
|
+
});
|
|
63
|
+
if (option) return option;
|
|
64
|
+
var random = Math.floor(Math.random() * (SELECT_OPTION_COLORS.length - 1));
|
|
65
|
+
var optionColor = SELECT_OPTION_COLORS[random];
|
|
66
|
+
var newOption = {
|
|
67
|
+
id: generateOptionID(options),
|
|
68
|
+
name: optionName,
|
|
69
|
+
color: optionColor.COLOR,
|
|
70
|
+
textColor: optionColor.TEXT_COLOR
|
|
71
|
+
};
|
|
72
|
+
column.data.options.push(newOption);
|
|
73
|
+
return newOption;
|
|
74
|
+
});
|
|
75
|
+
var optionIds = selectOptions.map(function (option) {
|
|
76
|
+
return option.id;
|
|
77
|
+
});
|
|
78
|
+
return optionIds.length > 0 ? optionIds : null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { formatTextToMultipleOption, formatValueToMultipleOption };
|
|
@@ -101,5 +101,20 @@ var formatDurationToNumber = function formatDurationToNumber(duration, data) {
|
|
|
101
101
|
var result = hours * 3600 + minutes * 60 + seconds;
|
|
102
102
|
return isNegative ? -result : result;
|
|
103
103
|
};
|
|
104
|
+
var formatTextToNumber = function formatTextToNumber(value) {
|
|
105
|
+
if (typeof value === 'number') {
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
if (!value || !value.trim()) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
var newValue = value.trim();
|
|
112
|
+
var isIncludePercent = String(newValue).indexOf('%') > -1;
|
|
113
|
+
var newData = parseFloat(newValue.replace(/[^.-\d]/g, ''));
|
|
114
|
+
if (isIncludePercent && !isNaN(newData)) {
|
|
115
|
+
return newData / 100;
|
|
116
|
+
}
|
|
117
|
+
return isNaN(newData) ? null : newData;
|
|
118
|
+
};
|
|
104
119
|
|
|
105
|
-
export { formatDurationToNumber, formatStringToNumber, getFloatNumber };
|
|
120
|
+
export { formatDurationToNumber, formatStringToNumber, formatTextToNumber, getFloatNumber };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import '../constants/column.js';
|
|
2
|
+
import '../constants/filter/filter-column-options.js';
|
|
3
|
+
import '../constants/filter/filter-modifier.js';
|
|
4
|
+
import '../constants/filter/filter-predicate.js';
|
|
5
|
+
import '../constants/filter/filter-is-within.js';
|
|
6
|
+
import '../constants/formula.js';
|
|
7
|
+
import { SELECT_OPTION_COLORS } from '../constants/select-option.js';
|
|
8
|
+
import '../constants/sort.js';
|
|
9
|
+
import '../constants/group.js';
|
|
10
|
+
import { generateOptionID } from '../column/option.js';
|
|
11
|
+
import '@babel/runtime/helpers/typeof';
|
|
12
|
+
|
|
13
|
+
var formatTextToSingleOption = function formatTextToSingleOption(value, column) {
|
|
14
|
+
var formatValue = typeof value === 'number' ? value + '' : value;
|
|
15
|
+
if (!formatValue || !formatValue.trim()) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var optionName = formatValue;
|
|
19
|
+
var options;
|
|
20
|
+
if (column.data) {
|
|
21
|
+
options = column.data && column.data.options;
|
|
22
|
+
} else {
|
|
23
|
+
column.data = {};
|
|
24
|
+
}
|
|
25
|
+
if (!options || !Array.isArray(options)) {
|
|
26
|
+
column.data.options = [];
|
|
27
|
+
options = [];
|
|
28
|
+
}
|
|
29
|
+
var option = options.find(function (option) {
|
|
30
|
+
return option.name === optionName;
|
|
31
|
+
});
|
|
32
|
+
if (option) {
|
|
33
|
+
return option.id;
|
|
34
|
+
}
|
|
35
|
+
var random = Math.floor(Math.random() * (SELECT_OPTION_COLORS.length - 1));
|
|
36
|
+
var optionColor = SELECT_OPTION_COLORS[random];
|
|
37
|
+
var newOption = {
|
|
38
|
+
id: generateOptionID(options),
|
|
39
|
+
name: optionName,
|
|
40
|
+
color: optionColor.COLOR,
|
|
41
|
+
textColor: optionColor.TEXT_COLOR
|
|
42
|
+
};
|
|
43
|
+
column.data.options.push(newOption);
|
|
44
|
+
return newOption.id;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { formatTextToSingleOption };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
|
+
|
|
3
|
+
var isFileValue = function isFileValue(object) {
|
|
4
|
+
if (_typeof(object) !== 'object') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
var needKeys = ['name', 'size', 'url', 'type'];
|
|
8
|
+
return needKeys.every(function (key) {
|
|
9
|
+
return object[key] || object[key] === 0;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { isFileValue };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var hrefReg = /\[.+\]\(\S+\)|<img src=(\S+).+\/>|!\[\]\(\S+\)|<\S+>/g;
|
|
2
|
+
var imageReg1 = /^<img src="(\S+)" .+\/>/;
|
|
3
|
+
var imageReg2 = /^!\[\]\((\S+)\)/;
|
|
4
|
+
var linkReg1 = /^\[.+\]\(\S+\)/;
|
|
5
|
+
var linkReg2 = /^<(\S+)>$/;
|
|
6
|
+
function getLinks(hrefs) {
|
|
7
|
+
var hrefObj = {
|
|
8
|
+
links: [],
|
|
9
|
+
images: []
|
|
10
|
+
};
|
|
11
|
+
hrefs.forEach(function (href) {
|
|
12
|
+
if (href.search(linkReg1) >= 0) {
|
|
13
|
+
hrefObj.links.push(href);
|
|
14
|
+
} else if (href.search(linkReg2) >= 0) {
|
|
15
|
+
hrefObj.links.push(href.match(linkReg2)[1]);
|
|
16
|
+
} else {
|
|
17
|
+
var imageSrcs = href.match(imageReg1);
|
|
18
|
+
var imageSrcs1 = href.match(imageReg2);
|
|
19
|
+
if (imageSrcs) {
|
|
20
|
+
hrefObj.images.push(imageSrcs[1]);
|
|
21
|
+
} else if (imageSrcs1) {
|
|
22
|
+
hrefObj.images.push(imageSrcs1[1]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return hrefObj;
|
|
27
|
+
}
|
|
28
|
+
function getPreviewContent(markdownContent) {
|
|
29
|
+
var preview = '';
|
|
30
|
+
var newMarkdownContent = markdownContent.replace(hrefReg, '');
|
|
31
|
+
var newMarkdownLength = newMarkdownContent.length;
|
|
32
|
+
for (var index = 0; index < newMarkdownLength; index++) {
|
|
33
|
+
var letter = newMarkdownContent[index];
|
|
34
|
+
if (letter === '#') {
|
|
35
|
+
continue;
|
|
36
|
+
} else if (letter === '\n') {
|
|
37
|
+
preview += ' ';
|
|
38
|
+
} else if (letter === '`') {
|
|
39
|
+
continue;
|
|
40
|
+
} else if (letter === '*') {
|
|
41
|
+
continue;
|
|
42
|
+
} else {
|
|
43
|
+
preview += newMarkdownContent[index];
|
|
44
|
+
}
|
|
45
|
+
if (preview.length === 150) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
preview = preview.length === newMarkdownLength ? preview : "".concat(preview, "...");
|
|
50
|
+
var hrefs = markdownContent.match(hrefReg);
|
|
51
|
+
if (hrefs) {
|
|
52
|
+
var _getLinks = getLinks(hrefs),
|
|
53
|
+
images = _getLinks.images,
|
|
54
|
+
links = _getLinks.links;
|
|
55
|
+
return {
|
|
56
|
+
preview: preview,
|
|
57
|
+
images: images,
|
|
58
|
+
links: links
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
preview: preview,
|
|
63
|
+
images: [],
|
|
64
|
+
links: []
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { getPreviewContent as default };
|
package/es/constants/column.js
CHANGED
|
@@ -172,8 +172,9 @@ var DATE_DEFAULT_TYPES = {
|
|
|
172
172
|
DAYS_AFTER: 'days_after'
|
|
173
173
|
};
|
|
174
174
|
var FILL_DEFAULT_VALUE_COLUMNS_TYPE = [CellType.TEXT, CellType.NUMBER, CellType.SINGLE_SELECT, CellType.RATE, CellType.CHECKBOX, CellType.LONG_TEXT, CellType.DATE, CellType.COLLABORATOR, CellType.DEPARTMENT_SINGLE_SELECT];
|
|
175
|
+
var NOT_SUPPORT_EDIT_COLUMN_TYPE = [CellType.CTIME, CellType.MTIME, CellType.CREATOR, CellType.LAST_MODIFIER, CellType.FORMULA, CellType.AUTO_NUMBER, CellType.BUTTON, CellType.LINK_FORMULA];
|
|
175
176
|
var NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP = (_NOT_SUPPORT_EDIT_COL = {}, _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.CTIME, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.MTIME, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.CREATOR, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.LAST_MODIFIER, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.FORMULA, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.AUTO_NUMBER, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.BUTTON, true), _defineProperty(_NOT_SUPPORT_EDIT_COL, CellType.LINK_FORMULA, true), _NOT_SUPPORT_EDIT_COL);
|
|
176
177
|
var MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP = (_MULTIPLE_CELL_VALUE_ = {}, _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.MULTIPLE_SELECT, true), _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.COLLABORATOR, true), _defineProperty(_MULTIPLE_CELL_VALUE_, CellType.LINK, true), _MULTIPLE_CELL_VALUE_);
|
|
177
178
|
var SINGLE_CELL_VALUE_COLUMN_TYPE_MAP = (_SINGLE_CELL_VALUE_CO = {}, _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.TEXT, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.DATE, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.CTIME, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.MTIME, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.NUMBER, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.CHECKBOX, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.SINGLE_SELECT, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.CREATOR, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.GEOLOCATION, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.FORMULA, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.LINK_FORMULA, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.URL, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.EMAIL, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.DURATION, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.RATE, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.LAST_MODIFIER, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.DIGITAL_SIGN, true), _defineProperty(_SINGLE_CELL_VALUE_CO, CellType.DEPARTMENT_SINGLE_SELECT, true), _SINGLE_CELL_VALUE_CO);
|
|
178
179
|
|
|
179
|
-
export { COLLABORATOR_COLUMN_TYPES, COLUMNS_ICON_CONFIG, COLUMN_OPTIONS, DATE_COLUMN_OPTIONS, DATE_DEFAULT_TYPES, DATE_FORMAT_MAP, DATE_UNIT, DEFAULT_DATE_FORMAT, DEFAULT_NUMBER_FORMAT, DEPARTMENT_SELECT_RANGE_MAP, DURATION_DECIMAL_DIGITS, DURATION_FORMATS, DURATION_FORMATS_MAP, DURATION_ZERO_DISPLAY, FILL_DEFAULT_VALUE_COLUMNS_TYPE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP, NUMERIC_COLUMNS_TYPES, SINGLE_CELL_VALUE_COLUMN_TYPE_MAP, UTC_FORMAT_DEFAULT };
|
|
180
|
+
export { COLLABORATOR_COLUMN_TYPES, COLUMNS_ICON_CONFIG, COLUMN_OPTIONS, DATE_COLUMN_OPTIONS, DATE_DEFAULT_TYPES, DATE_FORMAT_MAP, DATE_UNIT, DEFAULT_DATE_FORMAT, DEFAULT_NUMBER_FORMAT, DEPARTMENT_SELECT_RANGE_MAP, DURATION_DECIMAL_DIGITS, DURATION_FORMATS, DURATION_FORMATS_MAP, DURATION_ZERO_DISPLAY, FILL_DEFAULT_VALUE_COLUMNS_TYPE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, NOT_SUPPORT_EDIT_COLUMN_TYPE, NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP, NUMERIC_COLUMNS_TYPES, SINGLE_CELL_VALUE_COLUMN_TYPE_MAP, UTC_FORMAT_DEFAULT };
|
package/es/constants/formula.js
CHANGED
|
@@ -9,7 +9,8 @@ var FORMULA_RESULT_TYPE = {
|
|
|
9
9
|
BOOL: 'bool',
|
|
10
10
|
ARRAY: 'array'
|
|
11
11
|
};
|
|
12
|
+
var FORMULA_COLUMN_TYPES = [CellType.FORMULA, CellType.LINK_FORMULA];
|
|
12
13
|
var FORMULA_COLUMN_TYPES_MAP = (_FORMULA_COLUMN_TYPES = {}, _defineProperty(_FORMULA_COLUMN_TYPES, CellType.FORMULA, true), _defineProperty(_FORMULA_COLUMN_TYPES, CellType.LINK_FORMULA, true), _FORMULA_COLUMN_TYPES);
|
|
13
14
|
var DISPLAY_INTERNAL_ERRORS = ['#ERROR!', '#DIV/0!', '#NAME?', '#N/A', '#NULL!', '#NUM!', '#REF!', '#VALUE!', '#GETTING_DATA'];
|
|
14
15
|
|
|
15
|
-
export { DISPLAY_INTERNAL_ERRORS, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE };
|
|
16
|
+
export { DISPLAY_INTERNAL_ERRORS, FORMULA_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE };
|
package/es/constants/limit.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
var CONVERT_ROW_COLUMNS_LIMIT = 500;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// convert row text value limit
|
|
4
|
+
var TEXT_CELL_VALUE_LIMIT = 10000;
|
|
5
|
+
|
|
6
|
+
// convert row long-text value limit
|
|
7
|
+
var LONG_TEXT_CELL_VALUE_LIMIT = 10 * 10000;
|
|
8
|
+
|
|
9
|
+
export { CONVERT_ROW_COLUMNS_LIMIT, LONG_TEXT_CELL_VALUE_LIMIT, TEXT_CELL_VALUE_LIMIT };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
2
|
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
3
|
+
import { isEmptyObject } from '../../common.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Filter long-text
|
|
@@ -13,7 +14,11 @@ var longTextFilter = function longTextFilter(value, _ref) {
|
|
|
13
14
|
if (typeof value === 'string') {
|
|
14
15
|
text = value.trim();
|
|
15
16
|
} else if (_typeof(value) === 'object') {
|
|
16
|
-
|
|
17
|
+
if (isEmptyObject(value)) {
|
|
18
|
+
text = null;
|
|
19
|
+
} else {
|
|
20
|
+
text = typeof value.text === 'string' ? value.text.trim() : null;
|
|
21
|
+
}
|
|
17
22
|
} else {
|
|
18
23
|
text = null;
|
|
19
24
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
|
+
|
|
4
|
+
var PatchUtils = /*#__PURE__*/function () {
|
|
5
|
+
function PatchUtils() {
|
|
6
|
+
_classCallCheck(this, PatchUtils);
|
|
7
|
+
}
|
|
8
|
+
_createClass(PatchUtils, null, [{
|
|
9
|
+
key: "getUsername",
|
|
10
|
+
value: function getUsername(username) {
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
return window.dtable && window.dtable.username;
|
|
13
|
+
}
|
|
14
|
+
// username maybe not a email(form)
|
|
15
|
+
if (username && username.indexOf('@') === -1) return '';
|
|
16
|
+
return username;
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
key: "getUserId",
|
|
20
|
+
value: function getUserId(userId) {
|
|
21
|
+
if (typeof window !== 'undefined') {
|
|
22
|
+
return window.dtable && window.dtable.userId;
|
|
23
|
+
}
|
|
24
|
+
return userId;
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "getUserDepartmentIdsMap",
|
|
28
|
+
value: function getUserDepartmentIdsMap(userDepartmentIdsMap) {
|
|
29
|
+
if (typeof window !== 'undefined' && window.dtable && window.dtable.userDepartmentIdsMap) {
|
|
30
|
+
return window.dtable.userDepartmentIdsMap;
|
|
31
|
+
}
|
|
32
|
+
return userDepartmentIdsMap;
|
|
33
|
+
}
|
|
34
|
+
}]);
|
|
35
|
+
return PatchUtils;
|
|
36
|
+
}();
|
|
37
|
+
|
|
38
|
+
export { PatchUtils as default };
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CellType } from './constants/cell-type.js';
|
|
2
2
|
export { COLLABORATOR_COLUMN_TYPES, COLUMNS_ICON_CONFIG, COLUMN_OPTIONS, DATE_COLUMN_OPTIONS, DATE_DEFAULT_TYPES, DATE_FORMAT_MAP, DATE_UNIT, DEFAULT_DATE_FORMAT, DEFAULT_NUMBER_FORMAT, DEPARTMENT_SELECT_RANGE_MAP, DURATION_DECIMAL_DIGITS, DURATION_FORMATS, DURATION_FORMATS_MAP, DURATION_ZERO_DISPLAY, FILL_DEFAULT_VALUE_COLUMNS_TYPE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP, NUMERIC_COLUMNS_TYPES, SINGLE_CELL_VALUE_COLUMN_TYPE_MAP, UTC_FORMAT_DEFAULT } from './constants/column.js';
|
|
3
3
|
export { FILTER_CONJUNCTION_TYPE, FILTER_ERR_MSG } from './constants/filter/index.js';
|
|
4
|
-
export { DISPLAY_INTERNAL_ERRORS, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE } from './constants/formula.js';
|
|
4
|
+
export { DISPLAY_INTERNAL_ERRORS, FORMULA_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE } from './constants/formula.js';
|
|
5
5
|
export { HIGHLIGHT_COLORS, SELECT_OPTION_COLORS } from './constants/select-option.js';
|
|
6
6
|
export { NUMBER_SORTER_COLUMN_TYPES, SORT_COLUMN_OPTIONS, SORT_TYPE, TEXT_SORTER_COLUMN_TYPES } from './constants/sort.js';
|
|
7
7
|
export { DISPLAY_GROUP_DATE_GRANULARITY, DISPLAY_GROUP_GEOLOCATION_GRANULARITY, GROUP_DATE_GRANULARITY, GROUP_GEOLOCATION_GRANULARITY, MAX_GROUP_LEVEL, SUPPORT_GROUP_COLUMN_TYPES } from './constants/group.js';
|
|
@@ -10,12 +10,14 @@ export { TABLE_PERMISSION_TYPE } from './constants/table-permission.js';
|
|
|
10
10
|
export { REG_NUMBER_DIGIT, REG_STRING_NUMBER_PARTS } from './constants/reg.js';
|
|
11
11
|
export { COLOR_GRADATION_OPTIONS } from './constants/color.js';
|
|
12
12
|
export { HEADER_HEIGHT_TYPE } from './constants/grid-header.js';
|
|
13
|
+
export { AUTO_NUMBER_DATE_FORMAT, AUTO_NUMBER_PREFIX_TYPE } from './constants/auto-number.js';
|
|
14
|
+
export { PERMISSION_TYPES } from './constants/permission.js';
|
|
13
15
|
export { generatorBase64Code, isEmpty, isEmptyObject } from './common.js';
|
|
14
16
|
export { getTableById, getTableByIndex, getTableByName } from './table/core.js';
|
|
15
17
|
export { getTableColumnByKey, getTableColumnByName } from './table/column.js';
|
|
16
18
|
export { getRowById, getRowsByIds } from './table/row.js';
|
|
17
19
|
export { isTableRows } from './row/core.js';
|
|
18
|
-
export { convertRow } from './row/convert.js';
|
|
20
|
+
export { convertRow, convertRowBack } from './row/convert.js';
|
|
19
21
|
export { getLinkColumnsUsedInFilters, getNonArchiveViews, getViewById, getViewByName, getViewShownColumns, isArchiveView, isDefaultView, isFilterView, isGroupView, isHiddenColumnsView, isSortView } from './view/core.js';
|
|
20
22
|
export { getSummaries, getSummariesWithSubgroups, updateGroupSummaries } from './view/summaries.js';
|
|
21
23
|
export { getFormulaColumnsContainLinks, getSortedFormulaColumns, getSortedFormulaColumnsContainLinks, transLink2LinkFormula } from './view/formula.js';
|
|
@@ -25,19 +27,30 @@ export { getDateDisplayString } from './cell-value-get/date.js';
|
|
|
25
27
|
export { getDurationDisplayString } from './cell-value-get/duration.js';
|
|
26
28
|
export { getNumberDisplayString, getPrecisionNumber, replaceNumberNotAllowInput } from './cell-value-get/number.js';
|
|
27
29
|
export { getColumnOptionNameById, getMultipleOptionName, getOption, getOptionName } from './cell-value-get/option.js';
|
|
28
|
-
export { getCollaborator, getCollaboratorsName, getCollaboratorsNames } from './cell-value-get/collaborator.js';
|
|
30
|
+
export { getCollaborator, getCollaboratorEmailsByNames, getCollaboratorsName, getCollaboratorsNames } from './cell-value-get/collaborator.js';
|
|
29
31
|
export { getGeolocationByGranularity, getGeolocationDisplayString } from './cell-value-get/geolocation.js';
|
|
30
32
|
export { getDepartmentName } from './cell-value-get/department.js';
|
|
31
33
|
export { getDigitalSignImageUrl } from './cell-value-get/digital-sign.js';
|
|
32
34
|
export { getLongtextDisplayString } from './cell-value-get/long-text.js';
|
|
33
35
|
export { getCellValueDisplayString, getCellValueStringResult, getFormulaDisplayString } from './cell-value-get/cell-value.js';
|
|
34
36
|
export { getRateDisplayString } from './cell-value-get/rate.js';
|
|
35
|
-
export {
|
|
37
|
+
export { getFormattedAutoNumber } from './cell-value-get/auto-number.js';
|
|
38
|
+
export { formatDurationToNumber, formatStringToNumber, formatTextToNumber, getFloatNumber } from './cell-value-set/number.js';
|
|
39
|
+
export { formatTextToCheckbox } from './cell-value-set/checkbox.js';
|
|
36
40
|
export { formatTextToDate } from './cell-value-set/date.js';
|
|
41
|
+
export { formatTextToSingleOption } from './cell-value-set/single-select.js';
|
|
42
|
+
export { formatTextToMultipleOption, formatValueToMultipleOption } from './cell-value-set/multiple-select.js';
|
|
43
|
+
export { formatTextToLongText } from './cell-value-set/long-text.js';
|
|
44
|
+
export { formatTextToImage } from './cell-value-set/image.js';
|
|
45
|
+
export { formatTextToGeolocation } from './cell-value-set/geolocation.js';
|
|
46
|
+
export { formatTextToDuration } from './cell-value-set/duration.js';
|
|
47
|
+
export { formatRateMaxNumberToNumber, formatTextToAutoNumber } from './cell-value-set/auto-number.js';
|
|
48
|
+
export { default as getPreviewContent } from './column/long-text.js';
|
|
37
49
|
export { getColumnType, getColumnsByType } from './column/core.js';
|
|
38
50
|
export { createOption, generateOptionID, generatorCellOption, generatorCellOptions, getColumnOptions } from './column/option.js';
|
|
39
51
|
export { isDateColumn, isSupportDateColumnFormat } from './column/date.js';
|
|
40
52
|
export { isNumberColumn, isNumericColumn } from './column/number.js';
|
|
53
|
+
export { isFileValue } from './column/file.js';
|
|
41
54
|
export { DateUtils } from './date.js';
|
|
42
55
|
export { isNumber, isNumberEqual, round } from './number.js';
|
|
43
56
|
export { ValidateFilter } from './validate/filter.js';
|
|
@@ -77,6 +90,8 @@ export { getGroupedRowsWithoutFormulaCalculation, groupTableRows, groupViewRows
|
|
|
77
90
|
export { default as GradientColorUtils } from './color/gradient-color.js';
|
|
78
91
|
export { default as ColumnColorUtils } from './color/column-color.js';
|
|
79
92
|
export { default as RowColorUtils } from './color/row-color.js';
|
|
93
|
+
export { customFilter2SqlCondition, customSort2SqlCondition, generateSearchColumnsString, generateViewSearchColumnsString, generatorCustomSearchSQL, generatorSearchSQL, sort2SqlCondition } from './archive/clause-module/search.js';
|
|
94
|
+
export { generatorUpdateSql, getConvertedUpdatedValue } from './archive/clause-module/update.js';
|
|
80
95
|
export { checkboxSqlCondition, collaboratorSqlCondition, creatorSqlCondition, ctimeSqlCondition, dateSqlCondition, departmentSingleSelectSqlCondition, fileSqlCondition, filter2SqlCondition, formulaSqlCondition, getSqlConditionByFilter, linkSqlCondition, longtextSqlCondition, multipleSelectSqlCondition, numberSqlCondition, singleSelectSqlCondition, textSqlCondition } from './archive/sql-generator/filter-condition.js';
|
|
81
96
|
export { FILTER_COLUMN_OPTIONS } from './constants/filter/filter-column-options.js';
|
|
82
97
|
export { FILTER_TERM_MODIFIER_SHOW, FILTER_TERM_MODIFIER_TYPE } from './constants/filter/filter-modifier.js';
|
package/es/row/convert.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
1
2
|
import { getFormulaDisplayString } from '../cell-value-get/cell-value.js';
|
|
2
3
|
import { getColumnOptionNameById } from '../cell-value-get/option.js';
|
|
3
4
|
import { getLinkCellValue } from '../link/core.js';
|
|
4
5
|
import { isEmpty } from '../common.js';
|
|
5
|
-
import { CONVERT_ROW_COLUMNS_LIMIT } from '../constants/limit.js';
|
|
6
|
+
import { CONVERT_ROW_COLUMNS_LIMIT, TEXT_CELL_VALUE_LIMIT } from '../constants/limit.js';
|
|
6
7
|
import { CellType } from '../constants/cell-type.js';
|
|
8
|
+
import { getTableColumnByName } from '../table/column.js';
|
|
9
|
+
import { formatTextToNumber } from '../cell-value-set/number.js';
|
|
10
|
+
import { formatTextToCheckbox } from '../cell-value-set/checkbox.js';
|
|
11
|
+
import { formatTextToDate } from '../cell-value-set/date.js';
|
|
12
|
+
import { formatTextToSingleOption } from '../cell-value-set/single-select.js';
|
|
13
|
+
import { formatValueToMultipleOption, formatTextToMultipleOption } from '../cell-value-set/multiple-select.js';
|
|
14
|
+
import { formatTextToLongText } from '../cell-value-set/long-text.js';
|
|
15
|
+
import { formatTextToImage } from '../cell-value-set/image.js';
|
|
16
|
+
import { formatTextToGeolocation } from '../cell-value-set/geolocation.js';
|
|
17
|
+
import { formatTextToDuration } from '../cell-value-set/duration.js';
|
|
18
|
+
import 'dayjs';
|
|
19
|
+
import '../constants/column.js';
|
|
20
|
+
import '../constants/formula.js';
|
|
21
|
+
import { getCollaboratorEmailsByNames } from '../cell-value-get/collaborator.js';
|
|
22
|
+
import '../constants/group.js';
|
|
23
|
+
import '../date.js';
|
|
24
|
+
import '../constants/filter/filter-column-options.js';
|
|
25
|
+
import '../constants/filter/filter-modifier.js';
|
|
26
|
+
import '../constants/filter/filter-predicate.js';
|
|
27
|
+
import '../constants/filter/filter-is-within.js';
|
|
28
|
+
import '../constants/sort.js';
|
|
29
|
+
import { isFileValue } from '../column/file.js';
|
|
7
30
|
|
|
8
31
|
/**
|
|
9
32
|
* Convert row
|
|
@@ -162,5 +185,181 @@ var convertRow = function convertRow(row, value, table, view, formulaResults, co
|
|
|
162
185
|
}
|
|
163
186
|
return result;
|
|
164
187
|
};
|
|
188
|
+
var convertRowBack = function convertRowBack(row, table) {
|
|
189
|
+
var collaborators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
190
|
+
var result = {};
|
|
191
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
192
|
+
for (var key in row) {
|
|
193
|
+
var cellValue = row[key];
|
|
194
|
+
if (key === '_id') {
|
|
195
|
+
result['_id'] = cellValue;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
var column = getTableColumnByName(table, key);
|
|
199
|
+
if (!column) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
switch (column.type) {
|
|
203
|
+
case CellType.TEXT:
|
|
204
|
+
if (cellValue == null) {
|
|
205
|
+
result[column.key] = '';
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
result[column.key] = (cellValue + '').slice(0, TEXT_CELL_VALUE_LIMIT);
|
|
209
|
+
break;
|
|
210
|
+
case CellType.EMAIL:
|
|
211
|
+
case CellType.URL:
|
|
212
|
+
result[column.key] = cellValue == null ? '' : cellValue + '';
|
|
213
|
+
break;
|
|
214
|
+
case CellType.NUMBER:
|
|
215
|
+
result[column.key] = formatTextToNumber(cellValue);
|
|
216
|
+
break;
|
|
217
|
+
case CellType.CHECKBOX:
|
|
218
|
+
result[column.key] = formatTextToCheckbox(cellValue);
|
|
219
|
+
break;
|
|
220
|
+
case CellType.DATE:
|
|
221
|
+
// eslint-disable-next-line
|
|
222
|
+
var format = column.data && column.data.format;
|
|
223
|
+
result[column.key] = formatTextToDate(cellValue, format);
|
|
224
|
+
break;
|
|
225
|
+
case CellType.COLLABORATOR:
|
|
226
|
+
// todo
|
|
227
|
+
if (collaborators) {
|
|
228
|
+
result[column.key] = getCollaboratorEmailsByNames(cellValue, collaborators);
|
|
229
|
+
} else {
|
|
230
|
+
result[column.key] = cellValue;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case CellType.SINGLE_SELECT:
|
|
234
|
+
result[column.key] = formatTextToSingleOption(cellValue, column);
|
|
235
|
+
break;
|
|
236
|
+
case CellType.MULTIPLE_SELECT:
|
|
237
|
+
if (!cellValue) {
|
|
238
|
+
result[column.key] = null;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(cellValue)) {
|
|
242
|
+
result[column.key] = formatValueToMultipleOption(cellValue, column);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
if (typeof cellValue === 'string') {
|
|
246
|
+
if (!cellValue.trim()) {
|
|
247
|
+
result[column.key] = null;
|
|
248
|
+
} else {
|
|
249
|
+
result[column.key] = formatTextToMultipleOption(cellValue, column);
|
|
250
|
+
}
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
result[column.key] = null;
|
|
254
|
+
break;
|
|
255
|
+
case CellType.LONG_TEXT:
|
|
256
|
+
// eslint-disable-next-line
|
|
257
|
+
var text = cellValue;
|
|
258
|
+
if (!text) {
|
|
259
|
+
result[column.key] = null;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (_typeof(text) === 'object') {
|
|
263
|
+
result[column.key] = text;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
if (typeof text === 'string') {
|
|
267
|
+
if (!text.trim()) {
|
|
268
|
+
result[column.key] = null;
|
|
269
|
+
} else {
|
|
270
|
+
result[column.key] = formatTextToLongText(text);
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
result[column.key] = null;
|
|
275
|
+
break;
|
|
276
|
+
case CellType.IMAGE:
|
|
277
|
+
if (!cellValue) {
|
|
278
|
+
result[column.key] = null;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(cellValue)) {
|
|
282
|
+
result[column.key] = cellValue;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
if (typeof cellValue === 'string') {
|
|
286
|
+
if (!cellValue.trim()) {
|
|
287
|
+
result[column.key] = null;
|
|
288
|
+
} else {
|
|
289
|
+
result[column.key] = formatTextToImage(cellValue);
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
result[column.key] = null;
|
|
294
|
+
break;
|
|
295
|
+
case CellType.FILE:
|
|
296
|
+
if (!cellValue) {
|
|
297
|
+
result[column.key] = null;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
// add data from api
|
|
301
|
+
if (Array.isArray(cellValue)) {
|
|
302
|
+
var fileValue = cellValue.filter(function (value) {
|
|
303
|
+
return isFileValue(value);
|
|
304
|
+
});
|
|
305
|
+
result[column.key] = fileValue.length > 0 ? fileValue : null;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
// add data form other app
|
|
309
|
+
if (typeof cellValue === 'string') {
|
|
310
|
+
result[column.key] = null;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
result[column.key] = null;
|
|
314
|
+
break;
|
|
315
|
+
// don't support link/formula/digital-sign column convertRowBack
|
|
316
|
+
case CellType.LINK:
|
|
317
|
+
case CellType.FORMULA:
|
|
318
|
+
case CellType.LINK_FORMULA:
|
|
319
|
+
{
|
|
320
|
+
result[column.key] = null;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
case CellType.DIGITAL_SIGN:
|
|
324
|
+
if (!cellValue) {
|
|
325
|
+
result[column.key] = null;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
if (_typeof(cellValue) === 'object') {
|
|
329
|
+
result[column.key] = cellValue;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
result[column.key] = null;
|
|
333
|
+
break;
|
|
334
|
+
case CellType.GEOLOCATION:
|
|
335
|
+
if (!cellValue) {
|
|
336
|
+
result[column.key] = null;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
if (_typeof(cellValue) === 'object') {
|
|
340
|
+
result[column.key] = cellValue;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
if (typeof cellValue === 'string') {
|
|
344
|
+
if (!cellValue.trim()) {
|
|
345
|
+
result[column.key] = null;
|
|
346
|
+
} else {
|
|
347
|
+
result[column.key] = formatTextToGeolocation(cellValue, column.data);
|
|
348
|
+
}
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
result[column.key] = null;
|
|
352
|
+
break;
|
|
353
|
+
case CellType.DURATION:
|
|
354
|
+
{
|
|
355
|
+
result[column.key] = formatTextToDuration(cellValue, column.data);
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
default:
|
|
359
|
+
result[column.key] = cellValue;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return result;
|
|
363
|
+
};
|
|
165
364
|
|
|
166
|
-
export { convertRow };
|
|
365
|
+
export { convertRow, convertRowBack };
|