Browse Source

Put download links on the next line

pull/1999/head
Kat 3 years ago
parent
commit
75286b0162
  1. 6
      app/components/search_result_caption_component.html.erb
  2. 27
      app/views/logs/_log_list.html.erb
  3. 10
      spec/components/search_result_caption_component_spec.rb

6
app/components/search_result_caption_component.html.erb

@ -1,10 +1,10 @@
<span class="govuk-!-margin-right-4"> <span class="govuk-!-margin-right-4">
<% if searched.present? && filters_count&.positive? %> <% if searched.present? && filters_count&.positive? %>
<strong><%= count %></strong> <%= item_label.pluralize(count) %> matching search and filters <strong><%= count %></strong> <%= item_label.pluralize(count) %> matching search and filters<br>
<% elsif searched.present? %> <% elsif searched.present? %>
<strong><%= count %></strong> <%= item_label.pluralize(count) %> matching search <strong><%= count %></strong> <%= item_label.pluralize(count) %> matching search<br>
<% elsif filters_count&.positive? %> <% elsif filters_count&.positive? %>
<strong><%= count %></strong> <%= item_label.pluralize(count) %> matching filters <strong><%= count %></strong> <%= item_label.pluralize(count) %> matching filters<br>
<% else %> <% else %>
<strong><%= count %></strong> matching <%= item %> <strong><%= count %></strong> matching <%= item %>
<% end %> <% end %>

27
app/views/logs/_log_list.html.erb

@ -1,19 +1,20 @@
<h2 class="govuk-body"> <h2 class="govuk-body">
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters"> <div class="govuk-grid-column-three-quarters">
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", filters_count: applied_filters_count(@filter_type))) %> <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", filters_count: applied_filters_count(@filter_type))) %>
<% if logs&.any? %> <% if logs&.any? %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4" %> <%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4" %>
<% if @current_user.support? %> <% if @current_user.support? %>
<%= govuk_link_to "Download (CSV, codes only)", csv_codes_only_download_url, type: "text/csv", class: "govuk-!-margin-right-4" %> <%= govuk_link_to "Download (CSV, codes only)", csv_codes_only_download_url, type: "text/csv", class: "govuk-!-margin-right-4" %>
<% end %>
<% end %> <% end %>
<% end %> </div>
</div> <div class="govuk-grid-column-one-quarter govuk-!-text-align-right">
<div class="govuk-grid-column-one-quarter govuk-!-text-align-right"> <br>
<% if logs&.any? && (display_delete_logs?(@current_user, searched, filter_type) || in_organisations_tab?) %> <% if logs&.any? && (display_delete_logs?(@current_user, searched, filter_type) || in_organisations_tab?) %>
<%= govuk_link_to "Delete logs", delete_logs_path, class: "app-!-colour-red" %> <%= govuk_link_to "Delete logs", delete_logs_path, class: "app-!-colour-red" %>
<% end %> <% end %>
</div> </div>
</div> </div>
</h2> </h2>
<% logs.map do |log| %> <% logs.map do |log| %>

10
spec/components/search_result_caption_component_spec.rb

@ -11,7 +11,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
context "when search and filter results are found" do context "when search and filter results are found" do
it "renders table caption including the search results and total" do it "renders table caption including the search results and total" do
expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching search and filters\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching search and filters<br>\n</span>\n")
end end
end end
@ -19,7 +19,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
let(:filters_count) { nil } let(:filters_count) { nil }
it "renders table caption including the search results and total" do it "renders table caption including the search results and total" do
expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching search\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching search<br>\n</span>\n")
end end
end end
@ -27,7 +27,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
let(:searched) { nil } let(:searched) { nil }
it "renders table caption including the search results and total" do it "renders table caption including the search results and total" do
expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching filters\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>2</strong> users matching filters<br>\n</span>\n")
end end
end end
@ -44,7 +44,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
let(:count) { 0 } let(:count) { 0 }
it "renders table caption with total count only" do it "renders table caption with total count only" do
expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>0</strong> users matching search and filters\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>0</strong> users matching search and filters<br>\n</span>\n")
end end
end end
@ -52,7 +52,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
let(:count) { 1 } let(:count) { 1 }
it "renders table caption with total count only" do it "renders table caption with total count only" do
expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>1</strong> user matching search and filters\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>1</strong> user matching search and filters<br>\n</span>\n")
end end
end end
end end

Loading…
Cancel
Save