Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix upload multiple selection display #5664

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/resources/views/crud/fields/upload_multiple.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function bpFieldInitUploadMultipleElement(element) {

fileInput.change(function() {
let selectedFiles = [];
let existingFiles = fileInput.parent().siblings('.existing-file');

Array.from($(this)[0].files).forEach(file => {
selectedFiles.push({name: file.name, type: file.type})
Expand All @@ -231,11 +232,11 @@ function bpFieldInitUploadMultipleElement(element) {
selectedFiles.forEach(file => {
files += '<span class="badge mt-1 mb-1 text-bg-secondary badge-primary">'+file.name+'</span> ';
});

// if existing files is not on the page, create a new div a prepend it to the fileInput
if(existingFiles.length === 0) {
existingFiles = $('<div class="well well-sm existing-file mb-2"></div>');
existingFiles.insertBefore(element.find('input[type=hidden]'));
existingFiles.insertBefore(element.find('input[type=hidden]').first());
existingFiles.html(files);
}else {
// if existing files is on page show the added files after the uploaded ones
Expand Down