15
15
:x =" tData.x"
16
16
:y =" tData.y"
17
17
:annotationDisplay =" annotationDisplay"
18
+ :annotationFeature =" annotationFeature"
19
+ :offlineAnnotationEnabled =" offlineAnnotationEnabled"
18
20
@confirm-create =" confirmCreate($event)"
19
21
@cancel-create =" cancelCreate()"
22
+ @confirm-comment =" confirmComment($event)"
20
23
@confirm-delete =" confirmDelete()"
21
24
@tooltip-hide =" onTooltipHide()"
22
25
/>
@@ -399,8 +402,10 @@ import { MapSvgIcon, MapSvgSpriteColor } from "@abi-software/svg-sprite";
399
402
import { DrawToolbar } from ' @abi-software/map-utilities'
400
403
import ' @abi-software/map-utilities/dist/style.css'
401
404
import {
405
+ createNewAnnotationsWithFeatures ,
402
406
addUserAnnotationWithFeature ,
403
407
annotationFeaturesToPrimitives ,
408
+ getClickedObjects ,
404
409
getDeletableObjects ,
405
410
getDrawnAnnotations ,
406
411
getEditableLines ,
@@ -805,6 +810,7 @@ export default {
805
810
},
806
811
openMapRef: undefined ,
807
812
backgroundIconRef: undefined ,
813
+ annotationFeature: {},
808
814
offlineAnnotationEnabled: false ,
809
815
offlineAnnotations: markRaw ([]),
810
816
authorisedUser: undefined ,
@@ -1030,15 +1036,11 @@ export default {
1030
1036
zincObjectRemoved : function (zincObject ) {
1031
1037
if (this .$module .scene ) {
1032
1038
// zincObjectAdded will be alled in sequential callback
1033
- const regionPath = zincObject .region .getFullPath ();
1034
1039
const groupName = zincObject .groupName ;
1035
1040
const objects = zincObject .region .findObjectsWithGroupName (groupName, false );
1036
1041
// Remove relevant objects from the rest of the app.
1037
1042
if (objects .length === 0 ) {
1038
1043
this .$_searchIndex .removeZincObject (zincObject, zincObject .uuid );
1039
- if (this .offlineAnnotationEnabled ) {
1040
- this .removeFromOfflineAnnotation (regionPath, groupName);
1041
- }
1042
1044
}
1043
1045
}
1044
1046
},
@@ -1129,8 +1131,6 @@ export default {
1129
1131
}
1130
1132
annotation .region = regionPath;
1131
1133
this .offlineAnnotations = JSON .parse (sessionStorage .getItem (' offline-annotation' )) || [];
1132
- // Remove previous entry if there is matching region and group
1133
- this .removeFromOfflineAnnotation (regionPath, group);
1134
1134
this .offlineAnnotations .push (annotation);
1135
1135
sessionStorage .setItem (' offline-annotation' , JSON .stringify (this .offlineAnnotations ));
1136
1136
}
@@ -1215,6 +1215,27 @@ export default {
1215
1215
this .$emit (" annotation-close" );
1216
1216
}
1217
1217
},
1218
+ /**
1219
+ * Internal only.
1220
+ * Confirm delete of user created primitive.
1221
+ * This is only called from callback.
1222
+ */
1223
+ confirmComment : function (payload ) {
1224
+ if (this ._editingZincObject ) {
1225
+ let annotation = payload
1226
+ if (this ._editingZincObject .isEditable ) {
1227
+ this .existDrawnFeatures = markRaw (this .existDrawnFeatures .filter (feature => feature .id !== annotation .item .id ));
1228
+ this .existDrawnFeatures .push (payload .feature );
1229
+ }
1230
+ if (this .offlineAnnotationEnabled ) {
1231
+ annotation .group = this ._editingZincObject .groupName ;;
1232
+ annotation .region = this ._editingZincObject .region .getFullPath ();
1233
+ this .offlineAnnotations = JSON .parse (sessionStorage .getItem (' offline-annotation' )) || [];
1234
+ this .offlineAnnotations .push (annotation);
1235
+ sessionStorage .setItem (' offline-annotation' , JSON .stringify (this .offlineAnnotations ));
1236
+ }
1237
+ }
1238
+ },
1218
1239
/**
1219
1240
* Internal only.
1220
1241
* Confirm delete of user created primitive.
@@ -1231,6 +1252,8 @@ export default {
1231
1252
const childRegion = this .$module .scene .getRootRegion ().findChildFromPath (regionPath);
1232
1253
childRegion .removeZincObject (this ._editingZincObject );
1233
1254
if (this .offlineAnnotationEnabled ) {
1255
+ this .offlineAnnotations = JSON .parse (sessionStorage .getItem (' offline-annotation' )) || [];
1256
+ this .offlineAnnotations = this .offlineAnnotations .filter (offline => offline .item .id !== annotation .item .id );
1234
1257
sessionStorage .setItem (' offline-annotation' , JSON .stringify (this .offlineAnnotations ));
1235
1258
}
1236
1259
}
@@ -1572,6 +1595,14 @@ export default {
1572
1595
if (this .viewingMode === ' Annotation' ) {
1573
1596
this .tData .label = id;
1574
1597
this .tData .region = regionPath;
1598
+ const zincObject = getClickedObjects (event );
1599
+ this ._editingZincObject = zincObject;
1600
+ if (zincObject) {
1601
+ const regionPath = this ._editingZincObject .region .getFullPath () + " /" ;
1602
+ const group = this ._editingZincObject .groupName ;
1603
+ this .annotationFeature = createNewAnnotationsWithFeatures (this ._editingZincObject ,
1604
+ regionPath, group, this .url , ' ' ).feature ;
1605
+ }
1575
1606
this .activateAnnotationMode (names, event );
1576
1607
} else {
1577
1608
if (this .$refs .scaffoldTreeControls ) {
@@ -1965,13 +1996,16 @@ export default {
1965
1996
" featureId" : region + this .tData .label ,
1966
1997
" resourceId" : this .url ,
1967
1998
" resource" : this .url ,
1999
+ " feature" : this .annotationFeature ,
2000
+ " offline" : this .offlineAnnotationEnabled ,
1968
2001
};
1969
2002
this .$emit (' annotation-open' , {
1970
2003
annotationEntry: annotationEntry,
1971
2004
createData: this .createData ,
1972
2005
confirmCreate: this .confirmCreate ,
1973
2006
cancelCreate: this .cancelCreate ,
1974
2007
confirmDelete: this .confirmDelete ,
2008
+ confirmComment: this .confirmComment
1975
2009
});
1976
2010
return ;
1977
2011
}
@@ -2000,7 +2034,9 @@ export default {
2000
2034
let drawnFeatures;
2001
2035
if (this .offlineAnnotationEnabled ) {
2002
2036
this .offlineAnnotations = JSON .parse (sessionStorage .getItem (' offline-annotation' )) || [];
2003
- drawnFeatures = this .offlineAnnotations .filter ((offline ) => offline .resource === this .url ).map (offline => offline .feature );
2037
+ drawnFeatures = this .offlineAnnotations .filter ((offline ) => {
2038
+ return offline .resource === this .url && offline .feature .properties .drawn ;
2039
+ }).map (offline => offline .feature );
2004
2040
} else {
2005
2041
drawnFeatures = [];
2006
2042
const drawn = await getDrawnAnnotations (this .annotator , this .userToken , this .url );
0 commit comments