From a766cac7f07d0bf3ad4c94407cb1a06828cddef6 Mon Sep 17 00:00:00 2001 From: Garren Smith Date: Thu, 19 Sep 2013 16:47:31 +0200 Subject: show upload errors --- src/fauxton/app/modules/documents/views.js | 9 ++++++--- src/fauxton/app/templates/documents/upload_modal.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js index de1938633..c70e94e19 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -147,6 +147,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re event.preventDefault(); var docRev = this.model.get('_rev'), + that = this, $form = this.$('#file-upload'); if (!docRev) { @@ -165,21 +166,23 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re beforeSend: this.beforeSend, uploadProgress: this.uploadProgress, success: this.success, - error: function () { - console.log('ERR on upload', arguments); + error: function (resp) { + console.log('ERR on upload', resp); + return that.set_error_msg('Could not upload document: ' + JSON.parse(resp.responseText).reason); } }); }, success: function (resp) { var hideModal = this.hideModal, - $form = this.$('#file-upload'); + $form = this.$('#file-upload'); FauxtonAPI.triggerRouteEvent('reRenderDoc'); //slight delay to make this transistion a little more fluid and less jumpy setTimeout(function () { $form.clearForm(); hideModal(); + $('.modal-backdrop').remove(); }, 1000); }, diff --git a/src/fauxton/app/templates/documents/upload_modal.html b/src/fauxton/app/templates/documents/upload_modal.html index 08a14a6b5..33c28617e 100644 --- a/src/fauxton/app/templates/documents/upload_modal.html +++ b/src/fauxton/app/templates/documents/upload_modal.html @@ -18,7 +18,7 @@ the License.

Upload an Attachment