Skip to content

Commit

Permalink
Merge pull request #501 from slovensko-digital/GO-494/file-count
Browse files Browse the repository at this point in the history
Add filecount to FS list
  • Loading branch information
luciajanikova authored Nov 16, 2024
2 parents 548f0a9 + f9ec0e4 commit f22fdda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/javascript/controllers/dropzone_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default class extends Controller {
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('content[]');
const fileList = document.getElementById('fileList');
const fileCount = document.getElementById('fileCount');

dropzone.addEventListener('dragover', (e) => {
e.preventDefault();
Expand Down Expand Up @@ -38,6 +39,9 @@ export default class extends Controller {
listItem.textContent = `${file.name} (${this.formatBytes(file.size)})`;
fileList.appendChild(listItem);
}

fileCount.parentElement.classList.remove('hidden');
fileCount.textContent = `${parseInt(fileCount.textContent) + files.length}`;
}

formatBytes(bytes) {
Expand Down
4 changes: 3 additions & 1 deletion app/views/fs/message_drafts/_new_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
</label>
<p class="pl-1">alebo ich sem presuňte</p>
</div>
<div class="mt-6 text-center" id="fileList"></div>
<div class="mt-6 text-center" id="fileList">
<div class="font-semibold text-sm hidden">Počet nahratých súborov: <span id="fileCount">0</span></div>
</div>
<% end %>
</div>
</div>
Expand Down

0 comments on commit f22fdda

Please sign in to comment.