mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +08:00
Fixed repositories search to only search the current repository. [SCI-1357]
This commit is contained in:
parent
092e82c722
commit
bae1e298d7
1 changed files with 7 additions and 5 deletions
|
@ -185,18 +185,20 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
|||
end
|
||||
|
||||
# Overriden to make it work for custom columns, because they are polymorphic
|
||||
def simple_search(records)
|
||||
return records unless params[:search].present? &&
|
||||
params[:search][:value].present?
|
||||
# NOTE: Function assumes the provided records/rows are only from the current
|
||||
# repository!
|
||||
def simple_search(repo_rows)
|
||||
return repo_rows unless params[:search].present? &&
|
||||
params[:search][:value].present?
|
||||
search_val = params[:search][:value]
|
||||
|
||||
filtered_ids = RepositoryRow.select do |r|
|
||||
filtered_rows = repo_rows.select do |r|
|
||||
row_cells = [r.name, r.created_at.strftime(Constants::DATE_FORMAT),
|
||||
r.created_by.full_name]
|
||||
row_cells.push(*r.repository_cells.collect { |c| c.value.data })
|
||||
row_cells.any? { |c| c.include?(search_val) }
|
||||
end
|
||||
records.where!(id: filtered_ids)
|
||||
repo_rows.where(id: filtered_rows)
|
||||
end
|
||||
|
||||
# Override default sort method if needed
|
||||
|
|
Loading…
Reference in a new issue