Add search field to reports page [SCI-5551]

This commit is contained in:
aignatov-bio 2021-05-13 21:41:26 +02:00
parent 34c79d66b8
commit e953666762
5 changed files with 21 additions and 0 deletions

View file

@ -360,6 +360,10 @@
});
}
$('.reports-index').on('change', '.report-search', function() {
REPORTS_TABLE.search($(this).val()).draw();
});
$('#show_report_preview').click();
initDatatable();

View file

@ -18,6 +18,13 @@
}
}
}
.search-report-container {
display: inline-block;
float: right;
margin-right: 2em;
width: 200px;
}
}
.reports-datatable {

View file

@ -103,5 +103,10 @@ class ReportDatatable < CustomDatatable
Report.from(res, :reports)
end
def filter_records(records)
records.where('project_name ILIKE :q OR reports.name ILIKE :q OR reports.description ILIKE :q',
{ q: "%#{dt_params.dig(:search, :value)}%" })
end
# ==== Insert 'presenter'-like methods below if necessary
end

View file

@ -46,4 +46,8 @@
<span class="hidden-xs"><%=t "projects.reports.index.delete" %></span>
<% end %>
</div>
<div class="sci-input-container left-icon search-report-container">
<input type="text" class="sci-input-field report-search" placeholder="<%= t("projects.reports.index.search_reports") %>"></input>
<i class="fas fa-search"></i>
</div>
<% end %>

View file

@ -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"