From 5ea4903dbedffc0ea47c396b8fc26dd203055a97 Mon Sep 17 00:00:00 2001 From: Ted-U <92022120+Ted-U@users.noreply.github.com> Date: Thu, 5 May 2022 14:01:46 +0100 Subject: [PATCH] Cldc 1149 radio buttons filter (#548) * radio button * radio button again * rubocop versioning issue fixed * linux and darwin * Fix Gemfile * rubocop * erb lint Co-authored-by: baarkerlounger --- Gemfile | 2 +- Gemfile.lock | 34 ++++++++++++------------ app/controllers/case_logs_controller.rb | 4 ++- app/views/case_logs/_log_filters.erb | 4 +-- app/views/filters/_radio_filter.html.erb | 8 ++++++ 5 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 app/views/filters/_radio_filter.html.erb diff --git a/Gemfile b/Gemfile index 53b9cf5e9..35abd8d23 100644 --- a/Gemfile +++ b/Gemfile @@ -80,7 +80,7 @@ group :development do # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem "erb_lint", require: false gem "rack-mini-profiler", "~> 2.0" - gem "rubocop-govuk", require: false + gem "rubocop-govuk", "4.3.0", require: false gem "rubocop-performance", require: false gem "rubocop-rails", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 9c376691e..33491ce74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,7 +105,7 @@ GEM ruby2_keywords (>= 0.0.2, < 1.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.580.0) + aws-partitions (1.584.0) aws-sdk-core (3.130.2) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) @@ -114,7 +114,7 @@ GEM aws-sdk-kms (1.56.0) aws-sdk-core (~> 3, >= 3.127.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.113.2) + aws-sdk-s3 (1.114.0) aws-sdk-core (~> 3, >= 3.127.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) @@ -176,7 +176,7 @@ GEM rubocop smart_properties erubi (1.10.0) - excon (0.92.2) + excon (0.92.3) factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) @@ -220,8 +220,8 @@ GEM thor (>= 0.14, < 2.0) jsbundling-rails (1.0.2) railties (>= 6.0.0) - json-schema (2.8.1) - addressable (>= 2.4) + json-schema (3.0.0) + addressable (>= 2.8) jwt (2.3.0) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -238,7 +238,7 @@ GEM listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.16.0) + loofah (2.17.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -264,16 +264,16 @@ GEM net-protocol timeout nio4r (2.5.8) - nokogiri (1.13.4-arm64-darwin) + nokogiri (1.13.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.13.4-x86_64-darwin) + nokogiri (1.13.5-x86_64-darwin) racc (~> 1.4) - nokogiri (1.13.4-x86_64-linux) + nokogiri (1.13.5-x86_64-linux) racc (~> 1.4) notifications-ruby-client (5.3.0) jwt (>= 1.5, < 3) orm_adapter (0.5.0) - overcommit (0.58.0) + overcommit (0.59.1) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) rexml (~> 3.2) @@ -414,13 +414,13 @@ GEM childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) - sentry-rails (5.2.1) + sentry-rails (5.3.0) railties (>= 5.0) - sentry-ruby-core (~> 5.2.1) - sentry-ruby (5.2.1) + sentry-ruby-core (~> 5.3.0) + sentry-ruby (5.3.0) concurrent-ruby (~> 1.0, >= 1.0.2) - sentry-ruby-core (= 5.2.1) - sentry-ruby-core (5.2.1) + sentry-ruby-core (= 5.3.0) + sentry-ruby-core (5.3.0) concurrent-ruby simplecov (0.21.2) docile (~> 1.1) @@ -502,7 +502,7 @@ DEPENDENCIES redis roo rspec-rails - rubocop-govuk + rubocop-govuk (= 4.3.0) rubocop-performance rubocop-rails selenium-webdriver @@ -522,4 +522,4 @@ RUBY VERSION ruby 3.1.1p18 BUNDLED WITH - 2.3.7 + 2.3.12 diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 657e38503..7e8e00560 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -136,7 +136,9 @@ private def set_session_filters new_filters = session[:case_logs_filters].present? ? JSON.parse(session[:case_logs_filters]) : {} - %i[status years user].each { |filter| new_filters[filter] = params[filter] if params[filter].present? } + %i[status years].each { |filter| new_filters[filter] = params[filter] if params[filter].present? } + new_filters[:user] = [params[:user]] if params[:user].present? + session[:case_logs_filters] = new_filters.to_json end end diff --git a/app/views/case_logs/_log_filters.erb b/app/views/case_logs/_log_filters.erb index f76e8b876..893a8607d 100644 --- a/app/views/case_logs/_log_filters.erb +++ b/app/views/case_logs/_log_filters.erb @@ -8,9 +8,9 @@ <% years = {"2021": "2021/22", "2022": "2022/23"} %> <%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %> <%= render partial: "filters/checkbox_filter", locals: { f: f, options: status_filters, label: "Status", category: "status" } %> - <%= render partial: "filters/checkbox_filter", locals: { f: f, options: {"all": "All", "yours": "Yours"}, label: "Logs", category: "user" } %> + <%= render partial: "filters/radio_filter", locals: { f: f, options: {"all": "All", "yours": "Yours"}, label: "Logs", category: "user" } %> <%= f.govuk_submit "Apply filters", class: "govuk-!-margin-bottom-0" %> <% end %> - + \ No newline at end of file diff --git a/app/views/filters/_radio_filter.html.erb b/app/views/filters/_radio_filter.html.erb new file mode 100644 index 000000000..aff0f6ed6 --- /dev/null +++ b/app/views/filters/_radio_filter.html.erb @@ -0,0 +1,8 @@ +<%= f.govuk_radio_buttons_fieldset category.to_sym, legend: { text: label, size: "s" }, small: true, form_group: { classes: "app-filter__group" } do %> + <% options.map do |key, option| %> + <%= f.govuk_radio_button category, key.to_s, + label: { text: option }, + checked: filter_selected?(category, key), + size: "s" %> + <% end %> +<% end %>