dtable-utils 5.0.6 → 5.0.7-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/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 +33 -18
- package/es/row/convert.js +10 -2
- 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 +33 -18
- package/lib/row/convert.js +10 -2
- package/package.json +1 -1
package/lib/link/core.js
CHANGED
|
@@ -70,23 +70,30 @@ 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}
|
|
73
|
+
* @param {string} link_id
|
|
74
|
+
* @param {string} table1_id
|
|
75
|
+
* @param {string} table2_id
|
|
76
|
+
* @param {string} row_id
|
|
77
|
+
* @param {boolean} is_linked_back, determine the self-link column which use 'table1_table2_map'
|
|
77
78
|
* @returns linked rows ids, array
|
|
78
79
|
*/
|
|
79
|
-
var getLinkCellValue = function getLinkCellValue(
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
var getLinkCellValue = function getLinkCellValue(_ref) {
|
|
81
|
+
var links = _ref.links,
|
|
82
|
+
link_id = _ref.link_id,
|
|
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);
|
|
82
89
|
if (!linkBetween2Tables) return [];
|
|
83
90
|
var linkMap = {};
|
|
84
|
-
if (
|
|
85
|
-
linkMap = linkBetween2Tables.table2_table1_map;
|
|
91
|
+
if (table1_id === table2_id) {
|
|
92
|
+
linkMap = is_linked_back ? linkBetween2Tables.table1_table2_map : linkBetween2Tables.table2_table1_map;
|
|
86
93
|
} else {
|
|
87
|
-
linkMap = linkBetween2Tables.table1_id ===
|
|
94
|
+
linkMap = linkBetween2Tables.table1_id === table1_id ? linkBetween2Tables.table1_table2_map : linkBetween2Tables.table2_table1_map;
|
|
88
95
|
}
|
|
89
|
-
var linkedRowIds = linkMap[
|
|
96
|
+
var linkedRowIds = linkMap[row_id];
|
|
90
97
|
if (!linkedRowIds) {
|
|
91
98
|
return [];
|
|
92
99
|
}
|
|
@@ -103,21 +110,29 @@ var getTableLinkRows = function getTableLinkRows(operateRows, table, value) {
|
|
|
103
110
|
linkColumns.forEach(function (column) {
|
|
104
111
|
var key = column.key,
|
|
105
112
|
data = column.data;
|
|
106
|
-
var
|
|
107
|
-
link_id =
|
|
108
|
-
table_id =
|
|
109
|
-
other_table_id =
|
|
113
|
+
var _ref2 = data || {},
|
|
114
|
+
link_id = _ref2.link_id,
|
|
115
|
+
table_id = _ref2.table_id,
|
|
116
|
+
other_table_id = _ref2.other_table_id,
|
|
117
|
+
is_linked_back = _ref2.is_linked_back;
|
|
110
118
|
var linkedTableId = currentTableId === table_id ? other_table_id : table_id;
|
|
111
119
|
var linkedTable = core$2.getTableById(tables, linkedTableId);
|
|
112
120
|
rows.forEach(function (row) {
|
|
113
|
-
var
|
|
114
|
-
var linkedRowIds = linkedTable && getLinkCellValue(
|
|
121
|
+
var row_id = row._id;
|
|
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
|
+
}) || [];
|
|
115
130
|
|
|
116
131
|
// Handle the linked row has been deleted, but link still exists
|
|
117
132
|
linkedRowIds = linkedRowIds.filter(function (linkedRowId) {
|
|
118
133
|
return linkedTable.id_row_map[linkedRowId];
|
|
119
134
|
});
|
|
120
|
-
linkRows[
|
|
135
|
+
linkRows[row_id] = _objectSpread(_objectSpread({}, linkRows[row_id]), {}, _defineProperty__default["default"]({}, key, linkedRowIds));
|
|
121
136
|
});
|
|
122
137
|
});
|
|
123
138
|
return linkRows;
|
package/lib/row/convert.js
CHANGED
|
@@ -161,10 +161,18 @@ 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
|
|
164
|
+
other_table_id = _column$data.other_table_id,
|
|
165
|
+
is_linked_back = _column$data.is_linked_back;
|
|
165
166
|
var otherTableID = tableID === table_id ? other_table_id : table_id;
|
|
166
167
|
var links = value.links;
|
|
167
|
-
result[columnName] = core.getLinkCellValue(
|
|
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
|
+
});
|
|
168
176
|
break;
|
|
169
177
|
}
|
|
170
178
|
case cellType.CellType.FORMULA:
|