Skip to content

Commit

Permalink
Merge pull request #1269 from ProjectMirador/2.1.3-patch
Browse files Browse the repository at this point in the history
account for array of annotations, rather than a single one
  • Loading branch information
aeschylus committed Feb 21, 2017
2 parents 993b08e + 06d74ed commit f9d4d7d
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions js/src/annotations/catchEndpoint.js
Expand Up @@ -137,30 +137,33 @@
},

update: function(oaAnnotation, successCallback, errorCallback) {
var annotation = this.getAnnotationInEndpoint(oaAnnotation),
_this = this,
annotationID = annotation.id;
var annotations = this.getAnnotationInEndpoint(oaAnnotation),
_this = this;

jQuery.ajax({
url: this.prefix+"/update/"+annotationID + this.params,
type: 'POST',
dataType: 'json',
headers: {
"x-annotator-auth-token": this.token
},
data: JSON.stringify(annotation),
contentType: "application/json; charset=utf-8",
success: function(data) {
if (typeof successCallback === "function") {
successCallback(_this.getAnnotationInOA(data));
}
_this.eventEmitter.publish('catchAnnotationUpdated.'+_this.windowID, annotation);
},
error: function() {
if (typeof errorCallback === "function") {
errorCallback();
annotations.forEach(function(annotation) {
var annotationID = annotation.id;

jQuery.ajax({
url: _this.prefix+"/update/"+annotationID + _this.params,
type: 'POST',
dataType: 'json',
headers: {
"x-annotator-auth-token": _this.token
},
data: JSON.stringify(annotation),
contentType: "application/json; charset=utf-8",
success: function(data) {
if (typeof successCallback === "function") {
successCallback(_this.getAnnotationInOA(data));
}
_this.eventEmitter.publish('catchAnnotationUpdated.'+_this.windowID, annotation);
},
error: function() {
if (typeof errorCallback === "function") {
errorCallback();
}
}
}
});
});
},

Expand Down

0 comments on commit f9d4d7d

Please sign in to comment.