mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 12:43:06 +08:00
Improve storage locations search [SCI-11129]
This commit is contained in:
parent
5ab1fbbab9
commit
ba1162c453
2 changed files with 20 additions and 2 deletions
|
@ -6,6 +6,7 @@ class StorageLocation < ApplicationRecord
|
|||
ID_PREFIX = 'SL'
|
||||
include PrefixedIdModel
|
||||
include Shareable
|
||||
include SearchableModel
|
||||
|
||||
default_scope -> { kept }
|
||||
|
||||
|
|
|
@ -44,8 +44,25 @@ module Lists
|
|||
@records = @records.where(parent_id: @parent_id)
|
||||
end
|
||||
|
||||
@records = @records.where('LOWER(storage_locations.name) ILIKE ?', "%#{@filters[:query].downcase}%") if @filters[:query].present?
|
||||
@records = @records.where('LOWER(storage_locations.name) ILIKE ?', "%#{@params[:search].downcase}%") if @params[:search].present?
|
||||
if @filters[:query].present?
|
||||
@records = @records.where_attributes_like(
|
||||
[
|
||||
'storage_locations.name',
|
||||
'storage_locations.description',
|
||||
StorageLocation::PREFIXED_ID_SQL
|
||||
], @filters[:query]
|
||||
)
|
||||
end
|
||||
|
||||
if @params[:search].present?
|
||||
@records = @records.where_attributes_like(
|
||||
[
|
||||
'storage_locations.name',
|
||||
'storage_locations.description',
|
||||
StorageLocation::PREFIXED_ID_SQL
|
||||
], @params[:search]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue