diff --git a/app/assets/javascripts/reports/reports_datatable.js b/app/assets/javascripts/reports/reports_datatable.js index 522d05ce0..4bdbda04a 100644 --- a/app/assets/javascripts/reports/reports_datatable.js +++ b/app/assets/javascripts/reports/reports_datatable.js @@ -374,6 +374,10 @@ }); } + $('.reports-index').on('change', '.report-search', function() { + REPORTS_TABLE.search($(this).val()).draw(); + }); + $('#show_report_preview').click(); initDatatable(); diff --git a/app/assets/stylesheets/report_index.scss b/app/assets/stylesheets/report_index.scss index 8d7da8f8d..354085a04 100644 --- a/app/assets/stylesheets/report_index.scss +++ b/app/assets/stylesheets/report_index.scss @@ -18,6 +18,13 @@ } } } + + .search-report-container { + display: inline-block; + float: right; + margin-right: 2em; + width: 200px; + } } .reports-datatable { diff --git a/app/datatables/report_datatable.rb b/app/datatables/report_datatable.rb index d8bfe1d78..1c4b0b963 100644 --- a/app/datatables/report_datatable.rb +++ b/app/datatables/report_datatable.rb @@ -103,5 +103,12 @@ class ReportDatatable < CustomDatatable Report.from(res, :reports) end + def filter_records(records) + records.where_attributes_like( + ['project_name', 'reports.name', 'reports.description'], + dt_params.dig(:search, :value) + ) + end + # ==== Insert 'presenter'-like methods below if necessary end diff --git a/app/views/reports/_index_toolbar.html.erb b/app/views/reports/_index_toolbar.html.erb index a255a71c4..a47bbc8c8 100644 --- a/app/views/reports/_index_toolbar.html.erb +++ b/app/views/reports/_index_toolbar.html.erb @@ -46,4 +46,8 @@ <% end %> +
+ "> + +
<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 271b3a81a..fae458b02 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -495,6 +495,7 @@ en: report_button: "Report" update_pdf: "Update PDF" save_pdf_to_inventory: "Save PDF to Inventory" + search_reports: "Find Reports" request_docx: "Generate DOCX" update_docx: "Update DOCX" edit: "Edit"