mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-11 23:54:43 +08:00
Merge pull request #7910 from aignatov-bio/ai-sci-11129-improve-storage-locations-search
Improve storage locations search [SCI-11129]
This commit is contained in:
commit
f6bb7022d9
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…
Add table
Reference in a new issue