mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
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:
commit
838bce9ac1
3 changed files with 33 additions and 2 deletions
|
@ -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: {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue