diff --git a/app/assets/javascripts/revs.js b/app/assets/javascripts/revs.js.erb similarity index 97% rename from app/assets/javascripts/revs.js rename to app/assets/javascripts/revs.js.erb index 23b703d0..1de2c622 100644 --- a/app/assets/javascripts/revs.js +++ b/app/assets/javascripts/revs.js.erb @@ -501,6 +501,13 @@ function ajax_loading_done(element) { } } +// if there are any ajax errors (e.g. 500 or timeout on the server), show a generic error message so the user +// knows something bad happened, e.g. when a curator is editing metadata, they submit ajax forms +$(document).ajaxError(function myErrorHandler(event, xhr, ajaxOptions, thrownError) { + $('#main-flashes').html('
x<%=I18n.t('revs.errors.unexpected')%>
'); + window.scrollTo(0,0); +}); + // if the user clicks cancel on a confirm box, we need to hide the ajax loader $(document).on('confirm:complete', function(e,answer) { element=$(e.target); diff --git a/config/locales/en.yml b/config/locales/en.yml index fb967228..409fa9ed 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -50,7 +50,7 @@ en: action_browse_collections_linktext: 'Revs collections' tell_us_html: '%{href} what you were looking for' tell_us_linktext: 'Tell us' - unexpected: "Oops! An unexpected error has occurred." + unexpected: "An unexpected error has occurred. If you have made changes, they might not have been saved." 500_message: "We apologize for the inconvenience. The error has been logged and we have notified system administrators. Until we fix the problem, here are some things you can do:" actions: delete: 'Delete'