Open prioux opened 1 year ago
more like not user-friendly than totally bad.
The message is created by the Generic AJAX error handler line 28 cbrain.js.
Click on Upload creates a json request rather than redirect in controller, then json response intercepted by 'generic ajax error handler' at line 28 of cbrain.js
Adding JSON response handler, which checks for notices could help (currently only XML content is addressed, though I thought we seldom use XML). It might though create error message duplication . May be ignoring json error responses with notices better, not sure.
I meant something akin
--- a/BrainPortal/public/javascripts/cbrain.js
+++ b/BrainPortal/public/javascripts/cbrain.js
@@ -28,10 +28,10 @@
/* Generic AJAX error handler */
$(document).ajaxError(function (event, xhr, settings, error) {
var flash = $('.flash_error'),
- xml = $(xhr.responseXML);
-
+ xml = $(xhr.responseXML),
+ rjson = xhr.responseJSON;
if (xhr.status === 0) return true;
if (!flash.length)
flash = $('<div class="flash_error">')
.prependTo('#main');
@@ -44,6 +44,8 @@
.get()
.join('<br />')
);
+ else if (rjson && rjson.notice && rjson.notice)
+ flash.html(rjson.notice)
else
flash.html(
'Error sending background request: <br />' +
If you have a solution, make a PR...
When trying to upload a file that already exists, users get to see the message "422 Unprocessable entity"; that show up until a new page is loaded and THEN the proper message "name has already been taken" is shown.