generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This exposes the functionality of ImportTransactions via a file upload that accepts CSV. The CSV is parsed in the controller and the resulting rows fed into the importer, which itself is thoroughly unit-tested. If any errors occur, then no transactions are imported, and the errors are displayed to the user. If all the rows are valid, then the transactions are saved and a success message is displayed.
- Loading branch information
James Coglan
committed
Sep 17, 2020
1 parent
50c1d47
commit ca47d7c
Showing
9 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/views/staff/transaction_uploads/_error_table.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
%table.govuk-table | ||
%caption.govuk-table__caption List of errors in your uploaded CSV file | ||
%thead.govuk-table__head | ||
%tr.govuk-table__row | ||
%th.govuk-table__header{scope: "col"} Column | ||
%th.govuk-table__header{scope: "col"} Row | ||
%th.govuk-table__header{scope: "col"} Current Value | ||
%th.govuk-table__header{scope: "col"} Error description | ||
%tbody.govuk-table__body | ||
- @errors.each do |error| | ||
%tr.govuk-table__row | ||
%td.govuk-table__cell= error.column | ||
%td.govuk-table__cell= error.csv_row | ||
%td{class: "govuk-table__cell govuk-!-font-weight-bold error-text"}= error.value | ||
%td.govuk-table__cell= error.message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.govuk-grid-row | ||
.govuk-grid-column-two-thirds | ||
= form_for @report_presenter, url: report_transaction_upload_path(@report_presenter) do |f| | ||
|
||
= f.govuk_file_field :transaction_csv, | ||
label: { text: t("form.label.transaction.csv_file") }, | ||
hint_text: t("form.hint.transaction.csv_file") | ||
|
||
= f.govuk_submit t("action.transaction.upload.button") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%main.govuk-main-wrapper#main-content{ role: "main" } | ||
.govuk-grid-row | ||
.govuk-grid-column-two-thirds | ||
%h1.govuk-heading-xl | ||
= t("page_title.transaction.upload") | ||
|
||
- unless @errors.empty? | ||
.govuk-grid-row | ||
.govuk-grid-column-full | ||
= render partial: "error_table" | ||
|
||
= render partial: "upload_form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters