diff --git a/resources/assets/js/annotations/annotatorContainer.vue b/resources/assets/js/annotations/annotatorContainer.vue index 2b3d700bf..46f5b81a3 100644 --- a/resources/assets/js/annotations/annotatorContainer.vue +++ b/resources/assets/js/annotations/annotatorContainer.vue @@ -353,10 +353,10 @@ export default { handleDetachAnnotationLabel(annotation, annotationLabel) { if (this.isEditor) { if (annotation.labels.length > 1) { - AnnotationsStore.detachLabel(annotation, annotationLabel) + return AnnotationsStore.detachLabel(annotation, annotationLabel) .catch(handleErrorResponse); } else if (confirm('Detaching the last label of an annotation deletes the whole annotation. Do you want to delete the annotation?')) { - this.handleDeleteAnnotation(annotation); + return this.handleDeleteAnnotation(annotation); } } }, @@ -370,7 +370,7 @@ export default { // Mark for deletion so the annotation is immediately removed from // the canvas. See https://github.com/biigle/annotations/issues/70 Vue.set(annotation, 'markedForDeletion', true); - AnnotationsStore.delete(annotation) + return AnnotationsStore.delete(annotation) .catch(function (response) { annotation.markedForDeletion = false; handleErrorResponse(response); @@ -443,12 +443,18 @@ export default { this.handleAttachLabel(annotation, label) .then(() => { if (lastLabel) { - this.handleDetachAnnotationLabel(annotation, lastLabel); + this.handleDetachAnnotationLabel(annotation, lastLabel) + .then(() => { + this.refreshAnnotation(annotation); + }); } }) .catch(handleErrorResponse); } }, + refreshAnnotation(annotation){ + this.$refs.canvas.refreshAnnotation(annotation); + }, handleAttachAllSelected() { this.selectedAnnotations.forEach(this.handleAttachLabel); }, diff --git a/resources/assets/js/annotations/components/annotationCanvas.vue b/resources/assets/js/annotations/components/annotationCanvas.vue index cb3584004..784ff6e47 100644 --- a/resources/assets/js/annotations/components/annotationCanvas.vue +++ b/resources/assets/js/annotations/components/annotationCanvas.vue @@ -596,6 +596,17 @@ export default { }, updateMousePosition(e) { this.mousePosition = e.coordinate; + }, + refreshAnnotation(annotation) { + let source = this.annotationSource; + + let newFeature = this.createFeature(annotation); + let oldFeature = source.getFeatureById(annotation.id) + + source.removeFeature(oldFeature); + source.addFeature(newFeature); + + }, refreshAnnotationSource(annotations, source) { let annotationsMap = {};