From 09a03ab2c5d78f105ebec5418a2c174984a55f1e Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Tue, 29 Oct 2024 12:11:13 -0400 Subject: [PATCH 1/7] SAK-40229 Content screen reader announcing file upload to dropbox --- .../sakai_dropbox_multiple_folders_upload.vm | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index 3fbfd9053903..5dfc74b3beb7 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -25,6 +25,7 @@ #end +
@@ -229,4 +230,25 @@ #end } + function handleFileChange() + { + const input = document.getElementById('MultipleFolderContent'); + const feedback = document.getElementById('fileUploadFeedback'); + + if (input.files.length > 0) + { + const fileName = input.files[0].name; + feedback.textContent = `Successfully uploaded: ${fileName}`; + feedback.style.display = 'block'; + + setTimeout(() => { + feedback.style.display = 'none'; + }, 10000); + } + else + { + feedback.textContent = 'No file selected.'; + feedback.style.display = 'block'; + } + } From 0e778b0b39054505b4cdbb9c8303a2397bd1871c Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Wed, 30 Oct 2024 15:02:14 -0400 Subject: [PATCH 2/7] SAK-40229 Content screen reader announcing file upload to dropbox --- content/content-bundles/resources/types.properties | 1 + .../resources/sakai_dropbox_multiple_folders_upload.vm | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/content/content-bundles/resources/types.properties b/content/content-bundles/resources/types.properties index 5c41b45c4a7b..002643a2c417 100644 --- a/content/content-bundles/resources/types.properties +++ b/content/content-bundles/resources/types.properties @@ -233,6 +233,7 @@ processmessage.save.html=Saving HTML page processmessage.save.text=Saving text document processmessage.save.file=Saving new file(s) processmessage.save.url=Saving link(s) +label.success = Successfully uploaded: {0} label.time = Time: label.update = Update label.upl = Upload New Version Now diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index 5dfc74b3beb7..bd55a8ed3ff5 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -25,7 +25,9 @@ #end - +
@@ -238,16 +240,16 @@ if (input.files.length > 0) { const fileName = input.files[0].name; - feedback.textContent = `Successfully uploaded: ${fileName}`; + const successTemplate = feedback.textContent; + feedback.textContent = successTemplate.replace("{0}", fileName); feedback.style.display = 'block'; setTimeout(() => { - feedback.style.display = 'none'; + feedback.style.display = 'none'; }, 10000); } else { - feedback.textContent = 'No file selected.'; feedback.style.display = 'block'; } } From c6b6c38b3cfc2bb087fcba50895abd73bcc22439 Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Mon, 4 Nov 2024 11:19:44 -0500 Subject: [PATCH 3/7] SAK-40229 Content screen reader announcing file upload to dropbox --- .../sakai_dropbox_multiple_folders_upload.vm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index bd55a8ed3ff5..2a0eecbd5258 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -25,7 +25,7 @@ #end - @@ -240,17 +240,20 @@ if (input.files.length > 0) { const fileName = input.files[0].name; - const successTemplate = feedback.textContent; - feedback.textContent = successTemplate.replace("{0}", fileName); - feedback.style.display = 'block'; + const successTemplate = `$tlang.getString('label.success')`.replace("{0}", fileName); + feedback.textContent = successTemplate; + feedback.classList.remove('d-none'); + feedback.classList.add('d-block'); setTimeout(() => { - feedback.style.display = 'none'; + feedback.classList.remove('d-block'); + feedback.classList.add('d-none'); }, 10000); } else { - feedback.style.display = 'block'; + feedback.classList.remove('d-none'); + feedback.classList.add('d-block'); } } From 7d39772f2ff5a2bb0641b61275fc381247bc7762 Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Mon, 4 Nov 2024 14:21:46 -0500 Subject: [PATCH 4/7] SAK-40229 Content screen reader announcing file upload to dropbox --- .../vm/resources/sakai_dropbox_multiple_folders_upload.vm | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index 2a0eecbd5258..ceeb5a3cc69b 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -246,14 +246,12 @@ feedback.classList.add('d-block'); setTimeout(() => { - feedback.classList.remove('d-block'); feedback.classList.add('d-none'); }, 10000); } else { feedback.classList.remove('d-none'); - feedback.classList.add('d-block'); } } From 4aa2e4bd72a3c8995cdc1f69ed69e2ca9624accd Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Wed, 6 Nov 2024 21:08:57 -0500 Subject: [PATCH 5/7] Content screen reader announcing file upload to dropbox --- .../sakai_dropbox_multiple_folders_upload.vm | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index ceeb5a3cc69b..bdf3801b4a26 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -189,6 +189,21 @@ { const fileField = document.getElementById('MultipleFolderContent'); const nameField = document.getElementById('MultipleFolderDisplayName'); + const feedback = document.getElementById('fileUploadFeedback'); + + if (fileField.files.length > 0) + { + const fileName = fileField.files[0].name; + const successTemplate = `$tlang.getString('label.success')`.replace("{0}", fileName); + feedback.textContent = successTemplate; + feedback.classList.remove('d-none'); + } + else + { + feedback.classList.add('d-none'); + nameField.value = ''; + } + ## Goal: update the display name field. But if the user provided their own display name, don't overwrite it @@ -232,26 +247,4 @@ #end } - function handleFileChange() - { - const input = document.getElementById('MultipleFolderContent'); - const feedback = document.getElementById('fileUploadFeedback'); - - if (input.files.length > 0) - { - const fileName = input.files[0].name; - const successTemplate = `$tlang.getString('label.success')`.replace("{0}", fileName); - feedback.textContent = successTemplate; - feedback.classList.remove('d-none'); - feedback.classList.add('d-block'); - - setTimeout(() => { - feedback.classList.add('d-none'); - }, 10000); - } - else - { - feedback.classList.remove('d-none'); - } - } From 944efc49b49dae239733722fb0fcad952adbd0da Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Sat, 9 Nov 2024 11:24:46 -0500 Subject: [PATCH 6/7] SAK-40229 Content screen reader announcing file upload to dropbox --- .../vm/resources/sakai_dropbox_multiple_folders_upload.vm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index bdf3801b4a26..b9e039df179f 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -193,9 +193,7 @@ if (fileField.files.length > 0) { - const fileName = fileField.files[0].name; - const successTemplate = `$tlang.getString('label.success')`.replace("{0}", fileName); - feedback.textContent = successTemplate; + feedback.textContent = `$tlang.getString('label.success')`.replace("{0}", fileField.files[0].name); feedback.classList.remove('d-none'); } else From 017d8349e80508154ba78fbd43914139d0f0e74d Mon Sep 17 00:00:00 2001 From: Sharadhi Date: Fri, 22 Nov 2024 12:08:50 -0500 Subject: [PATCH 7/7] SAK-40229 Content screen reader announcing file upload to dropbox --- .../sakai_dropbox_multiple_folders_upload.vm | 85 ++++++++++--------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm index b9e039df179f..5597bf192b4e 100644 --- a/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm +++ b/content/content-tool/tool/src/webapp/vm/resources/sakai_dropbox_multiple_folders_upload.vm @@ -195,6 +195,49 @@ { feedback.textContent = `$tlang.getString('label.success')`.replace("{0}", fileField.files[0].name); feedback.classList.remove('d-none'); + + ## Goal: update the display name field. But if the user provided their own display name, don't overwrite it + + #if ($!alreadyUploadedFile) + ## A file was uploaded to the server, and there was a validation error; track if the file name matches the serverside file + let matchesPreviousFile = nameField.value.trim() == "$validator.escapeHtml("$alreadyUploadedFile.getFileName()")".trim(); + + #else + ## A file was not yet uploaded to the server + let matchesPreviousFile = false; + #end + + ## Compare with the name of the last selected file in the file picker + matchesPreviousFile = matchesPreviousFile || nameField.value.trim() == previousFileName.trim(); + if (nameField.value == null || nameField.value.trim() == '' || matchesPreviousFile) + { + ## User hasn't changed the display name; overwrite it + nameField.value = fileField.files[0].name; + } + previousFileName = fileField.files[0].name; + + #* + * Goal: validate the filesize. + * Note: the server doesn't accept files slightly under uploadMaxSize (default 20 MB), and the user's request is rejected. + * I suspect that validation occurs on the entire http post, and I'm unsure how to address this, but this validation is useful for most cases. + *# + #if ($!uploadMaxSize) + const maxFileSize = $!uploadMaxSize * 1024 * 1024; + const resourceAlert = document.getElementById('resourceAlert'); + const submitButton = document.getElementById('saveChanges'); + if (fileField.files[0].size > maxFileSize) + { + resourceAlert.innerText = "$tlang.getFormattedMessage('size.exceeded', $!uploadMaxSize)"; + resourceAlert.classList.remove('d-none'); + submitButton.disabled = true; + } + else + { + resourceAlert.classList.add('d-none'); + resourceAlert.innerText = ''; + submitButton.disabled = false; + } + #end } else { @@ -202,47 +245,5 @@ nameField.value = ''; } - - ## Goal: update the display name field. But if the user provided their own display name, don't overwrite it - -#if ($!alreadyUploadedFile) - ## A file was uploaded to the server, and there was a validation error; track if the file name matches the serverside file - let matchesPreviousFile = nameField.value.trim() == "$validator.escapeHtml("$alreadyUploadedFile.getFileName()")".trim(); -#else - ## A file was not yet uploaded to the server - let matchesPreviousFile = false; -#end - ## Compare with the name of the last selected file in the file picker - matchesPreviousFile = matchesPreviousFile || nameField.value.trim() == previousFileName.trim(); - if (nameField.value == null || nameField.value.trim() == '' || matchesPreviousFile) - { - ## User hasn't changed the display name; overwrite it - nameField.value = fileField.files[0].name; - } - previousFileName = fileField.files[0].name; - - #* - * Goal: validate the filesize. - * Note: the server doesn't accept files slightly under uploadMaxSize (default 20 MB), and the user's request is rejected. - * I suspect that validation occurs on the entire http post, and I'm unsure how to address this, but this validation is useful for most cases. - *# - #if ($!uploadMaxSize) - const maxFileSize = $!uploadMaxSize * 1024 * 1024; - const resourceAlert = document.getElementById('resourceAlert'); - const submitButton = document.getElementById('saveChanges'); - if (fileField.files[0].size > maxFileSize) - { - resourceAlert.innerText = "$tlang.getFormattedMessage('size.exceeded', $!uploadMaxSize)"; - resourceAlert.classList.remove('d-none'); - submitButton.disabled = true; - } - else - { - resourceAlert.classList.add('d-none'); - resourceAlert.innerText = ''; - submitButton.disabled = false; - } - #end - }