From de21811df30014b8a608a13225315abee24a7bb4 Mon Sep 17 00:00:00 2001 From: Guilherme Monteiro Date: Fri, 20 Oct 2023 17:06:32 -0300 Subject: [PATCH 1/2] Update massFileDownloader.html Just added a lightning-textarea with the URL removing the window.alert(). The previous one wasn't showing the whole URL if needed and now the URL is also getting updated according to the file selection (checkbox selection). --- .../lwc/massFileDownloader/massFileDownloader.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.html b/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.html index 251b39d..3b6cf36 100644 --- a/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.html +++ b/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.html @@ -1,9 +1,8 @@ From b40519d40c87cee6932cf1cb9f1d379bfda76c08 Mon Sep 17 00:00:00 2001 From: Guilherme Monteiro Date: Fri, 20 Oct 2023 17:09:44 -0300 Subject: [PATCH 2/2] Update massFileDownloader.js Just added a lightning-textarea with the URL removing the window.alert(). The previous one wasn't showing the whole URL if needed and now the URL is also getting updated according to the file selection (checkbox selection). On the JS, I've changed it a little bit to create a downloadString variable, as well as getters/setters to update the url dynamically. --- .../massFileDownloader/massFileDownloader.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.js b/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.js index bad218f..0e0d850 100644 --- a/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.js +++ b/Mass File Downloader/lwc/massFileDownloader/massFileDownloader.js @@ -23,6 +23,7 @@ const BASE_DOWNLOAD_PATH = '/sfc/servlet.shepherd/version/download'; export default class MassFileDownloader extends LightningElement { columns = COLUMNS; + downloadString = ''; @wire(getFiles) files; @@ -40,6 +41,11 @@ export default class MassFileDownloader extends LightningElement { ); } + handleRowSelection(event) { + let selectedFiles = event.detail.selectedRows; + this.downloadString = this.getDownloadString(selectedFiles); + } + getDownloadString(files) { let downloadString = ''; files.forEach(item => { @@ -48,12 +54,20 @@ export default class MassFileDownloader extends LightningElement { return downloadString; } - initDownloading(downloadString) { - alert(BASE_DOWNLOAD_PATH + downloadString); - //window.open(BASE_DOWNLOAD_PATH + downloadString, '_blank'); + get downloadUrl() { + return BASE_DOWNLOAD_PATH + this.downloadString; + } + + initDownloading() { + if (this.downloadString === '') { + alert('No files selected'); + return; + } + //alert(this.downloadUrl); + window.open(this.downloadUrl, '_blank'); } getSelectedRows() { return this.template.querySelector('lightning-datatable').getSelectedRows(); } -} \ No newline at end of file +}