dtable-utils 4.3.1 → 4.3.2-beta.2
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/column/core.js +16 -1
- package/es/constants/table-permission.js +8 -0
- package/es/index.js +7 -4
- package/es/link/core.js +40 -1
- package/es/row/convert.js +166 -0
- package/es/row/core.js +1 -169
- package/es/table/core.js +18 -1
- package/es/view/core.js +60 -1
- package/es/view/summaries.js +5 -1
- package/lib/column/core.js +16 -0
- package/lib/constants/table-permission.js +12 -0
- package/lib/index.js +32 -18
- package/lib/link/core.js +41 -0
- package/lib/row/convert.js +170 -0
- package/lib/row/core.js +0 -169
- package/lib/table/core.js +19 -0
- package/lib/view/core.js +64 -0
- package/lib/view/summaries.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { getFormulaDisplayString } from '../cell-value-get/cell-value.js';
|
|
2
|
+
import { getColumnOptionNameById } from '../cell-value-get/option.js';
|
|
3
|
+
import { getLinkCellValue } from '../link/core.js';
|
|
4
|
+
import { isEmpty } from '../common.js';
|
|
5
|
+
import { CONVERT_ROW_COLUMNS_LIMIT } from '../constants/limit.js';
|
|
6
|
+
import { CellType } from '../constants/cell-type.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert row
|
|
10
|
+
* e.g. { '0000': 'a' } to { 'Name': 'a' }
|
|
11
|
+
* @param {object} row
|
|
12
|
+
* @param {object} value e.g. { links, ... }
|
|
13
|
+
* @param {object} table e.g. { _id, columns, ... }
|
|
14
|
+
* @param {object} view e.g. { hidden_columns, ... }
|
|
15
|
+
* @param {object} formulaResults computed value of formula, link-formula, link etc.
|
|
16
|
+
* @param {bool} convertLinkID use to convert link: get linked from formulaResults if true, otherwise get linked from links
|
|
17
|
+
* @param {func} debug use to debug if supplied
|
|
18
|
+
* @returns converted row, object
|
|
19
|
+
*/
|
|
20
|
+
var convertRow = function convertRow(row, value, table, view, formulaResults, convertLinkID) {
|
|
21
|
+
var _ref = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {},
|
|
22
|
+
debug = _ref.debug;
|
|
23
|
+
var result = {};
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
if (row.hasOwnProperty('_id')) {
|
|
26
|
+
result._id = row._id;
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line
|
|
29
|
+
if (row.hasOwnProperty('_mtime')) {
|
|
30
|
+
result._mtime = row._mtime;
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line
|
|
33
|
+
if (row.hasOwnProperty('_ctime')) {
|
|
34
|
+
result._ctime = row._ctime;
|
|
35
|
+
}
|
|
36
|
+
var columns = table.columns;
|
|
37
|
+
if (columns.length > CONVERT_ROW_COLUMNS_LIMIT) {
|
|
38
|
+
columns = columns.slice(0, CONVERT_ROW_COLUMNS_LIMIT);
|
|
39
|
+
}
|
|
40
|
+
var hiddenColumns = view ? view.hidden_columns : null;
|
|
41
|
+
for (var i = 0; i < columns.length; i++) {
|
|
42
|
+
var column = columns[i];
|
|
43
|
+
var key = column.key,
|
|
44
|
+
type = column.type,
|
|
45
|
+
columnName = column.name;
|
|
46
|
+
if (hiddenColumns && hiddenColumns.includes(key)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
var cellValue = row[key];
|
|
50
|
+
switch (type) {
|
|
51
|
+
case CellType.SINGLE_SELECT:
|
|
52
|
+
{
|
|
53
|
+
if (!column.data) {
|
|
54
|
+
if (debug) {
|
|
55
|
+
debug('No options found');
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
result[columnName] = getColumnOptionNameById(column, cellValue);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case CellType.MULTIPLE_SELECT:
|
|
63
|
+
{
|
|
64
|
+
if (!column.data) {
|
|
65
|
+
if (debug) {
|
|
66
|
+
debug('No options found');
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (!Array.isArray(cellValue)) {
|
|
71
|
+
result[columnName] = '';
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
var optionNames = [];
|
|
75
|
+
for (var optionIndex = 0; optionIndex < cellValue.length; optionIndex++) {
|
|
76
|
+
var optionName = getColumnOptionNameById(column, cellValue[optionIndex]);
|
|
77
|
+
if (optionName) {
|
|
78
|
+
optionNames.push(optionName);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
result[columnName] = optionNames;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case CellType.LONG_TEXT:
|
|
85
|
+
{
|
|
86
|
+
result[columnName] = cellValue ? cellValue.text : '';
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case CellType.LINK:
|
|
90
|
+
{
|
|
91
|
+
if (!column.data) {
|
|
92
|
+
if (debug) {
|
|
93
|
+
debug('No links found');
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
// convertLinkID to display value
|
|
98
|
+
if (convertLinkID) {
|
|
99
|
+
// get values form formulaResults
|
|
100
|
+
var formulaRow = formulaResults && formulaResults[row._id];
|
|
101
|
+
var cellResult = formulaRow && formulaRow[key];
|
|
102
|
+
if (!Array.isArray(cellResult) || cellResult.length === 0) {
|
|
103
|
+
result[columnName] = null;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
// linked with common column:
|
|
107
|
+
// cellResult
|
|
108
|
+
// [
|
|
109
|
+
// {row_id: '', displayValue: ''},
|
|
110
|
+
// {row_id: '', displayValue: ''},
|
|
111
|
+
// ]
|
|
112
|
+
|
|
113
|
+
// linked with formula column and formula result is array
|
|
114
|
+
// cellResult
|
|
115
|
+
// [
|
|
116
|
+
// {row_id: '', display_value: []},
|
|
117
|
+
// {row_id: '', display_value: []},
|
|
118
|
+
// ]
|
|
119
|
+
result[columnName] = cellResult;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
var tableID = table._id;
|
|
123
|
+
var _column$data = column.data,
|
|
124
|
+
link_id = _column$data.link_id,
|
|
125
|
+
table_id = _column$data.table_id,
|
|
126
|
+
other_table_id = _column$data.other_table_id;
|
|
127
|
+
var otherTableID = tableID === table_id ? other_table_id : table_id;
|
|
128
|
+
var links = value.links;
|
|
129
|
+
result[columnName] = getLinkCellValue(links, link_id, tableID, otherTableID, row._id);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case CellType.FORMULA:
|
|
133
|
+
case CellType.LINK_FORMULA:
|
|
134
|
+
{
|
|
135
|
+
if (!column.data || !formulaResults) {
|
|
136
|
+
if (debug) {
|
|
137
|
+
debug('No formula found');
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
var _formulaRow = formulaResults[row._id] || {};
|
|
142
|
+
result[columnName] = getFormulaDisplayString(_formulaRow[key], column.data);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
default:
|
|
146
|
+
{
|
|
147
|
+
// text/email/url/auto-number/
|
|
148
|
+
// check/
|
|
149
|
+
// rate/duration/
|
|
150
|
+
// file/image/button/
|
|
151
|
+
// translate in dtable-events
|
|
152
|
+
// number/
|
|
153
|
+
// date/ctime/mtime/
|
|
154
|
+
// geolocation/
|
|
155
|
+
// collaborator/creator/last-modifier/
|
|
156
|
+
result[columnName] = cellValue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (isEmpty(result[columnName])) {
|
|
160
|
+
delete result[columnName];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export { convertRow };
|
package/es/row/core.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
|
-
import { getFormulaDisplayString } from '../cell-value-get/cell-value.js';
|
|
3
|
-
import 'dayjs';
|
|
4
|
-
import '../constants/column.js';
|
|
5
|
-
import '../constants/formula.js';
|
|
6
|
-
import { getColumnOptionNameById } from '../cell-value-get/option.js';
|
|
7
|
-
import '../constants/group.js';
|
|
8
|
-
import { getLinkCellValue } from '../link/core.js';
|
|
9
|
-
import { isEmpty } from '../common.js';
|
|
10
|
-
import { CellType } from '../constants/cell-type.js';
|
|
11
|
-
import { CONVERT_ROW_COLUMNS_LIMIT } from '../constants/limit.js';
|
|
12
2
|
|
|
13
3
|
/**
|
|
14
4
|
* Check is table rows
|
|
@@ -19,162 +9,4 @@ var isTableRows = function isTableRows(rows) {
|
|
|
19
9
|
return Array.isArray(rows) && _typeof(rows[0]) === 'object';
|
|
20
10
|
};
|
|
21
11
|
|
|
22
|
-
|
|
23
|
-
* Convert row
|
|
24
|
-
* e.g. { '0000': 'a' } to { 'Name': 'a' }
|
|
25
|
-
* @param {object} row
|
|
26
|
-
* @param {object} value e.g. { links, ... }
|
|
27
|
-
* @param {object} table e.g. { _id, columns, ... }
|
|
28
|
-
* @param {object} view e.g. { hidden_columns, ... }
|
|
29
|
-
* @param {object} formulaResults computed value of formula, link-formula, link etc.
|
|
30
|
-
* @param {bool} convertLinkID use to convert link: get linked from formulaResults if true, otherwise get linked from links
|
|
31
|
-
* @param {func} debug use to debug if supplied
|
|
32
|
-
* @returns converted row, object
|
|
33
|
-
*/
|
|
34
|
-
var convertRow = function convertRow(row, value, table, view, formulaResults, convertLinkID) {
|
|
35
|
-
var _ref = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {},
|
|
36
|
-
debug = _ref.debug;
|
|
37
|
-
var result = {};
|
|
38
|
-
// eslint-disable-next-line
|
|
39
|
-
if (row.hasOwnProperty('_id')) {
|
|
40
|
-
result._id = row._id;
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line
|
|
43
|
-
if (row.hasOwnProperty('_mtime')) {
|
|
44
|
-
result._mtime = row._mtime;
|
|
45
|
-
}
|
|
46
|
-
// eslint-disable-next-line
|
|
47
|
-
if (row.hasOwnProperty('_ctime')) {
|
|
48
|
-
result._ctime = row._ctime;
|
|
49
|
-
}
|
|
50
|
-
var columns = table.columns;
|
|
51
|
-
if (columns.length > CONVERT_ROW_COLUMNS_LIMIT) {
|
|
52
|
-
columns = columns.slice(0, CONVERT_ROW_COLUMNS_LIMIT);
|
|
53
|
-
}
|
|
54
|
-
var hiddenColumns = view ? view.hidden_columns : null;
|
|
55
|
-
for (var i = 0; i < columns.length; i++) {
|
|
56
|
-
var column = columns[i];
|
|
57
|
-
var key = column.key,
|
|
58
|
-
type = column.type,
|
|
59
|
-
columnName = column.name;
|
|
60
|
-
if (hiddenColumns && hiddenColumns.includes(key)) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
var cellValue = row[key];
|
|
64
|
-
switch (type) {
|
|
65
|
-
case CellType.SINGLE_SELECT:
|
|
66
|
-
{
|
|
67
|
-
if (!column.data) {
|
|
68
|
-
if (debug) {
|
|
69
|
-
debug('No options found');
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
result[columnName] = getColumnOptionNameById(column, cellValue);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case CellType.MULTIPLE_SELECT:
|
|
77
|
-
{
|
|
78
|
-
if (!column.data) {
|
|
79
|
-
if (debug) {
|
|
80
|
-
debug('No options found');
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
if (!Array.isArray(cellValue)) {
|
|
85
|
-
result[columnName] = '';
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
var optionNames = [];
|
|
89
|
-
for (var optionIndex = 0; optionIndex < cellValue.length; optionIndex++) {
|
|
90
|
-
var optionName = getColumnOptionNameById(column, cellValue[optionIndex]);
|
|
91
|
-
if (optionName) {
|
|
92
|
-
optionNames.push(optionName);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
result[columnName] = optionNames;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case CellType.LONG_TEXT:
|
|
99
|
-
{
|
|
100
|
-
result[columnName] = cellValue ? cellValue.text : '';
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case CellType.LINK:
|
|
104
|
-
{
|
|
105
|
-
if (!column.data) {
|
|
106
|
-
if (debug) {
|
|
107
|
-
debug('No links found');
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
// convertLinkID to display value
|
|
112
|
-
if (convertLinkID) {
|
|
113
|
-
// get values form formulaResults
|
|
114
|
-
var formulaRow = formulaResults && formulaResults[row._id];
|
|
115
|
-
var cellResult = formulaRow && formulaRow[key];
|
|
116
|
-
if (!Array.isArray(cellResult) || cellResult.length === 0) {
|
|
117
|
-
result[columnName] = null;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
// linked with common column:
|
|
121
|
-
// cellResult
|
|
122
|
-
// [
|
|
123
|
-
// {row_id: '', displayValue: ''},
|
|
124
|
-
// {row_id: '', displayValue: ''},
|
|
125
|
-
// ]
|
|
126
|
-
|
|
127
|
-
// linked with formula column and formula result is array
|
|
128
|
-
// cellResult
|
|
129
|
-
// [
|
|
130
|
-
// {row_id: '', display_value: []},
|
|
131
|
-
// {row_id: '', display_value: []},
|
|
132
|
-
// ]
|
|
133
|
-
result[columnName] = cellResult;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
var tableID = table._id;
|
|
137
|
-
var _column$data = column.data,
|
|
138
|
-
link_id = _column$data.link_id,
|
|
139
|
-
table_id = _column$data.table_id,
|
|
140
|
-
other_table_id = _column$data.other_table_id;
|
|
141
|
-
var otherTableID = tableID === table_id ? other_table_id : table_id;
|
|
142
|
-
var links = value.links;
|
|
143
|
-
result[columnName] = getLinkCellValue(links, link_id, tableID, otherTableID, row._id);
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case CellType.FORMULA:
|
|
147
|
-
case CellType.LINK_FORMULA:
|
|
148
|
-
{
|
|
149
|
-
if (!column.data || !formulaResults) {
|
|
150
|
-
if (debug) {
|
|
151
|
-
debug('No formula found');
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
var _formulaRow = formulaResults[row._id] || {};
|
|
156
|
-
result[columnName] = getFormulaDisplayString(_formulaRow[key], column.data);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
default:
|
|
160
|
-
{
|
|
161
|
-
// text/email/url/auto-number/
|
|
162
|
-
// check/
|
|
163
|
-
// rate/duration/
|
|
164
|
-
// file/image/button/
|
|
165
|
-
// translate in dtable-events
|
|
166
|
-
// number/
|
|
167
|
-
// date/ctime/mtime/
|
|
168
|
-
// geolocation/
|
|
169
|
-
// collaborator/creator/last-modifier/
|
|
170
|
-
result[columnName] = cellValue;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (isEmpty(result[columnName])) {
|
|
174
|
-
delete result[columnName];
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return result;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export { convertRow, isTableRows };
|
|
12
|
+
export { isTableRows };
|
package/es/table/core.js
CHANGED
|
@@ -11,4 +11,21 @@ var getTableById = function getTableById(tables, tableId) {
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Get table by name
|
|
16
|
+
* @param {array} tables
|
|
17
|
+
* @param {string} tableName
|
|
18
|
+
* @returns table, object
|
|
19
|
+
*/
|
|
20
|
+
var getTableByName = function getTableByName(tables, tableName) {
|
|
21
|
+
if (!Array.isArray(tables) || !tableName) return null;
|
|
22
|
+
return tables.find(function (table) {
|
|
23
|
+
return table.name === tableName;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var getTableByIndex = function getTableByIndex(tables, tableIndex) {
|
|
27
|
+
if (!Array.isArray(tables) || tableIndex < 0) return null;
|
|
28
|
+
return tables[tableIndex];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getTableById, getTableByIndex, getTableByName };
|
package/es/view/core.js
CHANGED
|
@@ -16,6 +16,28 @@ var getViewById = function getViewById(views, viewId) {
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Get view by name
|
|
21
|
+
* @param {array} views
|
|
22
|
+
* @param {string} viewName
|
|
23
|
+
* @returns view, object
|
|
24
|
+
*/
|
|
25
|
+
var getViewByName = function getViewByName(views, viewName) {
|
|
26
|
+
if (!Array.isArray(views) || !viewName) return null;
|
|
27
|
+
return views.find(function (view) {
|
|
28
|
+
return view.name === viewName;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Check whether the view is archived
|
|
34
|
+
* @param {object} view
|
|
35
|
+
* @returns bool
|
|
36
|
+
*/
|
|
37
|
+
var isArchiveView = function isArchiveView(view) {
|
|
38
|
+
return view.type === 'archive';
|
|
39
|
+
};
|
|
40
|
+
|
|
19
41
|
/**
|
|
20
42
|
* Check whether the view contains filters
|
|
21
43
|
* @param {object} view e.g. { filters, ... }
|
|
@@ -49,6 +71,17 @@ var isSortView = function isSortView(view, columns) {
|
|
|
49
71
|
return validSorts.length > 0;
|
|
50
72
|
};
|
|
51
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Check whether the view has hidden columns
|
|
76
|
+
* @param {object} view e.g. { hidden_columns, ... }
|
|
77
|
+
* @returns bool
|
|
78
|
+
*/
|
|
79
|
+
var isHiddenColumnsView = function isHiddenColumnsView(view) {
|
|
80
|
+
var _ref = view || {},
|
|
81
|
+
hidden_columns = _ref.hidden_columns;
|
|
82
|
+
return Array.isArray(hidden_columns) && hidden_columns.length > 0;
|
|
83
|
+
};
|
|
84
|
+
|
|
52
85
|
/**
|
|
53
86
|
* Check is default view which no contains filters, sorts, groupbys etc.
|
|
54
87
|
* @param {object} view e.g. { filters, groupbys, sorts, ... }
|
|
@@ -131,4 +164,30 @@ var getLinkColumnsUsedInFilters = function getLinkColumnsUsedInFilters(view, tab
|
|
|
131
164
|
return linkColumns;
|
|
132
165
|
};
|
|
133
166
|
|
|
134
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Get no-archived views
|
|
169
|
+
* @param {array} views
|
|
170
|
+
* @returns no-archived views, array
|
|
171
|
+
*/
|
|
172
|
+
var getNonArchiveViews = function getNonArchiveViews(views) {
|
|
173
|
+
if (!Array.isArray(views)) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
return views.filter(function (view) {
|
|
177
|
+
return !isArchiveView(view);
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
var getViewShownColumns = function getViewShownColumns(view, columns) {
|
|
181
|
+
if (!Array.isArray(columns)) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
if (!isHiddenColumnsView(view)) {
|
|
185
|
+
return columns;
|
|
186
|
+
}
|
|
187
|
+
var hidden_columns = view.hidden_columns;
|
|
188
|
+
return columns.filter(function (column) {
|
|
189
|
+
return !hidden_columns.includes(column.key);
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { getLinkColumnsUsedInFilters, getNonArchiveViews, getViewById, getViewByName, getViewShownColumns, isArchiveView, isDefaultView, isFilterView, isGroupView, isHiddenColumnsView, isSortView };
|
package/es/view/summaries.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { getRowsByIds } from '../table/row.js';
|
|
2
2
|
import { isTableRows } from '../row/core.js';
|
|
3
|
+
import '../cell-value-get/cell-value.js';
|
|
4
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
5
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
6
|
+
import { FORMULA_COLUMN_TYPES_MAP } from '../constants/formula.js';
|
|
7
|
+
import '@babel/runtime/helpers/typeof';
|
|
3
8
|
import { isNumericColumn } from '../column/number.js';
|
|
4
9
|
import { isNumber } from '../number.js';
|
|
5
|
-
import { FORMULA_COLUMN_TYPES_MAP } from '../constants/formula.js';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Calculate summaries of table numeric columns
|
package/lib/column/core.js
CHANGED
|
@@ -30,4 +30,20 @@ var getColumnType = function getColumnType(column) {
|
|
|
30
30
|
return type;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Get columns by type.
|
|
35
|
+
* @param {array} columns
|
|
36
|
+
* @param {string} columnType
|
|
37
|
+
* @returns the target type columns, array
|
|
38
|
+
*/
|
|
39
|
+
var getColumnsByType = function getColumnsByType(columns, columnType) {
|
|
40
|
+
if (!Array.isArray(columns) || !columnType) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return columns.filter(function (column) {
|
|
44
|
+
return column.type === columnType;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
33
48
|
exports.getColumnType = getColumnType;
|
|
49
|
+
exports.getColumnsByType = getColumnsByType;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var TABLE_PERMISSION_TYPE = {
|
|
6
|
+
DEFAULT: 'default',
|
|
7
|
+
ADMINS: 'admins',
|
|
8
|
+
SPECIFIC_USERS: 'specific_users',
|
|
9
|
+
NONE: 'none'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.TABLE_PERMISSION_TYPE = TABLE_PERMISSION_TYPE;
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var selectOption = require('./constants/select-option.js');
|
|
|
10
10
|
var sort = require('./constants/sort.js');
|
|
11
11
|
var group = require('./constants/group.js');
|
|
12
12
|
var columnPermission = require('./constants/column-permission.js');
|
|
13
|
+
var tablePermission = require('./constants/table-permission.js');
|
|
13
14
|
var reg = require('./constants/reg.js');
|
|
14
15
|
var color = require('./constants/color.js');
|
|
15
16
|
var gridHeader = require('./constants/grid-header.js');
|
|
@@ -18,6 +19,7 @@ var core = require('./table/core.js');
|
|
|
18
19
|
var column$1 = require('./table/column.js');
|
|
19
20
|
var row = require('./table/row.js');
|
|
20
21
|
var core$1 = require('./row/core.js');
|
|
22
|
+
var convert = require('./row/convert.js');
|
|
21
23
|
var core$2 = require('./view/core.js');
|
|
22
24
|
var summaries = require('./view/summaries.js');
|
|
23
25
|
var formula$1 = require('./view/formula.js');
|
|
@@ -36,6 +38,7 @@ var cellValue = require('./cell-value-get/cell-value.js');
|
|
|
36
38
|
var rate = require('./cell-value-get/rate.js');
|
|
37
39
|
var number$1 = require('./cell-value-set/number.js');
|
|
38
40
|
var date$1 = require('./cell-value-set/date.js');
|
|
41
|
+
var core$4 = require('./column/core.js');
|
|
39
42
|
var option$1 = require('./column/option.js');
|
|
40
43
|
var date$2 = require('./column/date.js');
|
|
41
44
|
var number$2 = require('./column/number.js');
|
|
@@ -44,7 +47,7 @@ var number$3 = require('./number.js');
|
|
|
44
47
|
var filter = require('./validate/filter.js');
|
|
45
48
|
var email = require('./validate/email.js');
|
|
46
49
|
var geolocation$1 = require('./validate/geolocation.js');
|
|
47
|
-
var core$
|
|
50
|
+
var core$5 = require('./filter/core.js');
|
|
48
51
|
var checkbox = require('./filter/filter-column/checkbox.js');
|
|
49
52
|
var collaborator$1 = require('./filter/filter-column/collaborator.js');
|
|
50
53
|
var creator = require('./filter/filter-column/creator.js');
|
|
@@ -61,7 +64,7 @@ var singleSelect = require('./filter/filter-column/single-select.js');
|
|
|
61
64
|
var link = require('./filter/filter-column/link.js');
|
|
62
65
|
var filterPredicate = require('./constants/filter/filter-predicate.js');
|
|
63
66
|
var filterRow = require('./filter/filter-row.js');
|
|
64
|
-
var core$
|
|
67
|
+
var core$6 = require('./sort/core.js');
|
|
65
68
|
var checkbox$1 = require('./sort/sort-column/checkbox.js');
|
|
66
69
|
var collaborator$2 = require('./sort/sort-column/collaborator.js');
|
|
67
70
|
var date$5 = require('./sort/sort-column/date.js');
|
|
@@ -73,7 +76,7 @@ var number$5 = require('./sort/sort-column/number.js');
|
|
|
73
76
|
var singleSelect$1 = require('./sort/sort-column/single-select.js');
|
|
74
77
|
var text$1 = require('./sort/sort-column/text.js');
|
|
75
78
|
var sortRow = require('./sort/sort-row.js');
|
|
76
|
-
var core$
|
|
79
|
+
var core$7 = require('./group/core.js');
|
|
77
80
|
var groupRow = require('./group/group-row.js');
|
|
78
81
|
var gradientColor = require('./color/gradient-color.js');
|
|
79
82
|
var columnColor = require('./color/column-color.js');
|
|
@@ -123,6 +126,7 @@ exports.GROUP_GEOLOCATION_GRANULARITY = group.GROUP_GEOLOCATION_GRANULARITY;
|
|
|
123
126
|
exports.MAX_GROUP_LEVEL = group.MAX_GROUP_LEVEL;
|
|
124
127
|
exports.SUPPORT_GROUP_COLUMN_TYPES = group.SUPPORT_GROUP_COLUMN_TYPES;
|
|
125
128
|
exports.COLUMN_PERMISSION_TYPE = columnPermission.COLUMN_PERMISSION_TYPE;
|
|
129
|
+
exports.TABLE_PERMISSION_TYPE = tablePermission.TABLE_PERMISSION_TYPE;
|
|
126
130
|
exports.REG_NUMBER_DIGIT = reg.REG_NUMBER_DIGIT;
|
|
127
131
|
exports.REG_STRING_NUMBER_PARTS = reg.REG_STRING_NUMBER_PARTS;
|
|
128
132
|
exports.COLOR_GRADATION_OPTIONS = color.COLOR_GRADATION_OPTIONS;
|
|
@@ -131,17 +135,24 @@ exports.generatorBase64Code = common.generatorBase64Code;
|
|
|
131
135
|
exports.isEmpty = common.isEmpty;
|
|
132
136
|
exports.isEmptyObject = common.isEmptyObject;
|
|
133
137
|
exports.getTableById = core.getTableById;
|
|
138
|
+
exports.getTableByIndex = core.getTableByIndex;
|
|
139
|
+
exports.getTableByName = core.getTableByName;
|
|
134
140
|
exports.getTableColumnByKey = column$1.getTableColumnByKey;
|
|
135
141
|
exports.getTableColumnByName = column$1.getTableColumnByName;
|
|
136
142
|
exports.getRowById = row.getRowById;
|
|
137
143
|
exports.getRowsByIds = row.getRowsByIds;
|
|
138
|
-
exports.convertRow = core$1.convertRow;
|
|
139
144
|
exports.isTableRows = core$1.isTableRows;
|
|
145
|
+
exports.convertRow = convert.convertRow;
|
|
140
146
|
exports.getLinkColumnsUsedInFilters = core$2.getLinkColumnsUsedInFilters;
|
|
147
|
+
exports.getNonArchiveViews = core$2.getNonArchiveViews;
|
|
141
148
|
exports.getViewById = core$2.getViewById;
|
|
149
|
+
exports.getViewByName = core$2.getViewByName;
|
|
150
|
+
exports.getViewShownColumns = core$2.getViewShownColumns;
|
|
151
|
+
exports.isArchiveView = core$2.isArchiveView;
|
|
142
152
|
exports.isDefaultView = core$2.isDefaultView;
|
|
143
153
|
exports.isFilterView = core$2.isFilterView;
|
|
144
154
|
exports.isGroupView = core$2.isGroupView;
|
|
155
|
+
exports.isHiddenColumnsView = core$2.isHiddenColumnsView;
|
|
145
156
|
exports.isSortView = core$2.isSortView;
|
|
146
157
|
exports.getSummaries = summaries.getSummaries;
|
|
147
158
|
exports.getSummariesWithSubgroups = summaries.getSummariesWithSubgroups;
|
|
@@ -155,6 +166,7 @@ exports.getLinkById = core$3.getLinkById;
|
|
|
155
166
|
exports.getLinkCellValue = core$3.getLinkCellValue;
|
|
156
167
|
exports.getLinkTableID = core$3.getLinkTableID;
|
|
157
168
|
exports.getLinkedTableID = core$3.getLinkedTableID;
|
|
169
|
+
exports.getTableLinkRows = core$3.getTableLinkRows;
|
|
158
170
|
exports.isValidLink = core$3.isValidLink;
|
|
159
171
|
exports.getDateDisplayString = date.getDateDisplayString;
|
|
160
172
|
exports.getDurationDisplayString = duration.getDurationDisplayString;
|
|
@@ -181,6 +193,8 @@ exports.formatDurationToNumber = number$1.formatDurationToNumber;
|
|
|
181
193
|
exports.formatStringToNumber = number$1.formatStringToNumber;
|
|
182
194
|
exports.getFloatNumber = number$1.getFloatNumber;
|
|
183
195
|
exports.formatTextToDate = date$1.formatTextToDate;
|
|
196
|
+
exports.getColumnType = core$4.getColumnType;
|
|
197
|
+
exports.getColumnsByType = core$4.getColumnsByType;
|
|
184
198
|
exports.createOption = option$1.createOption;
|
|
185
199
|
exports.generateOptionID = option$1.generateOptionID;
|
|
186
200
|
exports.generatorCellOption = option$1.generatorCellOption;
|
|
@@ -197,13 +211,13 @@ exports.round = number$3.round;
|
|
|
197
211
|
exports.ValidateFilter = filter.ValidateFilter;
|
|
198
212
|
exports.isValidEmail = email.isValidEmail;
|
|
199
213
|
exports.isValidPosition = geolocation$1.isValidPosition;
|
|
200
|
-
exports.deleteInvalidFilter = core$
|
|
201
|
-
exports.getFormattedFilter = core$
|
|
202
|
-
exports.getFormattedFilterOtherDate = core$
|
|
203
|
-
exports.getFormattedFilters = core$
|
|
204
|
-
exports.getValidFilters = core$
|
|
205
|
-
exports.getValidFiltersWithoutError = core$
|
|
206
|
-
exports.otherDate = core$
|
|
214
|
+
exports.deleteInvalidFilter = core$5.deleteInvalidFilter;
|
|
215
|
+
exports.getFormattedFilter = core$5.getFormattedFilter;
|
|
216
|
+
exports.getFormattedFilterOtherDate = core$5.getFormattedFilterOtherDate;
|
|
217
|
+
exports.getFormattedFilters = core$5.getFormattedFilters;
|
|
218
|
+
exports.getValidFilters = core$5.getValidFilters;
|
|
219
|
+
exports.getValidFiltersWithoutError = core$5.getValidFiltersWithoutError;
|
|
220
|
+
exports.otherDate = core$5.otherDate;
|
|
207
221
|
exports.checkboxFilter = checkbox.checkboxFilter;
|
|
208
222
|
exports.collaboratorFilter = collaborator$1.collaboratorFilter;
|
|
209
223
|
exports.creatorFilter = creator.creatorFilter;
|
|
@@ -223,10 +237,10 @@ exports.FILTER_PREDICATE_TYPE = filterPredicate.FILTER_PREDICATE_TYPE;
|
|
|
223
237
|
exports.filterRow = filterRow.filterRow;
|
|
224
238
|
exports.filterRows = filterRow.filterRows;
|
|
225
239
|
exports.getFilteredRowsWithoutFormulaCalculation = filterRow.getFilteredRowsWithoutFormulaCalculation;
|
|
226
|
-
exports.deleteInvalidSort = core$
|
|
227
|
-
exports.getMultipleIndexesOrderbyOptions = core$
|
|
228
|
-
exports.getValidSorts = core$
|
|
229
|
-
exports.isValidSort = core$
|
|
240
|
+
exports.deleteInvalidSort = core$6.deleteInvalidSort;
|
|
241
|
+
exports.getMultipleIndexesOrderbyOptions = core$6.getMultipleIndexesOrderbyOptions;
|
|
242
|
+
exports.getValidSorts = core$6.getValidSorts;
|
|
243
|
+
exports.isValidSort = core$6.isValidSort;
|
|
230
244
|
exports.sortCheckbox = checkbox$1.sortCheckbox;
|
|
231
245
|
exports.sortCollaborator = collaborator$2.sortCollaborator;
|
|
232
246
|
exports.sortDate = date$5.sortDate;
|
|
@@ -240,9 +254,9 @@ exports.compareString = text$1.compareString;
|
|
|
240
254
|
exports.sortText = text$1.sortText;
|
|
241
255
|
exports.sortRowsWithMultiSorts = sortRow.sortRowsWithMultiSorts;
|
|
242
256
|
exports.sortTableRows = sortRow.sortTableRows;
|
|
243
|
-
exports.deleteInvalidGroupby = core$
|
|
244
|
-
exports.getValidGroupbys = core$
|
|
245
|
-
exports.isValidGroupby = core$
|
|
257
|
+
exports.deleteInvalidGroupby = core$7.deleteInvalidGroupby;
|
|
258
|
+
exports.getValidGroupbys = core$7.getValidGroupbys;
|
|
259
|
+
exports.isValidGroupby = core$7.isValidGroupby;
|
|
246
260
|
exports.getGroupedRowsWithoutFormulaCalculation = groupRow.getGroupedRowsWithoutFormulaCalculation;
|
|
247
261
|
exports.groupTableRows = groupRow.groupTableRows;
|
|
248
262
|
exports.groupViewRows = groupRow.groupViewRows;
|