@riil-frontend/component-topology 2.10.0 → 2.10.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.
@@ -312,13 +312,18 @@ var useTopoEdit = function useTopoEdit(params) {
312
312
 
313
313
  var deleteGroup = function deleteGroup(data) {
314
314
  var id = data.id,
315
- tag = data.tag; // 因为新加的容器 tag 格式为 group_${id}
315
+ tag = data.tag; // 新加的容器 tag 格式为 group_${id}
316
316
 
317
- var groupTag = typeof tag === 'string' ? tag.replace('group_', '') : tag;
318
- var group = topoApp.getDataModel().getDataById(groupTag) || topoApp.getDataModel().getDataByTag(id);
317
+ var group = topoApp.getDataModel().getDataById(tag) || topoApp.getDataModel().getDataByTag(id) || topoApp.getDataModel().getDatas().toArray().filter(function (item) {
318
+ return item.a('tag') === tag;
319
+ })[0];
319
320
 
320
321
  if (!group) {
321
322
  return;
323
+ }
324
+
325
+ if (!group.getChildren().length) {
326
+ doDelete();
322
327
  } // 有子节点时需要确认
323
328
 
324
329
 
@@ -334,23 +339,13 @@ var useTopoEdit = function useTopoEdit(params) {
334
339
  },
335
340
  onOk: function () {
336
341
  var _onOk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
337
- var index;
338
342
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
339
343
  while (1) {
340
344
  switch (_context2.prev = _context2.next) {
341
345
  case 0:
342
- index = groups.findIndex(function (group) {
343
- return id ? group.id === id : group.tag === tag;
344
- }); // Existing group
345
-
346
- if (index > -1) {
347
- editDispatchers.deleteGroup(index);
348
- } // FIXME 。如果命中其他的动态条件,则立即显示
349
-
350
-
351
- topoApp.view.topoClient.deleteGroup(data);
346
+ doDelete();
352
347
 
353
- case 3:
348
+ case 1:
354
349
  case "end":
355
350
  return _context2.stop();
356
351
  }
@@ -366,6 +361,19 @@ var useTopoEdit = function useTopoEdit(params) {
366
361
  }()
367
362
  });
368
363
  }
364
+
365
+ function doDelete() {
366
+ var index = groups.findIndex(function (group) {
367
+ return id ? group.id === id : group.tag === tag;
368
+ }); // Existing group
369
+
370
+ if (index > -1) {
371
+ editDispatchers.deleteGroup(index);
372
+ } // FIXME 。如果命中其他的动态条件,则立即显示
373
+
374
+
375
+ topoApp.view.topoClient.deleteGroup(data);
376
+ }
369
377
  };
370
378
  /**
371
379
  * 删除容器内的单个资源
@@ -336,13 +336,18 @@ var useTopoEdit = function useTopoEdit(params) {
336
336
 
337
337
  var deleteGroup = function deleteGroup(data) {
338
338
  var id = data.id,
339
- tag = data.tag; // 因为新加的容器 tag 格式为 group_${id}
339
+ tag = data.tag; // 新加的容器 tag 格式为 group_${id}
340
340
 
341
- var groupTag = typeof tag === 'string' ? tag.replace('group_', '') : tag;
342
- var group = topoApp.getDataModel().getDataById(groupTag) || topoApp.getDataModel().getDataByTag(id);
341
+ var group = topoApp.getDataModel().getDataById(tag) || topoApp.getDataModel().getDataByTag(id) || topoApp.getDataModel().getDatas().toArray().filter(function (item) {
342
+ return item.a('tag') === tag;
343
+ })[0];
343
344
 
344
345
  if (!group) {
345
346
  return;
347
+ }
348
+
349
+ if (!group.getChildren().length) {
350
+ doDelete();
346
351
  } // 有子节点时需要确认
347
352
 
348
353
 
@@ -358,23 +363,13 @@ var useTopoEdit = function useTopoEdit(params) {
358
363
  },
359
364
  onOk: function () {
360
365
  var _onOk = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
361
- var index;
362
366
  return _regenerator["default"].wrap(function _callee2$(_context2) {
363
367
  while (1) {
364
368
  switch (_context2.prev = _context2.next) {
365
369
  case 0:
366
- index = groups.findIndex(function (group) {
367
- return id ? group.id === id : group.tag === tag;
368
- }); // Existing group
369
-
370
- if (index > -1) {
371
- editDispatchers.deleteGroup(index);
372
- } // FIXME 。如果命中其他的动态条件,则立即显示
373
-
374
-
375
- topoApp.view.topoClient.deleteGroup(data);
370
+ doDelete();
376
371
 
377
- case 3:
372
+ case 1:
378
373
  case "end":
379
374
  return _context2.stop();
380
375
  }
@@ -390,6 +385,19 @@ var useTopoEdit = function useTopoEdit(params) {
390
385
  }()
391
386
  });
392
387
  }
388
+
389
+ function doDelete() {
390
+ var index = groups.findIndex(function (group) {
391
+ return id ? group.id === id : group.tag === tag;
392
+ }); // Existing group
393
+
394
+ if (index > -1) {
395
+ editDispatchers.deleteGroup(index);
396
+ } // FIXME 。如果命中其他的动态条件,则立即显示
397
+
398
+
399
+ topoApp.view.topoClient.deleteGroup(data);
400
+ }
393
401
  };
394
402
  /**
395
403
  * 删除容器内的单个资源
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -105,6 +105,6 @@
105
105
  "access": "public"
106
106
  },
107
107
  "license": "MIT",
108
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@2.10.0/build/index.html",
108
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@2.10.1/build/index.html",
109
109
  "gitHead": "62eadeca07c85ed047f2e933676f62015eff98cc"
110
110
  }