FIX: Clearing inventory item filter fails with 500 or breaks UI [SCI-9345] (#6358)

This commit is contained in:
Soufiane 2023-10-24 16:05:35 +02:00 committed by GitHub
parent 809aaa8aa3
commit 9809f696a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View file

@ -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;

View file

@ -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)