diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/main/resources/static/js/multitool/PdfActionsManager.js b/src/main/resources/static/js/multitool/PdfActionsManager.js index 4bff39e3..3a4fd33d 100644 --- a/src/main/resources/static/js/multitool/PdfActionsManager.js +++ b/src/main/resources/static/js/multitool/PdfActionsManager.js @@ -55,6 +55,17 @@ class PdfActionsManager { deletePageButtonCallback(e) { var imgContainer = this.getPageContainer(e.target); this.pagesContainer.removeChild(imgContainer); + if (this.pagesContainer.childElementCount === 0) { + const filenameInput = document.getElementById('filename-input'); + const filenameParagraph = document.getElementById('filename'); + const downloadBtn = document.getElementById('export-button'); + + filenameInput.disabled = true; + filenameInput.value = ""; + filenameParagraph.innerText = ""; + + downloadBtn.disabled = true; + } }; insertFileButtonCallback(e) { diff --git a/src/main/resources/static/js/multitool/PdfContainer.js b/src/main/resources/static/js/multitool/PdfContainer.js index f7ffec36..570db8a5 100644 --- a/src/main/resources/static/js/multitool/PdfContainer.js +++ b/src/main/resources/static/js/multitool/PdfContainer.js @@ -34,8 +34,12 @@ class PdfContainer { window.rotateAll = this.rotateAll; const filenameInput = document.getElementById('filename-input'); + const filenameParagraph = document.getElementById('filename'); + filenameInput.onkeyup = this.updateFilename; filenameInput.disabled = true; + filenameInput.innerText = ""; + filenameParagraph.innerText = ""; } movePageTo(startElement, endElement, scrollTo = false) { @@ -70,8 +74,17 @@ class PdfContainer { const files = e.target.files; if (files.length > 0) { const filenameInput = document.getElementById('filename-input'); + const pagesContainer = document.getElementById('pages-container'); + const downloadBtn = document.getElementById('export-button'); + filenameInput.disabled = false; + downloadBtn.disabled = false; + + if (pagesContainer.childElementCount === 0) { + filenameInput.value = ""; + } } + this.addPdfsFromFiles(files, nextSiblingElement); } @@ -228,16 +241,15 @@ class PdfContainer { setDownloadAttribute() { console.log('inside setDownloadAttribute ' + this.filename); - this.downloadLink.setAttribute("download", this.filename); + this.downloadLink.setAttribute("download", this.filename ? this.filename : 'managed.pdf'); } updateFilename() { const filenameInput = document.getElementById('filename-input'); const filenameParagraph = document.getElementById('filename'); - console.log('updatedFilename fired ' + filenameInput.value); this.filename = filenameInput.value; - filenameParagraph.innerText = this.filename; + filenameParagraph.innerText = this.filename + ".pdf"; } } diff --git a/src/main/resources/templates/multi-tool.html b/src/main/resources/templates/multi-tool.html index 4266a795..2df41c0a 100644 --- a/src/main/resources/templates/multi-tool.html +++ b/src/main/resources/templates/multi-tool.html @@ -23,7 +23,7 @@