Merge pull request #3093 from aaa2000/annotation-error-on-save

Displays an error with an annotation with a too long quote
This commit is contained in:
Nicolas Lœuillet
2017-06-07 16:30:27 +02:00
committed by GitHub
23 changed files with 272 additions and 28 deletions

View File

@ -34,7 +34,21 @@ $(document).ready(() => {
app.registry.registerUtility(authorization, 'authorizationPolicy');
const x = JSON.parse($('#annotationroutes').html());
app.include(annotator.storage.http, x);
app.include(annotator.storage.http, $.extend({}, x, {
onError(msg, xhr) {
if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) {
annotator.notification.banner('An error occurred', 'error');
return;
}
$.each(xhr.responseJSON.children, (k, v) => {
if (v.errors) {
$.each(v.errors, (n, errorText) => {
annotator.notification.banner(errorText, 'error');
});
}
});
},
}));
app.start().then(() => {
app.annotations.load({ entry: x.entryId });