diff options
Diffstat (limited to 'assets/common/js/shaare-batch.js')
-rw-r--r-- | assets/common/js/shaare-batch.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/assets/common/js/shaare-batch.js b/assets/common/js/shaare-batch.js index 9f612993..557325ee 100644 --- a/assets/common/js/shaare-batch.js +++ b/assets/common/js/shaare-batch.js | |||
@@ -15,7 +15,7 @@ const sendBookmarkForm = (basePath, formElement) => { | |||
15 | alert(`An error occurred. Return code: ${xhr.status}`); | 15 | alert(`An error occurred. Return code: ${xhr.status}`); |
16 | reject(); | 16 | reject(); |
17 | } else { | 17 | } else { |
18 | formElement.remove(); | 18 | formElement.closest('.edit-link-container').remove(); |
19 | resolve(); | 19 | resolve(); |
20 | } | 20 | } |
21 | }; | 21 | }; |
@@ -32,7 +32,7 @@ const sendBookmarkDelete = (buttonElement, formElement) => ( | |||
32 | alert(`An error occurred. Return code: ${xhr.status}`); | 32 | alert(`An error occurred. Return code: ${xhr.status}`); |
33 | reject(); | 33 | reject(); |
34 | } else { | 34 | } else { |
35 | formElement.remove(); | 35 | formElement.closest('.edit-link-container').remove(); |
36 | resolve(); | 36 | resolve(); |
37 | } | 37 | } |
38 | }; | 38 | }; |
@@ -80,9 +80,23 @@ const redirectIfEmptyBatch = (basePath, formElements, path) => { | |||
80 | saveAllButton.addEventListener('click', (e) => { | 80 | saveAllButton.addEventListener('click', (e) => { |
81 | e.preventDefault(); | 81 | e.preventDefault(); |
82 | 82 | ||
83 | const forms = [...getForms()]; | ||
84 | const nbForm = forms.length; | ||
85 | let current = 0; | ||
86 | const progressBar = document.querySelector('.progressbar > div'); | ||
87 | const progressBarCurrent = document.querySelector('.progressbar-current'); | ||
88 | |||
89 | document.querySelector('.dark-layer').style.display = 'block'; | ||
90 | document.querySelector('.progressbar-max').innerHTML = nbForm; | ||
91 | progressBarCurrent.innerHTML = current; | ||
92 | |||
83 | const promises = []; | 93 | const promises = []; |
84 | [...getForms()].forEach((formElement) => { | 94 | forms.forEach((formElement) => { |
85 | promises.push(sendBookmarkForm(basePath, formElement)); | 95 | promises.push(sendBookmarkForm(basePath, formElement).then(() => { |
96 | current += 1; | ||
97 | progressBar.style.width = `${(current * 100) / nbForm}%`; | ||
98 | progressBarCurrent.innerHTML = current; | ||
99 | })); | ||
86 | }); | 100 | }); |
87 | 101 | ||
88 | Promise.all(promises).then(() => { | 102 | Promise.all(promises).then(() => { |