@abi-software/scaffoldvuer 1.13.1-beta.3 → 1.13.1-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "1.13.1-beta.3",
3
+ "version": "1.13.1-beta.4",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,7 +41,7 @@
41
41
  "*.js"
42
42
  ],
43
43
  "dependencies": {
44
- "@abi-software/map-utilities": "^1.7.8-beta.1",
44
+ "@abi-software/map-utilities": "^1.7.8-beta.2",
45
45
  "@abi-software/sparc-annotation": "^0.3.2",
46
46
  "@abi-software/svg-sprite": "1.0.3",
47
47
  "@element-plus/icons-vue": "^2.3.1",
@@ -53,7 +53,7 @@
53
53
  "unplugin-vue-components": "^0.26.0",
54
54
  "vue": "^3.4.21",
55
55
  "vue-router": "^4.2.5",
56
- "zincjs": "^1.16.5"
56
+ "zincjs": "^1.16.6"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@babel/eslint-parser": "^7.28.0",
@@ -210,21 +210,29 @@ export default {
210
210
  }
211
211
  }
212
212
  },
213
+ removeGroupFromRegionTreeData: function(region, groupName) {
214
+ const paths = region.getFullSeparatedPath();
215
+ const regionData = this.findOrCreateRegion(this.treeData[0], paths, "");
216
+ for (let i = 0; i < regionData.children.length; i++) {
217
+ if (regionData.children[i].label === groupName) {
218
+ regionData.children.splice(i, 1);
219
+ this.nodeNumbers--;
220
+ return;
221
+ }
222
+ }
223
+ },
224
+ zincObjectRenamed: function(zincObject, oldName) {
225
+ const objects = zincObject.region.findObjectsWithGroupName(oldName, false);
226
+ if (objects.length < 1) {
227
+ this.removeGroupFromRegionTreeData(zincObject.region, oldName);
228
+ }
229
+ this.zincObjectAdded(zincObject);
230
+ },
213
231
  zincObjectRemoved: function(zincObject) {
214
232
  const group = zincObject.groupName;
215
233
  const objects = zincObject.region.findObjectsWithGroupName(group, false);
216
234
  if (objects.length === 0) {
217
- const paths = zincObject.region.getFullSeparatedPath();
218
- const regionData = this.findOrCreateRegion(this.treeData[0], paths, "");
219
- if (regionData.children) {
220
- for (let i = 0; i < regionData.children.length; i++) {
221
- if (regionData.children[i].label === group) {
222
- regionData.children.splice(i, 1);
223
- this.nodeNumbers--;
224
- return;
225
- }
226
- }
227
- }
235
+ this.removeGroupFromRegionTreeData(zincObject.region, group);
228
236
  }
229
237
  },
