Browse Source

feat: DRY up routing

pull/2083/head
natdeanlewissoftwire 2 years ago
parent
commit
763423a9db
  1. 8
      app/helpers/schemes_helper.rb
  2. 4
      app/views/organisations/schemes.html.erb
  3. 2
      app/views/schemes/index.html.erb

8
app/helpers/schemes_helper.rb

@ -68,6 +68,14 @@ module SchemesHelper
end
end
def primary_schemes_csv_download_url(download_type)
csv_download_schemes_path(search: @searched, download_type:)
end
def secondary_schemes_csv_download_url(download_type)
schemes_csv_download_organisation_path(@organisation, search: @searched, download_type:)
end
private
ActivePeriod = Struct.new(:from, :to)

4
app/views/organisations/schemes.html.erb

@ -28,9 +28,9 @@
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<% if current_user.support? %>
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: schemes_csv_download_organisation_path(@organisation, search: @searched, download_type: "schemes"), locations_csv_download_url: schemes_csv_download_organisation_path(@organisation, search: @searched, download_type: "locations"), combined_csv_download_url: schemes_csv_download_organisation_path(@organisation, search: @searched, download_type: "combined") } %>
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: secondary_schemes_csv_download_url("schemes"), locations_csv_download_url: secondary_schemes_csv_download_url("locations"), combined_csv_download_url: secondary_schemes_csv_download_url("combined") } %>
<% else %>
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "schemes"), locations_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "locations"), combined_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "combined") } %>
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: primary_schemes_csv_download_url("schemes"), locations_csv_download_url: primary_schemes_csv_download_url("locations"), combined_csv_download_url: primary_schemes_csv_download_url("combined") } %>
<% end %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "schemes" } %>

2
app/views/schemes/index.html.erb

@ -15,7 +15,7 @@
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "schemes"), locations_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "locations"), combined_csv_download_url: csv_download_schemes_path(search: @searched, download_type: "combined") } %>
<%= render partial: "schemes/scheme_list", locals: { schemes: @schemes, title:, pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, schemes_csv_download_url: primary_schemes_csv_download_url("schemes"), locations_csv_download_url: primary_schemes_csv_download_url("locations"), combined_csv_download_url: primary_schemes_csv_download_url("combined") } %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "schemes" } %>
</div>

Loading…
Cancel
Save