dtable-utils 4.3.4 → 4.3.5-beta
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 +182 -0
- package/es/archive/clause-module/update.js +120 -0
- package/es/archive/sql-generator/filter-condition.js +15 -7
- package/es/cell-value-get/auto-number.js +16 -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 +18 -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/filter/filter-column/long-text.js +11 -3
- package/es/helper/patch-utils.js +38 -0
- package/es/index.js +18 -4
- package/es/row/convert.js +202 -1
- package/es/view/summaries.js +11 -2
- package/lib/archive/clause-module/search.js +197 -0
- package/lib/archive/clause-module/update.js +125 -0
- package/lib/archive/sql-generator/filter-condition.js +15 -7
- package/lib/cell-value-get/auto-number.js +20 -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 +22 -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/filter/filter-column/long-text.js +15 -3
- package/lib/helper/patch-utils.js +47 -0
- package/lib/index.js +62 -20
- package/lib/row/convert.js +206 -0
- package/lib/view/summaries.js +11 -2
- package/package.json +1 -1
|
@@ -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 };
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
1
2
|
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Filter long-text
|
|
5
|
-
* @param {
|
|
6
|
+
* @param {any} value
|
|
6
7
|
* @param {string} filter_predicate
|
|
7
8
|
* @returns bool
|
|
8
9
|
*/
|
|
9
|
-
var longTextFilter = function longTextFilter(
|
|
10
|
+
var longTextFilter = function longTextFilter(value, _ref) {
|
|
10
11
|
var filter_predicate = _ref.filter_predicate;
|
|
11
|
-
var text
|
|
12
|
+
var text;
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
|
+
text = value.trim();
|
|
15
|
+
} else if (_typeof(value) === 'object') {
|
|
16
|
+
text = value ? value.text.trim() : null;
|
|
17
|
+
} else {
|
|
18
|
+
text = null;
|
|
19
|
+
}
|
|
12
20
|
switch (filter_predicate) {
|
|
13
21
|
case FILTER_PREDICATE_TYPE.EMPTY:
|
|
14
22
|
{
|
|
@@ -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,13 @@ 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';
|
|
13
14
|
export { generatorBase64Code, isEmpty, isEmptyObject } from './common.js';
|
|
14
15
|
export { getTableById, getTableByIndex, getTableByName } from './table/core.js';
|
|
15
16
|
export { getTableColumnByKey, getTableColumnByName } from './table/column.js';
|
|
16
17
|
export { getRowById, getRowsByIds } from './table/row.js';
|
|
17
18
|
export { isTableRows } from './row/core.js';
|
|
18
|
-
export { convertRow } from './row/convert.js';
|
|
19
|
+
export { convertRow, convertRowBack } from './row/convert.js';
|
|
19
20
|
export { getLinkColumnsUsedInFilters, getNonArchiveViews, getViewById, getViewByName, getViewShownColumns, isArchiveView, isDefaultView, isFilterView, isGroupView, isHiddenColumnsView, isSortView } from './view/core.js';
|
|
20
21
|
export { getSummaries, getSummariesWithSubgroups, updateGroupSummaries } from './view/summaries.js';
|
|
21
22
|
export { getFormulaColumnsContainLinks, getSortedFormulaColumns, getSortedFormulaColumnsContainLinks, transLink2LinkFormula } from './view/formula.js';
|
|
@@ -25,19 +26,30 @@ export { getDateDisplayString } from './cell-value-get/date.js';
|
|
|
25
26
|
export { getDurationDisplayString } from './cell-value-get/duration.js';
|
|
26
27
|
export { getNumberDisplayString, getPrecisionNumber, replaceNumberNotAllowInput } from './cell-value-get/number.js';
|
|
27
28
|
export { getColumnOptionNameById, getMultipleOptionName, getOption, getOptionName } from './cell-value-get/option.js';
|
|
28
|
-
export { getCollaborator, getCollaboratorsName, getCollaboratorsNames } from './cell-value-get/collaborator.js';
|
|
29
|
+
export { getCollaborator, getCollaboratorEmailsByNames, getCollaboratorsName, getCollaboratorsNames } from './cell-value-get/collaborator.js';
|
|
29
30
|
export { getGeolocationByGranularity, getGeolocationDisplayString } from './cell-value-get/geolocation.js';
|
|
30
31
|
export { getDepartmentName } from './cell-value-get/department.js';
|
|
31
32
|
export { getDigitalSignImageUrl } from './cell-value-get/digital-sign.js';
|
|
32
33
|
export { getLongtextDisplayString } from './cell-value-get/long-text.js';
|
|
33
34
|
export { getCellValueDisplayString, getCellValueStringResult, getFormulaDisplayString } from './cell-value-get/cell-value.js';
|
|
34
35
|
export { getRateDisplayString } from './cell-value-get/rate.js';
|
|
35
|
-
export {
|
|
36
|
+
export { getFormattedAutoNumber } from './cell-value-get/auto-number.js';
|
|
37
|
+
export { formatDurationToNumber, formatStringToNumber, formatTextToNumber, getFloatNumber } from './cell-value-set/number.js';
|
|
38
|
+
export { formatTextToCheckbox } from './cell-value-set/checkbox.js';
|
|
36
39
|
export { formatTextToDate } from './cell-value-set/date.js';
|
|
40
|
+
export { formatTextToSingleOption } from './cell-value-set/single-select.js';
|
|
41
|
+
export { formatTextToMultipleOption, formatValueToMultipleOption } from './cell-value-set/multiple-select.js';
|
|
42
|
+
export { formatTextToLongText } from './cell-value-set/long-text.js';
|
|
43
|
+
export { formatTextToImage } from './cell-value-set/image.js';
|
|
44
|
+
export { formatTextToGeolocation } from './cell-value-set/geolocation.js';
|
|
45
|
+
export { formatTextToDuration } from './cell-value-set/duration.js';
|
|
46
|
+
export { formatRateMaxNumberToNumber, formatTextToAutoNumber } from './cell-value-set/auto-number.js';
|
|
47
|
+
export { default as getPreviewContent } from './column/long-text.js';
|
|
37
48
|
export { getColumnType, getColumnsByType } from './column/core.js';
|
|
38
49
|
export { createOption, generateOptionID, generatorCellOption, generatorCellOptions, getColumnOptions } from './column/option.js';
|
|
39
50
|
export { isDateColumn, isSupportDateColumnFormat } from './column/date.js';
|
|
40
51
|
export { isNumberColumn, isNumericColumn } from './column/number.js';
|
|
52
|
+
export { isFileValue } from './column/file.js';
|
|
41
53
|
export { DateUtils } from './date.js';
|
|
42
54
|
export { isNumber, isNumberEqual, round } from './number.js';
|
|
43
55
|
export { ValidateFilter } from './validate/filter.js';
|
|
@@ -77,6 +89,8 @@ export { getGroupedRowsWithoutFormulaCalculation, groupTableRows, groupViewRows
|
|
|
77
89
|
export { default as GradientColorUtils } from './color/gradient-color.js';
|
|
78
90
|
export { default as ColumnColorUtils } from './color/column-color.js';
|
|
79
91
|
export { default as RowColorUtils } from './color/row-color.js';
|
|
92
|
+
export { customFilter2SqlCondition, customSort2SqlCondition, generateSearchColumnsString, generateViewSearchColumnsString, generatorCustomSearchSQL, generatorSearchSQL, sort2SqlCondition } from './archive/clause-module/search.js';
|
|
93
|
+
export { generatorUpdateSql, getConvertedUpdatedValue } from './archive/clause-module/update.js';
|
|
80
94
|
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
95
|
export { FILTER_COLUMN_OPTIONS } from './constants/filter/filter-column-options.js';
|
|
82
96
|
export { FILTER_TERM_MODIFIER_SHOW, FILTER_TERM_MODIFIER_TYPE } from './constants/filter/filter-modifier.js';
|
package/es/row/convert.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
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
6
|
import { CONVERT_ROW_COLUMNS_LIMIT } from '../constants/limit.js';
|
|
6
7
|
import { CellType } from '../constants/cell-type.js';
|
|
8
|
+
import { getTableColumnByName } from '../table/column.js';
|
|
9
|
+
import { isNumber } from '../number.js';
|
|
10
|
+
import { formatTextToNumber } from '../cell-value-set/number.js';
|
|
11
|
+
import { formatTextToCheckbox } from '../cell-value-set/checkbox.js';
|
|
12
|
+
import { formatTextToDate } from '../cell-value-set/date.js';
|
|
13
|
+
import { formatTextToSingleOption } from '../cell-value-set/single-select.js';
|
|
14
|
+
import { formatValueToMultipleOption, formatTextToMultipleOption } from '../cell-value-set/multiple-select.js';
|
|
15
|
+
import { formatTextToLongText } from '../cell-value-set/long-text.js';
|
|
16
|
+
import { formatTextToImage } from '../cell-value-set/image.js';
|
|
17
|
+
import { formatTextToGeolocation } from '../cell-value-set/geolocation.js';
|
|
18
|
+
import { formatTextToDuration } from '../cell-value-set/duration.js';
|
|
19
|
+
import 'dayjs';
|
|
20
|
+
import '../constants/column.js';
|
|
21
|
+
import '../constants/formula.js';
|
|
22
|
+
import { getCollaboratorEmailsByNames } from '../cell-value-get/collaborator.js';
|
|
23
|
+
import '../constants/group.js';
|
|
24
|
+
import '../date.js';
|
|
25
|
+
import '../constants/filter/filter-column-options.js';
|
|
26
|
+
import '../constants/filter/filter-modifier.js';
|
|
27
|
+
import '../constants/filter/filter-predicate.js';
|
|
28
|
+
import '../constants/filter/filter-is-within.js';
|
|
29
|
+
import '../constants/sort.js';
|
|
30
|
+
import { isFileValue } from '../column/file.js';
|
|
7
31
|
|
|
8
32
|
/**
|
|
9
33
|
* Convert row
|
|
@@ -162,5 +186,182 @@ var convertRow = function convertRow(row, value, table, view, formulaResults, co
|
|
|
162
186
|
}
|
|
163
187
|
return result;
|
|
164
188
|
};
|
|
189
|
+
var convertRowBack = function convertRowBack(row, table) {
|
|
190
|
+
var collaborators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
191
|
+
var textCellValueLimit = arguments.length > 3 ? arguments[3] : undefined;
|
|
192
|
+
var result = {};
|
|
193
|
+
for (var key in row) {
|
|
194
|
+
var cellValue = row[key];
|
|
195
|
+
if (key === '_id') {
|
|
196
|
+
result['_id'] = cellValue;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
var column = getTableColumnByName(table, key);
|
|
200
|
+
if (!column) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
switch (column.type) {
|
|
204
|
+
case CellType.TEXT:
|
|
205
|
+
if (cellValue == null) {
|
|
206
|
+
result[column.key] = '';
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
var validTextCellValueLimit = isNumber(textCellValueLimit) ? textCellValueLimit : 10000;
|
|
210
|
+
result[column.key] = (cellValue + '').slice(0, validTextCellValueLimit);
|
|
211
|
+
break;
|
|
212
|
+
case CellType.EMAIL:
|
|
213
|
+
case CellType.URL:
|
|
214
|
+
result[column.key] = cellValue == null ? '' : cellValue + '';
|
|
215
|
+
break;
|
|
216
|
+
case CellType.NUMBER:
|
|
217
|
+
result[column.key] = formatTextToNumber(cellValue);
|
|
218
|
+
break;
|
|
219
|
+
case CellType.CHECKBOX:
|
|
220
|
+
result[column.key] = formatTextToCheckbox(cellValue);
|
|
221
|
+
break;
|
|
222
|
+
case CellType.DATE:
|
|
223
|
+
// eslint-disable-next-line
|
|
224
|
+
var format = column.data && column.data.format;
|
|
225
|
+
result[column.key] = formatTextToDate(cellValue, format);
|
|
226
|
+
break;
|
|
227
|
+
case CellType.COLLABORATOR:
|
|
228
|
+
// todo
|
|
229
|
+
if (collaborators) {
|
|
230
|
+
result[column.key] = getCollaboratorEmailsByNames(cellValue, collaborators);
|
|
231
|
+
} else {
|
|
232
|
+
result[column.key] = cellValue;
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case CellType.SINGLE_SELECT:
|
|
236
|
+
result[column.key] = formatTextToSingleOption(cellValue, column);
|
|
237
|
+
break;
|
|
238
|
+
case CellType.MULTIPLE_SELECT:
|
|
239
|
+
if (!cellValue) {
|
|
240
|
+
result[column.key] = null;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (Array.isArray(cellValue)) {
|
|
244
|
+
result[column.key] = formatValueToMultipleOption(cellValue, column);
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
if (typeof cellValue === 'string') {
|
|
248
|
+
if (!cellValue.trim()) {
|
|
249
|
+
result[column.key] = null;
|
|
250
|
+
} else {
|
|
251
|
+
result[column.key] = formatTextToMultipleOption(cellValue, column);
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
result[column.key] = null;
|
|
256
|
+
break;
|
|
257
|
+
case CellType.LONG_TEXT:
|
|
258
|
+
// eslint-disable-next-line
|
|
259
|
+
var text = cellValue;
|
|
260
|
+
if (!text) {
|
|
261
|
+
result[column.key] = null;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
if (_typeof(text) === 'object') {
|
|
265
|
+
result[column.key] = text;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
if (typeof text === 'string') {
|
|
269
|
+
if (!text.trim()) {
|
|
270
|
+
result[column.key] = null;
|
|
271
|
+
} else {
|
|
272
|
+
result[column.key] = formatTextToLongText(text);
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
result[column.key] = null;
|
|
277
|
+
break;
|
|
278
|
+
case CellType.IMAGE:
|
|
279
|
+
if (!cellValue) {
|
|
280
|
+
result[column.key] = null;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
if (Array.isArray(cellValue)) {
|
|
284
|
+
result[column.key] = cellValue;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
if (typeof cellValue === 'string') {
|
|
288
|
+
if (!cellValue.trim()) {
|
|
289
|
+
result[column.key] = null;
|
|
290
|
+
} else {
|
|
291
|
+
result[column.key] = formatTextToImage(cellValue);
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
result[column.key] = null;
|
|
296
|
+
break;
|
|
297
|
+
case CellType.FILE:
|
|
298
|
+
if (!cellValue) {
|
|
299
|
+
result[column.key] = null;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
// add data from api
|
|
303
|
+
if (Array.isArray(cellValue)) {
|
|
304
|
+
var fileValue = cellValue.filter(function (value) {
|
|
305
|
+
return isFileValue(value);
|
|
306
|
+
});
|
|
307
|
+
result[column.key] = fileValue.length > 0 ? fileValue : null;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
// add data form other app
|
|
311
|
+
if (typeof cellValue === 'string') {
|
|
312
|
+
result[column.key] = null;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
result[column.key] = null;
|
|
316
|
+
break;
|
|
317
|
+
// don't support link/formula/digital-sign column convertRowBack
|
|
318
|
+
case CellType.LINK:
|
|
319
|
+
case CellType.FORMULA:
|
|
320
|
+
case CellType.LINK_FORMULA:
|
|
321
|
+
{
|
|
322
|
+
result[column.key] = null;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
case CellType.DIGITAL_SIGN:
|
|
326
|
+
if (!cellValue) {
|
|
327
|
+
result[column.key] = null;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
if (_typeof(cellValue) === 'object') {
|
|
331
|
+
result[column.key] = cellValue;
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
result[column.key] = null;
|
|
335
|
+
break;
|
|
336
|
+
case CellType.GEOLOCATION:
|
|
337
|
+
if (!cellValue) {
|
|
338
|
+
result[column.key] = null;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
if (_typeof(cellValue) === 'object') {
|
|
342
|
+
result[column.key] = cellValue;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (typeof cellValue === 'string') {
|
|
346
|
+
if (!cellValue.trim()) {
|
|
347
|
+
result[column.key] = null;
|
|
348
|
+
} else {
|
|
349
|
+
result[column.key] = formatTextToGeolocation(cellValue, column.data);
|
|
350
|
+
}
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
result[column.key] = null;
|
|
354
|
+
break;
|
|
355
|
+
case CellType.DURATION:
|
|
356
|
+
{
|
|
357
|
+
result[column.key] = formatTextToDuration(cellValue, column.data);
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
default:
|
|
361
|
+
result[column.key] = cellValue;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return result;
|
|
365
|
+
};
|
|
165
366
|
|
|
166
|
-
export { convertRow };
|
|
367
|
+
export { convertRow, convertRowBack };
|
package/es/view/summaries.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { getRowsByIds } from '../table/row.js';
|
|
2
2
|
import { isTableRows } from '../row/core.js';
|
|
3
|
+
import '@babel/runtime/helpers/typeof';
|
|
3
4
|
import '../cell-value-get/cell-value.js';
|
|
4
5
|
import '@babel/runtime/helpers/defineProperty';
|
|
5
6
|
import '@babel/runtime/helpers/toConsumableArray';
|
|
6
7
|
import { FORMULA_COLUMN_TYPES_MAP } from '../constants/formula.js';
|
|
7
|
-
import '@babel/runtime/helpers/typeof';
|
|
8
|
-
import { isNumericColumn } from '../column/number.js';
|
|
9
8
|
import { isNumber } from '../number.js';
|
|
9
|
+
import '../constants/column.js';
|
|
10
|
+
import '../date.js';
|
|
11
|
+
import '../constants/filter/filter-column-options.js';
|
|
12
|
+
import '../constants/filter/filter-modifier.js';
|
|
13
|
+
import '../constants/filter/filter-predicate.js';
|
|
14
|
+
import '../constants/filter/filter-is-within.js';
|
|
15
|
+
import '../constants/sort.js';
|
|
16
|
+
import '../constants/group.js';
|
|
17
|
+
import { isNumericColumn } from '../column/number.js';
|
|
18
|
+
import 'dayjs';
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* Calculate summaries of table numeric columns
|