Merge pull request #7776 from aignatov-bio/ai-sci-10927-add-storage-locations-filter-search

Add filters to storage locations [SCI-10927]
This commit is contained in:
aignatov-bio 2024-08-02 14:04:33 +02:00 committed by GitHub
commit 838bce9ac1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 2 deletions

View file

@ -6,6 +6,7 @@
:reloadingTable="reloadingTable"
:toolbarActions="toolbarActions"
:actionsUrl="actionsUrl"
:filters="filters"
@create_location="openCreateLocationModal"
@create_container="openCreateContainerModal"
@edit="edit"
@ -158,6 +159,21 @@ export default {
left,
right: []
};
},
filters() {
const filters = [
{
key: 'query',
type: 'Text'
},
{
key: 'search_tree',
type: 'Checkbox',
label: this.i18n.t('storage_locations.index.filters_modal.search_tree')
}
];
return filters;
}
},
methods: {

View file

@ -5,13 +5,26 @@ module Lists
def initialize(team, params)
@team = team
@parent_id = params[:parent_id]
@filters = params[:filters] || {}
@params = params
end
def fetch_records
@records = @team.storage_locations.where(parent_id: @parent_id)
@records = @team.storage_locations
end
def filter_records; end
def filter_records
if @filters[:search_tree].present?
if @parent_id.present?
storage_location = @records.find_by(id: @parent_id)
@records = @records.where(id: StorageLocation.inner_storage_locations(@team, storage_location))
end
else
@records = @records.where(parent_id: @parent_id)
end
@records = @records.where('LOWER(name) ILIKE ?', "%#{@filters[:query].downcase}%") if @filters[:query].present?
@records = @records.where('LOWER(name) ILIKE ?', "%#{@params[:search].downcase}%") if @params[:search].present?
end
end
end

View file

@ -2726,6 +2726,8 @@ en:
owned_by: "Owned by"
created_on: "Created on"
description: "Description"
filters_modal:
search_tree: "Look inside locations"
edit_modal:
title_create_location: "Create new location"
title_create_container: "Create new box"