From 5c13aa1bd1db32c8372e93fe876daf7f3fc1f815 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Fri, 4 Aug 2017 09:21:45 +0200 Subject: [PATCH] Clear errors when new file is uploaded (#34) --- buckets/__init__.py | 2 +- buckets/static/buckets/js/script.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/buckets/__init__.py b/buckets/__init__.py index dccb61c0a6..872472ae26 100644 --- a/buckets/__init__.py +++ b/buckets/__init__.py @@ -1 +1 @@ -__version__ = '0.1.21' +__version__ = '0.1.22' diff --git a/buckets/static/buckets/js/script.js b/buckets/static/buckets/js/script.js index da11e5047f..427dc1460e 100644 --- a/buckets/static/buckets/js/script.js +++ b/buckets/static/buckets/js/script.js @@ -38,12 +38,16 @@ } } + function clearErrors(el) { + if (errs = el.querySelector('.errors')) { errs.remove(); } + } + function error(el, msg) { message(el); el.querySelector('.file-url').value = ''; el.querySelector('.file-input').value = ''; - if (errs = el.querySelector('.errors')) { errs.remove(); } + clearErrors(el); var errorList = document.createElement('ul'); errorList.setAttribute('class', 'errors'); @@ -58,7 +62,7 @@ var link = el.querySelector('.file-link'), url = el.querySelector('.file-url'); - if (errs = el.querySelector('.errors')) { errs.remove(); } + clearErrors(el); url.value = fileUrl; link.href = fileUrl; @@ -155,6 +159,8 @@ file = el.querySelector('.file-input').files[0], accepted = el.getAttribute('data-accepted-types'); + clearErrors(el); + disableSubmit(el, true); var ext = file.name.split('.').slice(-1)[0]; var type = file.type || MIME_LOOKUPS[ext];