From 285aa170247b01a66090a7ca9f85ff6ba8b219dd Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Thu, 14 Jan 2021 14:17:05 -0500 Subject: [PATCH] Added search to admin reports page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - search to admin reports page --- app/controllers/admin/reports_controller.rb | 1 + app/models/report_filter.rb | 2 ++ app/views/admin/reports/index.html.haml | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index f138376b..90f0f557 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -55,6 +55,7 @@ module Admin params.permit( :account_id, :resolved, + :comment, :target_account_id ) end diff --git a/app/models/report_filter.rb b/app/models/report_filter.rb index 56ab28df..267f5ded 100644 --- a/app/models/report_filter.rb +++ b/app/models/report_filter.rb @@ -23,6 +23,8 @@ class ReportFilter Report.where(account_id: value) when :target_account_id Report.where(target_account_id: value) + when :comment + Report.where(comment: value) else raise "Unknown filter: #{key}" end diff --git a/app/views/admin/reports/index.html.haml b/app/views/admin/reports/index.html.haml index d73faccb..27e893d9 100644 --- a/app/views/admin/reports/index.html.haml +++ b/app/views/admin/reports/index.html.haml @@ -8,6 +8,16 @@ %li= filter_link_to t('admin.reports.unresolved'), resolved: nil %li= filter_link_to t('admin.reports.resolved'), resolved: '1' += form_tag admin_reports_url, method: 'GET', class: 'simple_form' do + .fields-group + - %i(comment).each do |key| + .input.string.optional + = text_field_tag key, params[key], class: 'string optional', placeholder: "#{key}" + + .actions + %button= t('admin.accounts.search') + = link_to t('admin.accounts.reset'), admin_accounts_path, class: 'button negative' + - @reports.group_by(&:target_account_id).each do |target_account_id, reports| - target_account = reports.first.target_account .report-card