230
238
  checkChanged: function (node, data) {
@@ -817,9 +817,10 @@ export default {
817
817
  colourRadio: true,
818
818
  createData: {
819
819
  drawingBox: false,
820
+ renaming: false,
820
821
  toBeConfirmed: false,
821
822
  points: [],
822
- tempGroupName: "",
823
+ tempGroupName: undefined,
823
824
  shape: "",
824
825
  x: 0,
825
826
  y: 0,
@@ -1204,6 +1205,18 @@ export default {
1204
1205
  }
1205
1206
  }
1206
1207
  },
1208
+ /**
1209
+ * Rename Zinc Object
1210
+ */
1211
+ renameZincObject: function (zincObject, newName) {
1212
+ if (this.$module.scene) {
1213
+ const scaffoldTreeControls = this.$refs.scaffoldTreeControls;
1214
+ const oldName = zincObject.groupName;
1215
+ zincObject.setName(newName);
1216
+ scaffoldTreeControls.zincObjectRenamed(zincObject, oldName);
1217
+ this.$_searchIndex.updateZincObject(zincObject, zincObject.uuid);
1218
+ }
1219
+ },
1207
1220
  /**
1208
1221
  * Internal only.
1209
1222
  * This is called when a zinc object is removed.
@@ -1321,6 +1334,45 @@ export default {
1321
1334
  }
1322
1335
  this.$emit('userPrimitivesUpdated', {region, group, zincObject});
1323
1336
  },
1337
+ /**
1338
+ * @public
1339
+ * Rename group in annotations, only support local annotations at this moment.
1340
+ * @arg `region`,
1341
+ * @arg `group`,
1342
+ * @arg `zincObject`,
1343
+ * @arg `oldName`
1344
+ */
1345
+ renameAnnotations: function (region, group, zincObject, oldName) {
1346
+ //Pending support for online annotation
1347
+ let regionPath = region.slice(-1) === "/" ? region : region + "/";
1348
+ const oldFeatureID = regionPath + oldName;
1349
+ const annotation = addUserAnnotationWithFeature(this.annotator, this.userToken, zincObject,
1350
+ region, group, this.url, `Rename from ${oldFeatureID}`);
1351
+ this.existDrawnFeatures = markRaw(this.existDrawnFeatures.filter(feature => feature.id !== oldFeatureID));
1352
+ this.existDrawnFeatures.push(annotation.feature);
1353
+ if (this.offlineAnnotationEnabled) {
1354
+ annotation.group = group;
1355
+ regionPath = region;
1356
+ if (regionPath.slice(-1) === "/") {
1357
+ regionPath = regionPath.slice(0, -1);
1358
+ }
1359
+ annotation.region = regionPath;
1360
+ //console.log(annotation, "oldName", oldName);
1361
+ this.offlineAnnotations = JSON.parse(sessionStorage.getItem('anonymous-annotation')) || [];
1362
+ const found = this.offlineAnnotations.find((element) => {
1363
+ return element.group === oldName &&
1364
+ element.region === annotation.region &&
1365
+ element.resource === annotation.resource &&
1366
+ element.feature.geometry.type === annotation.feature.geometry.type;
1367
+ });
1368
+ if (found) {
1369
+ //console.log('found', found)
1370
+ Object.assign(found, annotation);
1371
+ }
1372
+ sessionStorage.setItem('anonymous-annotation', JSON.stringify(this.offlineAnnotations));
1373
+ }
1374
+ this.$emit('userPrimitivesUpdated', {region, group, zincObject, renamedFrom: oldName});
1375
+ },
1324
1376
  /**
1325
1377
  * @public
1326
1378
  * Callback for when primitives have been update using primitive controls.
@@ -1373,6 +1425,11 @@ export default {
1373
1425
  const group = this._editingZincObject.groupName;
1374
1426
  this.addAndEditAnnotations(region, group, this._editingZincObject, "Position Updated");
1375
1427
  }
1428
+ } else if (payload.renaming) {
1429
+ const oldGroupName = this._editingZincObject.groupName;
1430
+ this.renameZincObject(this._editingZincObject, payload.group);
1431
+ this.renameAnnotations(payload.region, payload.group,
1432
+ this._editingZincObject, oldGroupName);
1376
1433
  }
1377
1434
  if (object) {
1378
1435
  this.addAndEditAnnotations(payload.region, payload.group, object.zincObject, "Create");
@@ -1391,10 +1448,12 @@ export default {
1391
1448
  cancelCreate: function() {
1392
1449
  this.changeActiveByName(undefined);
1393
1450
  this.createData.points.length = 0;
1451
+ this.createData.renaming = false;
1394
1452
  this.createData.toBeConfirmed = false;
1395
1453
  this._editingZincObject = undefined;
1396
1454
  this.createData.editingIndex = -1;
1397
1455
  this.createData.faceIndex = -1;
1456
+ this.createData.tempGroupName = undefined;
1398
1457
  this.tData.visible = false;
1399
1458
  this.createData.toBeDeleted = false;
1400
1459
  if (this._tempLine) {
@@ -1564,6 +1623,7 @@ export default {
1564
1623
  this.$module.selectObjectOnPick = true;
1565
1624
  } else if (type === 'tool') {
1566
1625
  this.activeDrawTool = icon;
1626
+ this.createData.renaming = false;
1567
1627
  this.createData.shape = this.activeDrawTool ? this.activeDrawTool : '';
1568
1628
  this.$module.selectObjectOnPick = false;
1569
1629
  }
@@ -1699,6 +1759,9 @@ export default {
1699
1759
  if (this.createData.toBeConfirmed === false) {
1700
1760
  this.createData.points.length = 0;
1701
1761
  this.createData.points.push(coords);
1762
+ if (this.createData.editingIndex === -1 && !this.createData.renaming) {
1763
+ this.createData.tempGroupName = undefined;
1764
+ }
1702
1765
  this.createData.toBeConfirmed = true;
1703
1766
  this.showRegionTooltipWithAnnotations(data, true, false);
1704
1767
  this.tData.x = 50;
@@ -1712,6 +1775,9 @@ export default {
1712
1775
  if (this.createData.toBeConfirmed === false) {
1713
1776
  if (this.createData.points.length === 1) {
1714
1777
  this.createData.points.push(coords);
1778
+ if (this.createData.editingIndex === -1 && !this.createData.renaming) {
1779
+ this.createData.tempGroupName = undefined;
1780
+ }
1715
1781
  this.createData.toBeConfirmed = true;
1716
1782
  this.showRegionTooltipWithAnnotations(data, true, false);
1717
1783
  this.tData.x = 50;
@@ -1761,6 +1827,23 @@ export default {
1761
1827
  }
1762
1828
  }
1763
1829
  },
1830
+ activateRenamingMode: function(eventIdentifiers) {
1831
+ let editing = getEditablePoint(eventIdentifiers);
1832
+ if (!editing) {
1833
+ editing = getEditableLines(eventIdentifiers);
1834
+ }
1835
+ if (editing) {
1836
+ this._editingZincObject = editing.zincObject;
1837
+ this.createData.faceIndex = -1;
1838
+ this.createData.editingIndex = -1;
1839
+ this.createData.renaming = true;
1840
+ this.createData.tempGroupName = this._editingZincObject.groupName;
1841
+ this.createData.toBeConfirmed = true;
1842
+ this.showRegionTooltipWithAnnotations(eventIdentifiers, true, false);
1843
+ this.tData.x = 50;
1844
+ this.tData.y = 200;
1845
+ }
1846
+ },
1764
1847
  activateAnnotationMode: function(names, event) {
1765
1848
  if (this.authorisedUser || this.offlineAnnotationEnabled) {
1766
1849
  this.createData.toBeDeleted = false;
@@ -1768,8 +1851,6 @@ export default {
1768
1851
  // Create new shape bsaed on current settings
1769
1852
  if (names.length > 0) {
1770
1853
  if (event.identifiers[0].coords) {
1771
- this.createData.x = event.identifiers[0].coords.x;
1772
- this.createData.y = event.identifiers[0].coords.y;
1773
1854
  this.draw(event.identifiers);
1774
1855
  }
1775
1856
  }
@@ -1797,6 +1878,7 @@ export default {
1797
1878
  activatePointEditingMode: function(zincObject, index, point) {
1798
1879
  this._editingZincObject = zincObject;
1799
1880
  this.createData.faceIndex = -1;
1881
+ this.createData.renaming = false;
1800
1882
  this.createData.editingIndex = index;
1801
1883
  this.createData.tempGroupName = this._editingZincObject.groupName;
1802
1884
  //this.drawPoint(point, undefined);
@@ -1804,6 +1886,7 @@ export default {
1804
1886
  activateLineEditingMode: function(zincObject, faceIndex, vertexIndex, point) {
1805
1887
  this._editingZincObject = zincObject;
1806
1888
  this.createData.faceIndex = faceIndex;
1889
+ this.createData.renaming = false;
1807
1890
  this.createData.editingIndex = vertexIndex;
1808
1891
  this.createData.tempGroupName = this._editingZincObject.groupName;
1809
1892
  this.drawLine(point, undefined);
@@ -49,6 +49,19 @@ export class SearchIndex
49
49
  this.idMaps = {};
50
50
  }
51
51
 
52
+ updateZincObject(zincObject, id)
53
+ //=======================
54
+ {
55
+ const path = zincObject.getRegion().getFullPath();
56
+ let groupName = zincObject.groupName;
57
+ let fullPath = path ? `${path}/${zincObject.groupName}` : zincObject.groupName;
58
+ groupName = groupName.replaceAll('"', '');
59
+ fullPath = fullPath.replaceAll('"', '');
60
+ const item = { path: fullPath, name: groupName, id };
61
+ this._searchEngine.replace(item);
62
+ this.idMaps[id] = { path: fullPath, zincObject };
63
+ }
64
+
52
65
  addZincObject(zincObject, id)
53
66
  //=======================
54
67
  {
@@ -169,7 +182,7 @@ export class SearchIndex
169
182
  const result = this.search(term);
170
183
  results.push(...result);
171
184
  });
172
-
185
+
173
186
  return results;
174
187
  }
175
188