mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-30 20:23:14 +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"
|
:reloadingTable="reloadingTable"
|
||||||
:toolbarActions="toolbarActions"
|
:toolbarActions="toolbarActions"
|
||||||
:actionsUrl="actionsUrl"
|
:actionsUrl="actionsUrl"
|
||||||
|
:filters="filters"
|
||||||
@create_location="openCreateLocationModal"
|
@create_location="openCreateLocationModal"
|
||||||
@create_container="openCreateContainerModal"
|
@create_container="openCreateContainerModal"
|
||||||
@edit="edit"
|
@edit="edit"
|
||||||
|
@ -158,6 +159,21 @@ export default {
|
||||||
left,
|
left,
|
||||||
right: []
|
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: {
|
methods: {
|
||||||
|
|
|
@ -5,13 +5,26 @@ module Lists
|
||||||
def initialize(team, params)
|
def initialize(team, params)
|
||||||
@team = team
|
@team = team
|
||||||
@parent_id = params[:parent_id]
|
@parent_id = params[:parent_id]
|
||||||
|
@filters = params[:filters] || {}
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_records
|
def fetch_records
|
||||||
@records = @team.storage_locations.where(parent_id: @parent_id)
|
@records = @team.storage_locations
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -2726,6 +2726,8 @@ en:
|
||||||
owned_by: "Owned by"
|
owned_by: "Owned by"
|
||||||
created_on: "Created on"
|
created_on: "Created on"
|
||||||
description: "Description"
|
description: "Description"
|
||||||
|
filters_modal:
|
||||||
|
search_tree: "Look inside locations"
|
||||||
edit_modal:
|
edit_modal:
|
||||||
title_create_location: "Create new location"
|
title_create_location: "Create new location"
|
||||||
title_create_container: "Create new box"
|
title_create_container: "Create new box"
|
||||||
|
|
Loading…
Reference in a new issue