From c717407470fbb85f1616b5af67f4daa9d93b9bb3 Mon Sep 17 00:00:00 2001
From: Chris Lawton <chris.lawton@torchbox.com>
Date: Fri, 23 Feb 2018 14:49:13 +0000
Subject: [PATCH] remove existing listed files from file upload

---
 opentech/static_src/src/javascript/main.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/opentech/static_src/src/javascript/main.js b/opentech/static_src/src/javascript/main.js
index 6ce41abd7..86d1def8a 100755
--- a/opentech/static_src/src/javascript/main.js
+++ b/opentech/static_src/src/javascript/main.js
@@ -21,9 +21,11 @@ $(function () {
 
     // Show list of selected files for upload on input[type=file]
     $('input[type=file]').change(function() {
+        // remove any existing files first
+        $(this).siblings('.form__file').remove();
         for (let i = 0; i < $(this)[0].files.length; ++i) {
             $(this).parents('.form__item').prepend(`
-                <p>${$(this)[0].files[i].name}</p>
+                <p class="form__file">${$(this)[0].files[i].name}</p>
             `);
         }
     });
-- 
GitLab