Skip to content

Commit

Permalink
Fix: Conditional Attribute Binding for the multiple Attribute in the …
Browse files Browse the repository at this point in the history
…File Selector Fragment (#1665)
  • Loading branch information
Ludy87 authored Aug 12, 2024
1 parent 68c3870 commit f176558
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/resources/templates/fragments/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@

// Find the file input within the form
var fileInput = $('input[type="file"]');

// Find the closest enclosing form of the file input
var form = fileInput.closest('form');

// Find the submit button within the form
var submitButton = form.find('button[type="submit"], input[type="submit"]');

const boredWaitingText = /*[[#{bored}]]*/ 'Bored Waiting?';
const downloadCompleteText = /*[[#{downloadComplete}]]*/ 'Download Complete';
window.downloadCompleteText = downloadCompleteText;
// Create the 'show-game-btn' button
var gameButton = $('<button type="button" class="btn btn-primary" id="show-game-btn" style="display:none;">' + boredWaitingText + '</button><br><br>');

// Insert the 'show-game-btn' just above the submit button
submitButton.before(gameButton);

Expand Down Expand Up @@ -147,14 +147,14 @@
<th:block th:fragment="fileSelector(name, multiple)" th:with="accept=${accept} ?: '*/*', inputText=${inputText} ?: #{pdfPrompt}, remoteCall=${remoteCall} ?: true, notRequired=${notRequired} ?: false">
<script th:inline="javascript">
const pdfPasswordPrompt = /*[[#{error.pdfPassword}]]*/ '';
const multiple = [[${multiple}]] || false;
const remoteCall = [[${remoteCall}]] || true;
const multiple = /*[[${multiple}]]*/ false;
const remoteCall = /*[[${remoteCall}]]*/ true;
</script>
<script th:src="@{'/js/downloader.js'}"></script>

<div class="custom-file-chooser" th:attr="data-bs-unique-id=${name}, data-bs-element-id=${name+'-input'}, data-bs-files-selected=#{filesSelected}, data-bs-pdf-prompt=#{pdfPrompt}">
<div class="mb-3">
<input type="file" class="form-control" th:name="${name}" th:id="${name}+'-input'" th:accept="${accept}" multiple th:required="${notRequired} ? null : 'required'">
<input type="file" class="form-control" th:name="${name}" th:id="${name}+'-input'" th:accept="${accept}" th:attr="multiple=${multiple}" th:required="${notRequired} ? null : 'required'">
</div>
<div class="selected-files"></div>
</div>
Expand Down

0 comments on commit f176558

Please sign in to comment.