avo
avo copied to clipboard
Filters showing as active when they shouldn't be
Describe the bug
A basic filter is showing that a filter is applied when clearly none of the options are selected. This happens after applying and then disabling a filter. The table view of records updates with the no longer filtered records but the filter button still says a filter is active.
My filters are:
class Avo::Filters::Logo1 < Avo::Filters::BooleanFilter
self.name = "Logos"
# self.visible = -> do
# true
# end
def apply(request, query, values)
return query if values['logo'] && values['no_logo']
if values['logo']
query = query.with_logo1
elsif values['no_logo']
query = query.without_logo1
end
query
end
def options
{
logo: "Have Logos",
no_logo: "Do not have Logos"
}
end
end
class Avo::Filters::Milestones < Avo::Filters::BooleanFilter
self.name = "Milestones"
# self.visible = -> do
# true
# end
def apply(request, query, values)
return query if values['milestones'] && values['not_milestones']
if values['milestones']
query = query.milestones
elsif values['not_milestones']
query = query.where.not(id: Coaster.milestones)
end
query
end
def options
{
milestones: "Milestones",
not_milestones: "Not Milestones"
}
end
end
and
class Avo::Filters::Soundtrack1 < Avo::Filters::BooleanFilter
self.name = "Soundtracks"
# self.visible = -> do
# true
# end
def apply(request, query, values)
return query if values['soundtrack'] && values['no_soundtracks']
if values['soundtracks']
query = query.with_soundtrack1
elsif values['not_soundtracks']
query = query.without_soundtrack1
end
query
end
def options
{
soundtracks: "Have Soundtracks",
no_soundtracks: "Do not have Soundtracks"
}
end
end
What do you have in your URL when that is visible?
Also, do any of your filters use the default method?
@adrianthedev Sorry for the delay in reply. Things have been super hectic recently.
When it says a filter is applied but it actually isn't, my URL looks like:
http://localhost:3000/avo/resources/coasters?page=1&filters=eyJBdm86OkZpbHRlcnM6OkxvZ28xIjp7ImxvZ28iOmZhbHNlLCJub19sb2dvIjpmYWxzZX19
No, none of my Filters use the default method.
This issue has been marked as stale because there was no activity for the past 15 days.
This issue has been marked as stale because there was no activity for the past 15 days.
Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️
This issue has been marked as stale because there was no activity for the past 15 days.
@rctneil are you able to share a reproduction repository?
This issue has been marked as stale because there was no activity for the past 15 days.
Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️