Browse Source

add a button to the logs list to delete multiple logs

style and position of button
helpers for displaying the button conditionally depending on user role and what filters and search are active
pull/1657/head
Arthur Campbell 3 years ago
parent
commit
ddf079047c
  1. 3
      app/frontend/styles/application.scss
  2. 11
      app/helpers/filters_helper.rb
  3. 9
      app/helpers/log_list_helper.rb
  4. 11
      app/views/logs/_log_list.html.erb

3
app/frontend/styles/application.scss

@ -44,6 +44,7 @@ $govuk-breakpoints: (
@import "search"; @import "search";
@import "sub-navigation"; @import "sub-navigation";
@import "errors"; @import "errors";
@import "log-list";
// App utilities // App utilities
.app-\!-colour-muted { .app-\!-colour-muted {
@ -52,7 +53,7 @@ $govuk-breakpoints: (
} }
.app-\!-colour-red { .app-\!-colour-red {
color: govuk-colour("red"); color: govuk-colour("red") !important;
} }
.app-\!-font-tabular { .app-\!-font-tabular {

11
app/helpers/filters_helper.rb

@ -11,6 +11,17 @@ module FiltersHelper
selected_filters[filter].include?(value.to_s) selected_filters[filter].include?(value.to_s)
end end
def any_filter_selected?
return false unless session[:logs_filters]
selected_filters = JSON.parse(session[:logs_filters])
filter_selected?("user", "yours") ||
selected_filters["organisation"]&.present? ||
selected_filters["status"]&.compact_blank&.any? ||
selected_filters["years"]&.compact_blank&.any? ||
selected_filters["bulk_upload_id"]&.compact_blank&.any?
end
def status_filters def status_filters
{ {
"not_started" => "Not started", "not_started" => "Not started",

9
app/helpers/log_list_helper.rb

@ -0,0 +1,9 @@
module LogListHelper
def display_delete_logs?
if @current_user.data_provider?
filter_selected?("user", "yours")
else
any_filter_selected? || @searched.present?
end
end
end

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

@ -1,11 +1,20 @@
<h2 class="govuk-body"> <h2 class="govuk-body">
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %> <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %>
<% 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" %> <%= 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 class="govuk-grid-column-one-quarter govuk-!-text-align-right">
<% if display_delete_logs? %>
<%= govuk_link_to "Delete logs", "#", class: "app-!-colour-red" %>
<% end %>
</div>
</div>
</h2> </h2>
<% logs.map do |log| %> <% logs.map do |log| %>
<%= render(LogSummaryComponent.new(current_user:, log:)) %> <%= render(LogSummaryComponent.new(current_user:, log:)) %>

Loading…
Cancel
Save