mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 11:14:24 +08:00
FIX: Clearing inventory item filter fails with 500 or breaks UI [SCI-9345] (#6358)
This commit is contained in:
parent
809aaa8aa3
commit
9809f696a2
2 changed files with 15 additions and 8 deletions
|
@ -72,6 +72,7 @@ window.initRepositoryFilter = () => {
|
|||
{ id: 'archived_by', name: I18n.t('repositories.table.archived_by'), data_type: 'RepositoryUserValue' },
|
||||
{ id: 'archived_on', name: I18n.t('repositories.table.archived_on'), data_type: 'RepositoryDateTimeValue' }
|
||||
];
|
||||
const defFilters = JSON.parse(JSON.stringify(DEFAULT_FILTERS));
|
||||
const repositoryFilterContainer = new Vue({
|
||||
el: '#filterContainer',
|
||||
data: () => ({
|
||||
|
@ -120,10 +121,10 @@ window.initRepositoryFilter = () => {
|
|||
this.reloadDataTable();
|
||||
},
|
||||
clearFilters() {
|
||||
this.filters = this.filters
|
||||
.map(filter => {
|
||||
this.filters.forEach((filter, index) => {
|
||||
const newFilter = { ...filter };
|
||||
newFilter.data["parameters"] = {};
|
||||
newFilter.data['parameters'] = {};
|
||||
newFilter.data['operator'] = defFilters[index].data['operator'];
|
||||
return newFilter;
|
||||
});
|
||||
this.filterName = null;
|
||||
|
|
|
@ -168,6 +168,8 @@ class RepositoryDatatableService
|
|||
end
|
||||
|
||||
def build_row_id_filter_condition(repository_rows, filter_element_params)
|
||||
return repository_rows if filter_element_params.dig(:parameters, :text).blank?
|
||||
|
||||
case filter_element_params[:operator]
|
||||
when 'contains'
|
||||
repository_rows
|
||||
|
@ -183,6 +185,8 @@ class RepositoryDatatableService
|
|||
end
|
||||
|
||||
def build_name_filter_condition(repository_rows, filter_element_params)
|
||||
return repository_rows if filter_element_params.dig(:parameters, :text).blank?
|
||||
|
||||
case filter_element_params[:operator]
|
||||
when 'contains'
|
||||
repository_rows.where('repository_rows.name ILIKE ?',
|
||||
|
@ -351,6 +355,8 @@ class RepositoryDatatableService
|
|||
end
|
||||
|
||||
def build_assigned_filter_condition(repository_rows, filter_element_params)
|
||||
return repository_rows if filter_element_params.dig(:parameters, :my_module_ids).blank?
|
||||
|
||||
case filter_element_params[:operator]
|
||||
when 'any_of'
|
||||
repository_rows.joins(:my_modules)
|
||||
|
|
Loading…
Reference in a new issue