Skip to content

Commit

Permalink
feat: add multi file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaharrisdwp committed Nov 18, 2024
1 parent 95a73b7 commit ff9e234
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 43 deletions.
29 changes: 7 additions & 22 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2559,9 +2559,6 @@ router.all(
}
);




// e6

// var filenames = [];
Expand Down Expand Up @@ -2646,27 +2643,15 @@ router.post("/round-9/e6/upload-evidence-type", function (req, res) {
});

router.post("/round-9/e6/upload-evidence-form", function (req, res) {
var fileName = req.session.data["file-upload"].replaceAll(" ", "");
// filenames.push(fileName);
// req.session.data.benefitsArray = filenames;

// const index = benefits.findIndex(
// (benefit) => benefit.name === req.session.data["yourBenefits"]
// );
// benefits[index].files.push(fileName);

// currentFiles.push(fileName);
// req.session.data.currentFiles = currentFiles;

// console.log(benefits);

// req.session.data.benefits = benefits;

// console.log(JSON.stringify(req.session.data.benefits));

console.log("hello + " + JSON.stringify(req.session.data));

req.session.data.benefits[0].files.push(fileName);
if (Array.isArray(req.session.data["file-upload"])) {
req.session.data["file-upload"].forEach((file) => {
req.session.data.benefits[0].files.push(file);
});
} else {
req.session.data.benefits[0].files.push(req.session.data["file-upload"]);
}

res.redirect("/round-9/e6/file-check");
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/round-9/e6/are-you-sure.njk
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}
}
if (!hasSelection) {
window.location.href = "/round-8/e5/error/are-you-sure";
window.location.href = "/round-9/e6/error/are-you-sure";
} else {
if (document.getElementById("yes").checked) {
window.location.href = "upload-table?file={{ fileToDelete }}"
Expand Down
2 changes: 1 addition & 1 deletion app/views/round-9/e6/declaration.njk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="govuk-button-group">
{{ govukButton({
text: "I agree - send evidence",
href: "/round-8/e5/sending-data",
href: "/round-9/e6/sending-data",
preventDoubleClick: true
}) }}

Expand Down
4 changes: 2 additions & 2 deletions app/views/round-9/e6/file-check.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<div class="hods-loading-spinner">
<h1 class="govuk-heading-m" style="text-align: center; margin-bottom: 30px">
Checking your file
Checking your file(s)
</h1>
<div
class="hods-loading-spinner__spinner"
Expand All @@ -39,7 +39,7 @@

<script>
setTimeout(() => {
window.location.href="/round-8/e5/upload-table"
window.location.href="/round-9/e6/upload-table"
}, 3000)
</script>

Expand Down
2 changes: 1 addition & 1 deletion app/views/round-9/e6/sending-data.njk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<script>
setTimeout(() => {
window.location.href="/round-8/e5/confirmation"
window.location.href="/round-9/e6/confirmation"
}, 3000)
</script>

Expand Down
13 changes: 6 additions & 7 deletions app/views/round-9/e6/upload-another-page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@


<div class="govuk-form-group">
<label class="govuk-label" for="file-upload"> Upload a file </label>
<input
class="govuk-file-upload"
id="file-upload"
name="file-upload"
type="file"
/>
<label class="govuk-label govuk-label--m" for="file-upload">
Upload file(s)
</label>

<input class="govuk-file-upload moj-multi-file-upload__input" id="file-upload" name="file-upload" type="file" multiple="">

</div>

</fieldset>
Expand Down
14 changes: 6 additions & 8 deletions app/views/round-9/e6/upload-evidence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@
<div class="govuk-!-padding-bottom-2"></div>

<div class="govuk-form-group">
<label class="govuk-label" for="file-upload"> Upload a file </label>
<input
class="govuk-file-upload"
id="file-upload"
name="file-upload"
type="file"
/>
</div>
<label class="govuk-label govuk-label--m" for="file-upload">
Upload file(s)
</label>

<input class="govuk-file-upload moj-multi-file-upload__input" id="file-upload" name="file-upload" type="file" multiple="">

</div>

</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion app/views/round-9/e6/upload-table.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</dd>
<dd class="govuk-summary-list__actions">

<a class="govuk-link" href="/round-8/e5/are-you-sure?file={{ loop.index }}" name="file-to-delete">Remove</a>
<a class="govuk-link" href="/round-9/e6/are-you-sure?file={{ loop.index }}" name="file-to-delete">Remove</a>

</dd>
</div>
Expand Down

0 comments on commit ff9e234

Please sign in to comment.