]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/_global/index.js
Displays an error with an annotation with a too long quote
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / index.js
index 00410754a244209c8b07bfa3dabb4152825626a2..3ec26488272b5da2fe2aa61a0d0203b66fd1ca3f 100644 (file)
@@ -28,8 +28,27 @@ $(document).ready(() => {
       element: document.querySelector('article'),
     });
 
+    const authorization = {
+      permits() { return true; },
+    };
+    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 });