dtable-utils 5.0.7-beta.1 → 5.0.8-beta.1
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/sql-generator/filter-condition.js +98 -19
- package/es/color/column-color.js +2 -2
- package/es/color/row-color.js +2 -2
- package/es/common.js +4 -1
- package/es/constants/column.js +1 -1
- package/es/filter/core.js +195 -20
- package/es/filter/filter-row.js +20 -4
- package/es/index.js +1 -1
- package/es/link/core.js +18 -33
- package/es/row/convert.js +2 -10
- package/lib/archive/sql-generator/filter-condition.js +100 -17
- package/lib/common.js +4 -0
- package/lib/constants/column.js +1 -1
- package/lib/filter/core.js +202 -19
- package/lib/filter/filter-row.js +19 -3
- package/lib/index.js +5 -0
- package/lib/link/core.js +18 -33
- package/lib/row/convert.js +2 -10
- package/package.json +1 -1
package/lib/link/core.js
CHANGED
|
@@ -70,30 +70,23 @@ var getLinkedTableID = function getLinkedTableID(currentTableID, tableID, otherT
|
|
|
70
70
|
/**
|
|
71
71
|
* Get linked rows ids by the given row id
|
|
72
72
|
* @param {array} links e.g. [ { _id, table1_id, table2_id, table1_table2_map, table2_table1_map, ... }, ... ]
|
|
73
|
-
* @param {string}
|
|
74
|
-
* @param {string}
|
|
75
|
-
* @param {string}
|
|
76
|
-
* @param {string}
|
|
77
|
-
* @param {boolean} is_linked_back, determine the self-link column which use 'table1_table2_map'
|
|
73
|
+
* @param {string} linkId
|
|
74
|
+
* @param {string} table1Id
|
|
75
|
+
* @param {string} table2Id
|
|
76
|
+
* @param {string} rowId
|
|
78
77
|
* @returns linked rows ids, array
|
|
79
78
|
*/
|
|
80
|
-
var getLinkCellValue = function getLinkCellValue(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
table1_id = _ref.table1_id,
|
|
84
|
-
table2_id = _ref.table2_id,
|
|
85
|
-
row_id = _ref.row_id,
|
|
86
|
-
is_linked_back = _ref.is_linked_back;
|
|
87
|
-
if (!Array.isArray(links) || links.length === 0 || !table1_id || !table2_id || !row_id) return [];
|
|
88
|
-
var linkBetween2Tables = getLinkById(links, link_id);
|
|
79
|
+
var getLinkCellValue = function getLinkCellValue(links, linkId, table1Id, table2Id, rowId) {
|
|
80
|
+
if (!Array.isArray(links) || links.length === 0 || !table1Id || !table2Id || !rowId) return [];
|
|
81
|
+
var linkBetween2Tables = getLinkById(links, linkId);
|
|
89
82
|
if (!linkBetween2Tables) return [];
|
|
90
83
|
var linkMap = {};
|
|
91
|
-
if (
|
|
92
|
-
linkMap =
|
|
84
|
+
if (table1Id === table2Id) {
|
|
85
|
+
linkMap = linkBetween2Tables.table2_table1_map;
|
|
93
86
|
} else {
|
|
94
|
-
linkMap = linkBetween2Tables.table1_id ===
|
|
87
|
+
linkMap = linkBetween2Tables.table1_id === table1Id ? linkBetween2Tables.table1_table2_map : linkBetween2Tables.table2_table1_map;
|
|
95
88
|
}
|
|
96
|
-
var linkedRowIds = linkMap[
|
|
89
|
+
var linkedRowIds = linkMap[rowId];
|
|
97
90
|
if (!linkedRowIds) {
|
|
98
91
|
return [];
|
|
99
92
|
}
|
|
@@ -110,29 +103,21 @@ var getTableLinkRows = function getTableLinkRows(operateRows, table, value) {
|
|
|
110
103
|
linkColumns.forEach(function (column) {
|
|
111
104
|
var key = column.key,
|
|
112
105
|
data = column.data;
|
|
113
|
-
var
|
|
114
|
-
link_id =
|
|
115
|
-
table_id =
|
|
116
|
-
other_table_id =
|
|
117
|
-
is_linked_back = _ref2.is_linked_back;
|
|
106
|
+
var _ref = data || {},
|
|
107
|
+
link_id = _ref.link_id,
|
|
108
|
+
table_id = _ref.table_id,
|
|
109
|
+
other_table_id = _ref.other_table_id;
|
|
118
110
|
var linkedTableId = currentTableId === table_id ? other_table_id : table_id;
|
|
119
111
|
var linkedTable = core$2.getTableById(tables, linkedTableId);
|
|
120
112
|
rows.forEach(function (row) {
|
|
121
|
-
var
|
|
122
|
-
var linkedRowIds = linkedTable && getLinkCellValue(
|
|
123
|
-
links: links,
|
|
124
|
-
link_id: link_id,
|
|
125
|
-
table1_id: currentTableId,
|
|
126
|
-
table2_id: linkedTableId,
|
|
127
|
-
row_id: row_id,
|
|
128
|
-
is_linked_back: is_linked_back
|
|
129
|
-
}) || [];
|
|
113
|
+
var rowId = row._id;
|
|
114
|
+
var linkedRowIds = linkedTable && getLinkCellValue(links, link_id, currentTableId, linkedTableId, rowId) || [];
|
|
130
115
|
|
|
131
116
|
// Handle the linked row has been deleted, but link still exists
|
|
132
117
|
linkedRowIds = linkedRowIds.filter(function (linkedRowId) {
|
|
133
118
|
return linkedTable.id_row_map[linkedRowId];
|
|
134
119
|
});
|
|
135
|
-
linkRows[
|
|
120
|
+
linkRows[rowId] = _objectSpread(_objectSpread({}, linkRows[rowId]), {}, _defineProperty__default["default"]({}, key, linkedRowIds));
|
|
136
121
|
});
|
|
137
122
|
});
|
|
138
123
|
return linkRows;
|
package/lib/row/convert.js
CHANGED
|
@@ -161,18 +161,10 @@ var convertRow = function convertRow(row, value, table, view, formulaResults, co
|
|
|
161
161
|
var _column$data = column.data,
|
|
162
162
|
link_id = _column$data.link_id,
|
|
163
163
|
table_id = _column$data.table_id,
|
|
164
|
-
other_table_id = _column$data.other_table_id
|
|
165
|
-
is_linked_back = _column$data.is_linked_back;
|
|
164
|
+
other_table_id = _column$data.other_table_id;
|
|
166
165
|
var otherTableID = tableID === table_id ? other_table_id : table_id;
|
|
167
166
|
var links = value.links;
|
|
168
|
-
result[columnName] = core.getLinkCellValue(
|
|
169
|
-
links: links,
|
|
170
|
-
link_id: link_id,
|
|
171
|
-
is_linked_back: is_linked_back,
|
|
172
|
-
table1_id: tableID,
|
|
173
|
-
table2_id: otherTableID,
|
|
174
|
-
row_id: row._id
|
|
175
|
-
});
|
|
167
|
+
result[columnName] = core.getLinkCellValue(links, link_id, tableID, otherTableID, row._id);
|
|
176
168
|
break;
|
|
177
169
|
}
|
|
178
170
|
case cellType.CellType.FORMULA:
|