From 6d6f1148e218565bd71f8132048120887ef4df13 Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Thu, 28 Mar 2024 10:10:28 -0400 Subject: [PATCH 1/6] [publication] Fix number of files in Upload tab --- modules/publication/jsx/uploadForm.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/publication/jsx/uploadForm.js b/modules/publication/jsx/uploadForm.js index ebb28285006..f493e937bc4 100644 --- a/modules/publication/jsx/uploadForm.js +++ b/modules/publication/jsx/uploadForm.js @@ -83,9 +83,17 @@ class PublicationUploadForm extends React.Component { */ setFileData(formElement, value) { let numFiles = this.state.numFiles; - if (!this.state.formData[formElement]) { - numFiles += 1; - this.setState({numFiles: numFiles}); + if (value) { + if (!this.state.formData[formElement]) { + numFiles += 1; + this.setState({numFiles: numFiles}); + } + } else { + // File is being removed + if (this.state.formData[formElement]) { + numFiles -= 1; + this.setState({ numFiles: numFiles }); + } } this.setFormData(formElement, value); } From 9a1919110f3631a0e3e441b28380de7eb801d2cb Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Thu, 28 Mar 2024 10:17:50 -0400 Subject: [PATCH 2/6] Documentation modifications --- CHANGELOG.md | 1 + modules/publication/test/TestPlan.md | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91346b860b7..e26f19f5410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ changes in the following format: PR #1234*** - Fix examiner site display (PR #8967) - bvl_feedback updates in real-time (PR #8966) - DoB and DoD format respected in candidate parameters (PR #9001) +- Prevent indefinate "File to upload" fields from being added if files are browsed then cancelled (PR #9179) ## LORIS 25.0 (Release Date: ????-??-??) ### Core diff --git a/modules/publication/test/TestPlan.md b/modules/publication/test/TestPlan.md index 5441e5a4231..07d212e589e 100644 --- a/modules/publication/test/TestPlan.md +++ b/modules/publication/test/TestPlan.md @@ -15,6 +15,9 @@ and ensure that the project proposal page is now accessible. 5. Fill out all the fields in the form and try to submit. Make sure you have a corresponding directory to the directory specified in Config if you are attempting a file upload. Try submitting without filling in required fields. +6. Try adding a file to upload, and then adding another file to upload. Next, +select browse in the second file that was uploaded, but cancel the file. The +file should be removed, and no extra "File to upload" fields should be added. 6. Login under one of the accounts you specified under the "Users with Edit Permission" and access the project page and make edits to the proposal. From 13fda0f51f5c816f2dc9194327e12810568f6d47 Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Thu, 28 Mar 2024 11:04:21 -0400 Subject: [PATCH 3/6] fix test suite --- modules/publication/jsx/uploadForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/publication/jsx/uploadForm.js b/modules/publication/jsx/uploadForm.js index f493e937bc4..17a4a1184b8 100644 --- a/modules/publication/jsx/uploadForm.js +++ b/modules/publication/jsx/uploadForm.js @@ -92,7 +92,7 @@ class PublicationUploadForm extends React.Component { // File is being removed if (this.state.formData[formElement]) { numFiles -= 1; - this.setState({ numFiles: numFiles }); + this.setState({numFiles: numFiles}); } } this.setFormData(formElement, value); From 13168f89909bc8b9bf9333108fc4073a23d452d2 Mon Sep 17 00:00:00 2001 From: CamilleBeau <51176779+CamilleBeau@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:49:22 -0400 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e26f19f5410..614801214c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ changes in the following format: PR #1234*** - Fix examiner site display (PR #8967) - bvl_feedback updates in real-time (PR #8966) - DoB and DoD format respected in candidate parameters (PR #9001) -- Prevent indefinate "File to upload" fields from being added if files are browsed then cancelled (PR #9179) +- While proposing a project or editing a project in publications module, prevent indefinate "File to upload" fields from being added if files are browsed then cancelled (PR #9179) ## LORIS 25.0 (Release Date: ????-??-??) ### Core From 81d252468765b930a3684731afbdeaae1500e0cf Mon Sep 17 00:00:00 2001 From: CamilleBeau <51176779+CamilleBeau@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:49:58 -0400 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 614801214c0..5480471ae75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ changes in the following format: PR #1234*** - Fix examiner site display (PR #8967) - bvl_feedback updates in real-time (PR #8966) - DoB and DoD format respected in candidate parameters (PR #9001) -- While proposing a project or editing a project in publications module, prevent indefinate "File to upload" fields from being added if files are browsed then cancelled (PR #9179) +- While proposing a project or editing a project in publications module, prevent indefinite "File to upload" fields from being added if files are browsed then cancelled (PR #9179) ## LORIS 25.0 (Release Date: ????-??-??) ### Core From b28bcda768f166a97f7348b8310f07dba279583d Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Thu, 11 Apr 2024 11:25:44 -0400 Subject: [PATCH 6/6] Add to viewProject.js --- modules/publication/jsx/viewProject.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/publication/jsx/viewProject.js b/modules/publication/jsx/viewProject.js index b479ba224f9..6f49f0ffd6c 100644 --- a/modules/publication/jsx/viewProject.js +++ b/modules/publication/jsx/viewProject.js @@ -436,9 +436,17 @@ class ViewProject extends React.Component { */ setFileData(formElement, value) { let numFiles = this.state.numFiles; - if (!this.state.formData[formElement]) { - numFiles += 1; - this.setState({numFiles: numFiles}); + if (value) { + if (!this.state.formData[formElement]) { + numFiles += 1; + this.setState({numFiles: numFiles}); + } + } else { + // File is being removed + if (this.state.formData[formElement]) { + numFiles -= 1; + this.setState({numFiles: numFiles}); + } } this.setFormData(formElement, value); }