@gingkoo/pandora-metabase 1.0.41 → 1.0.43

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.
@@ -158,6 +158,18 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
158
158
  return v.fieldId != (val === null || val === void 0 ? void 0 : val.fieldId);
159
159
  });
160
160
  }
161
+ // 当前选中的表字段
162
+ var curTableColumn = data.filter(function (v) {
163
+ return v.tableUuid === curTable;
164
+ }).flatMap(function (v) {
165
+ return v.columns;
166
+ });
167
+ // 过滤选中字段不在当前选中的表字段中,
168
+ _value = _value.filter(function (item2) {
169
+ return curTableColumn.some(function (item1) {
170
+ return item1.name === item2.fieldName;
171
+ });
172
+ });
161
173
  setValue(_value);
162
174
  setCurTable(tableUuid);
163
175
  onSelect === null || onSelect === void 0 || onSelect(_value, getQuotes(_value));
@@ -226,6 +226,7 @@ var useStore = function useStore() {
226
226
  var _columns2;
227
227
  var oldColumns,
228
228
  callback,
229
+ oldObj,
229
230
  selectId,
230
231
  _table$alias,
231
232
  alias,
@@ -243,7 +244,9 @@ var useStore = function useStore() {
243
244
  oldColumns = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
244
245
  callback = _args2.length > 3 ? _args2[3] : undefined;
245
246
  // 获取之前选中的数据
247
+ oldObj = {};
246
248
  selectId = oldColumns.filter(function (v) {
249
+ oldObj[v.id] = v;
247
250
  return v.select;
248
251
  }).map(function (v) {
249
252
  return v.id;
@@ -265,9 +268,11 @@ var useStore = function useStore() {
265
268
  case 2:
266
269
  _columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
267
270
  var select = selectId.includes(v.id);
268
- return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
271
+ var obj = {};
272
+ obj = oldObj[v.id] || {};
273
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, obj), v), {}, {
269
274
  select: select,
270
- fieldUuid: v.fieldUuid || (0, _helper.uuidv4)('field')
275
+ fieldUuid: obj.fieldUuid || v.fieldUuid || (0, _helper.uuidv4)('field')
271
276
  });
272
277
  });
273
278
  typeof callback === 'function' && callback(_columns);
package/lib/cjs/utils.js CHANGED
@@ -713,7 +713,10 @@ var _isError = exports.isError = function isError(item, data) {
713
713
  }
714
714
  } else {
715
715
  var _tables$_datasourceId3;
716
- return !(tables !== null && tables !== void 0 && (_tables$_datasourceId3 = tables[_datasourceId]) !== null && _tables$_datasourceId3 !== void 0 && _tables$_datasourceId3[tableId]); // 注意:返回 true 表示“有错误”
716
+ var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
717
+ return v.name === fieldName;
718
+ })) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
719
+ return !hasField; // 注意:返回 true 表示“有错误”
717
720
  }
718
721
  }
719
722
  // 表达式类型
@@ -152,6 +152,18 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
152
152
  return v.fieldId != (val === null || val === void 0 ? void 0 : val.fieldId);
153
153
  });
154
154
  }
155
+ // 当前选中的表字段
156
+ var curTableColumn = data.filter(function (v) {
157
+ return v.tableUuid === curTable;
158
+ }).flatMap(function (v) {
159
+ return v.columns;
160
+ });
161
+ // 过滤选中字段不在当前选中的表字段中,
162
+ _value = _value.filter(function (item2) {
163
+ return curTableColumn.some(function (item1) {
164
+ return item1.name === item2.fieldName;
165
+ });
166
+ });
155
167
  setValue(_value);
156
168
  setCurTable(tableUuid);
157
169
  onSelect === null || onSelect === void 0 || onSelect(_value, getQuotes(_value));
@@ -219,6 +219,7 @@ var useStore = function useStore() {
219
219
  var _columns2;
220
220
  var oldColumns,
221
221
  callback,
222
+ oldObj,
222
223
  selectId,
223
224
  _table$alias,
224
225
  alias,
@@ -236,7 +237,9 @@ var useStore = function useStore() {
236
237
  oldColumns = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
237
238
  callback = _args2.length > 3 ? _args2[3] : undefined;
238
239
  // 获取之前选中的数据
240
+ oldObj = {};
239
241
  selectId = oldColumns.filter(function (v) {
242
+ oldObj[v.id] = v;
240
243
  return v.select;
241
244
  }).map(function (v) {
242
245
  return v.id;
@@ -258,9 +261,11 @@ var useStore = function useStore() {
258
261
  case 2:
259
262
  _columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
260
263
  var select = selectId.includes(v.id);
261
- return _objectSpread(_objectSpread({}, v), {}, {
264
+ var obj = {};
265
+ obj = oldObj[v.id] || {};
266
+ return _objectSpread(_objectSpread(_objectSpread({}, obj), v), {}, {
262
267
  select: select,
263
- fieldUuid: v.fieldUuid || uuidv4('field')
268
+ fieldUuid: obj.fieldUuid || v.fieldUuid || uuidv4('field')
264
269
  });
265
270
  });
266
271
  typeof callback === 'function' && callback(_columns);
package/lib/es/utils.js CHANGED
@@ -702,7 +702,10 @@ var _isError = function isError(item, data) {
702
702
  }
703
703
  } else {
704
704
  var _tables$_datasourceId3;
705
- return !(tables !== null && tables !== void 0 && (_tables$_datasourceId3 = tables[_datasourceId]) !== null && _tables$_datasourceId3 !== void 0 && _tables$_datasourceId3[tableId]); // 注意:返回 true 表示“有错误”
705
+ var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
706
+ return v.name === fieldName;
707
+ })) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
708
+ return !hasField; // 注意:返回 true 表示“有错误”
706
709
  }
707
710
  }
708
711
  // 表达式类型
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",