Skip to content

Search select multi option #511

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

Open
wants to merge 4 commits into
base: v1
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GIT
PATH
remote: .
specs:
activeadmin_addons (1.10.1)
activeadmin_addons (1.10.2)
active_material (~> 1.5)
railties
redcarpet
Expand Down Expand Up @@ -108,7 +108,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
climate_control (0.2.0)
coderay (1.1.2)
coderay (1.1.3)
concurrent-ruby (1.1.10)
content_disposition (1.0.0)
crass (1.0.6)
Expand Down Expand Up @@ -186,7 +186,7 @@ GEM
mini_mime (>= 0.1.1)
marcel (1.0.2)
matrix (0.4.2)
method_source (0.9.2)
method_source (1.1.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
Expand All @@ -212,9 +212,9 @@ GEM
parser (2.7.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry (0.15.0)
coderay (~> 1.1)
method_source (~> 1.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
psych (3.1.0)
Expand Down Expand Up @@ -336,7 +336,7 @@ GEM
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
thor (1.2.1)
tilt (2.1.0)
tilt (2.4.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (1.4.1)
Expand Down
6 changes: 5 additions & 1 deletion app/inputs/search_select_filter_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def load_control_attributes
end

def input_method
eq_input_name
if @options.dig(:input_html, :multiple)
in_input_name
else
eq_input_name
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def input_value
result.values.first.value
end

def in_input_name
"#{method}_in"
end

def eq_input_name
"#{valid_method}_eq"
end
Expand Down
44 changes: 43 additions & 1 deletion spec/features/inputs/search_select_filter_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
click_filter_btn
end

it "shows all the results" do
it "shows filtered results" do
within "#index_table_cities" do
expect_text("Santiago")
expect_text("Colina")
Expand All @@ -47,4 +47,46 @@
end
end
end

context "with multiple: true" do
before do
register_page(City, false) do
filter :region_id, as: :search_select_filter, input_html: { multiple: true }
end

visit admin_cities_path
end

it "shows filter input" do
expect_css("select#q_region_id[multiple]")
end

it "shows all the results" do
within "#index_table_cities" do
expect_text("Santiago")
expect_text("Colina")
expect_text("Mejillones")
expect_text("Tocopilla")
expect_text("Mendoza")
end
end

context "setting multiple values", js: true do
before do
pick_select2_entered_option("Cuyo")
pick_select2_entered_option("Metropolitana")
click_filter_btn
end

it "shows filtered results" do
within "#index_table_cities" do
expect_text("Santiago")
expect_text("Colina")
expect_text("Mendoza")
not_expect_text("Mejillones")
not_expect_text("Tocopilla")
end
end
end
end
end