Skip to content

Commit bb7c47c

Browse files
authored
Merge pull request #317 from DigitalSlideArchive/better-annotation-update
Better update annotations when they change from external causes
2 parents 2f09259 + 96c0b81 commit bb7c47c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

histomicsui/web_client/panels/AnnotationSelector.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ var AnnotationSelector = Panel.extend({
6060
this.listenTo(this.collection, 'change:highlight', this._changeAnnotationHighlight);
6161
this.listenTo(eventStream, 'g:event.job_status', _.debounce(this._onJobUpdate, 500));
6262
this.listenTo(eventStream, 'g:eventStream.start', this._refreshAnnotations);
63+
this.listenTo(eventStream, 'g:event.large_image_annotation.create', this._refreshAnnotations);
64+
this.listenTo(eventStream, 'g:event.large_image_annotation.remove', this._refreshAnnotations);
6365
this.listenTo(this.collection, 'change:annotation change:groups', this._saveAnnotation);
6466
this.listenTo(girderEvents, 'g:login', () => {
6567
this.collection.reset();
@@ -240,6 +242,10 @@ var AnnotationSelector = Panel.extend({
240242
},
241243

242244
_refreshAnnotations() {
245+
if (this._norefresh) {
246+
delete this._norefresh;
247+
return;
248+
}
243249
if (!this.parentItem || !this.parentItem.id || !this.viewer) {
244250
return;
245251
}
@@ -290,6 +296,9 @@ var AnnotationSelector = Panel.extend({
290296
this._deselectAnnotationElements(models[id]);
291297
this.viewer.removeAnnotation(models[id]);
292298
}
299+
if (activeId === id) {
300+
this.trigger('h:deleteAnnotation', models[id]);
301+
}
293302
});
294303
return null;
295304
});
@@ -389,6 +398,7 @@ var AnnotationSelector = Panel.extend({
389398
showSaveAnnotationDialog(model, {title: 'Create annotation'}),
390399
'g:submit',
391400
() => {
401+
this._norefresh = true;
392402
model.save().done(() => {
393403
model.set('displayed', true);
394404
this.collection.add(model);

0 commit comments

Comments
 (0)