8000 fix filter by blank string by elad-eyal · Pull Request #709 · frab/frab · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix filter by blank string #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filter_modal
case @filter.type
when :text
@options = helpers.localized_filter_options(@conference.events.includes(:track).distinct.pluck(@filter.attribute_name), @filter.i18n_scope)
@selected_values = helpers.split_filter_string(params[@filter.qname]) if params[@filter.qname].present?
@selected_values = helpers.split_filter_string(params[@filter.qname]) if params[@filter.qname]
when :range
@op, @current_numeric_value = helpers.get_op_and_val(params[@filter.qname])
end
Expand Down Expand Up @@ -338,7 +338,7 @@ def clean_events_attributes
def search(events)
filter = events
helpers.filters_data.each do |f|
if params[f.qname].present?
if params[f.qname]
filter = filter.where(f.attribute_name => criteria_from_param(f))
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def filters_data

def show_filters_pane?
filters_data.each do |f|
return true if params[f.qname].present?
return true if params[f.qname]
end
false
end

def localized_filter_options(c, i18n_scope)
c = split_filter_string(c) if c.is_a? String
options = (c - ['',nil]).map{|v| [ if i18n_scope
Expand All @@ -88,6 +89,7 @@ def localized_filter_options(c, i18n_scope)
end

def split_filter_string(s)
return [''] if s==''
s.split('|', -1)
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/events/_filters.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%div.filters-row
%b= t('col_filters')
- filters_data.each do |f|
- if params[f.qname].present?
- if params[f.qname]
%span{:class => 'filterbox'}
= link_to "╳", request.query_parameters.except(f.qname), class: 'filterbox-close-btn'
= f.filter_name || t(f.filter_name_i18n)
Expand Down
0