From 2c3e148b0029a094431622feac79fafcd0d43fc8 Mon Sep 17 00:00:00 2001 From: adev Date: Sun, 7 May 2017 17:21:30 +0200 Subject: Displays an error with an annotation with a too long quote Fix #2762 --- app/Resources/static/themes/_global/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'app/Resources/static/themes') diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 3fdcaa3d..3ec26488 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js @@ -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 }); -- cgit v1.2.3