Skip to content

Commit

Permalink
Add page for CSV download reports
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencdaly committed Jan 2, 2025
1 parent a4c44d2 commit 914a1c6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def selection_questions_with_checkboxes
render template: "reports/selection_questions/checkboxes", locals: { data: }
end

def csv_downloads; end

def live_forms_csv
send_data ReportsService.new.live_forms_csv,
type: "text/csv; charset=iso-8859-1; header=present",
Expand All @@ -56,8 +58,8 @@ def live_forms_csv

def live_questions_csv
send_data ReportsService.new.live_questions_csv,
type: "text/csv; charset=iso-8859-1; header=present",
disposition: "attachment; filename=#{csv_filename('live_questions_csv')}"
type: "text/csv; charset=iso-8859-1; header=present",
disposition: "attachment; filename=#{csv_filename('live_questions_report')}"
end

private
Expand Down
13 changes: 13 additions & 0 deletions app/views/reports/csv_downloads.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% set_page_title(t("reports.csv_downloads.title")) %>
<% content_for :back_link, govuk_back_link_to(reports_path, t("reports.back_link")) %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l"><%= t("reports.csv_downloads.title") %></h1>

<ul class="govuk-list">
<li><%= govuk_link_to t("reports.csv_downloads.live_forms"), report_live_forms_csv_path, no_visited_state: true %></li>
<li><%= govuk_link_to t("reports.csv_downloads.live_questions"), report_live_questions_csv_path, no_visited_state: true %></li>
</ul>

</div>
</div>
1 change: 1 addition & 0 deletions app/views/reports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<li><%= govuk_link_to t("reports.features.long_list_usage.title"), report_selection_questions_summary_path %></li>
<li><%= govuk_link_to t("reports.users.title"), report_users_path %></li>
<li><%= govuk_link_to t("reports.last_signed_in_at.title"), report_last_signed_in_at_path %></li>
<li><%= govuk_link_to t("reports.csv_downloads.title"), report_csv_downloads_path %></li>
</ul>
</div>
</div>
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,10 @@ en:
heading: All forms with add another answer
title: All forms with add another answer
back_link: Back to reports
csv_downloads:
live_forms: Download all live forms as a CSV file
live_questions: Download all questions in live forms as a CSV file
title: Download form data as a CSV file
features:
answer_types:
heading: Answer type usage
Expand Down
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@
get "selection-questions-with-autocomplete", to: "reports#selection_questions_with_autocomplete", as: :report_selection_questions_with_autocomplete
get "selection-questions-with-radios", to: "reports#selection_questions_with_radios", as: :report_selection_questions_with_radios
get "selection-questions-with-checkboxes", to: "reports#selection_questions_with_checkboxes", as: :report_selection_questions_with_checkboxes
get "live-forms-csv", to: "reports#live_forms_csv", as: :live_forms_csv
get "live-questions-csv", to: "reports#live_questions_csv", as: :live_questions_csv
get "csv-downloads", to: "reports#csv_downloads", as: :report_csv_downloads
get "live-forms-csv", to: "reports#live_forms_csv", as: :report_live_forms_csv
get "live-questions-csv", to: "reports#live_questions_csv", as: :report_live_questions_csv
end

get "/maintenance" => "errors#maintenance", as: :maintenance_page
Expand Down

0 comments on commit 914a1c6

Please sign in to comment.