Merge pull request #7864 from aignatov-bio/ai-sci-11067-fix-search-and-filter

Fix search and filter on storage locations [SCI-11067][SCI-11068]
This commit is contained in:
Martin Artnik 2024-09-18 14:59:51 +02:00 committed by GitHub
commit b9fd5148cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 8 deletions

View file

@ -517,7 +517,7 @@ export default {
this.totalPage = response.data.meta.total_pages;
this.totalEntries = response.data.meta.total_count;
}
this.$emit('tableReloaded', this.rowData);
this.$emit('tableReloaded', this.rowData, { filtered: this.searchValue.length > 0 });
this.dataLoading = false;
this.restoreSelection();

View file

@ -34,13 +34,13 @@
:selectedPosition="assignToPosition"
:selectedRow="rowIdToMove"
:cellId="cellIdToUnassign"
@close="openAssignModal = false; this.reloadingTable = true"
@close="openAssignModal = false; resetTableSearch(); this.reloadingTable = true"
></AssignModal>
<ImportModal
v-if="openImportModal"
:containerId="containerId"
@close="openImportModal = false"
@reloadTable="reloadingTable = true"
@reloadTable="resetTableSearch(); reloadingTable = true"
></ImportModal>
<ConfirmationModal
:title="i18n.t('storage_locations.show.unassign_modal.title')"
@ -187,9 +187,14 @@ export default {
updateTable() {
this.reloadingTable = true;
},
handleTableReload(items) {
handleTableReload(items, params) {
this.reloadingTable = false;
this.assignedItems = items;
if (!params.filtered) {
this.assignedItems = items;
}
},
resetTableSearch() {
this.$refs.table.searchValue = '';
},
selectRow(row) {
if (this.$refs.table.selectedRows.includes(row)) {
@ -231,7 +236,9 @@ export default {
const ok = await this.$refs.unassignStorageLocationModal.show();
if (ok) {
axios.post(event.path).then(() => {
this.resetTableSearch();
this.reloadingTable = true;
}).catch((error) => {
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
});

View file

@ -12,7 +12,9 @@ module Lists
@records = StorageLocationRepositoryRow.includes(:repository_row).where(storage_location_id: @storage_location_id)
end
def filter_records; end
def filter_records
@records = @records.joins(:repository_row).where('LOWER(repository_rows.name) ILIKE ?', "%#{@params[:search].downcase}%") if @params[:search].present?
end
def sort_records
return unless @params[:order]

View file

@ -36,8 +36,8 @@ module Lists
@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?
@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?
end
private