Skip to content

Commit

Permalink
Add geolocation form back to _aside partial
Browse files Browse the repository at this point in the history
I figured out the original issue that caused me to add an id to the hidden field. It was because I changed the name (and therefore the id too) of the search fields from "#{css_field}-option-input" to the field name, resulting in the search fields having the same id as the hidden field. But adding an id to the hidden field was not the right solution because the location-manager is looking for an id=location, of which there are now many.

So, I reverted the hidden field back to have both name and id set to the field name, and added the "#{css_field}-option-input" id back to the search fields. Now everything is working like it should.
  • Loading branch information
monfresh committed May 28, 2014
1 parent dbe2e9d commit 9abe2bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/views/component/search/_aside.html.haml
@@ -1,5 +1,7 @@
%aside#search-container
%section#search-box
= form_tag('/organizations', :method => :get, :id=>"location-form") do
= hidden_field_tag 'location'
= form_tag('/organizations', :method => :get, :id=>"search-form") do
%section#keyword-search-box
%div
Expand Down
6 changes: 3 additions & 3 deletions app/views/component/search/_filter.html.haml
Expand Up @@ -52,7 +52,7 @@
%label{:for => "#{css_field}-option-1",:id => "#{css_field}-option-1-label"}
%span{:class=>(add_is_checked ? "hide" : "")}
Other...
= search_field_tag field, (add_is_checked ? params[field] : ""), :class=>(add_is_checked ? "" : "hide"),:list=>"#{css_field}-list",:placeholder=>"#{add_placeholder}"
= search_field_tag field, (add_is_checked ? params[field] : ""), id: "#{css_field}-option-input", :class=>(add_is_checked ? "" : "hide"),:list=>"#{css_field}-list",:placeholder=>"#{add_placeholder}"
- elsif add_input_type == "SELECT"
- add_is_checked = (all_is_checked == false && toggle_is_checked == false)
%div.toggle-group-wrapper.add
Expand All @@ -65,7 +65,7 @@
%label{:for => "#{css_field}-option-1",:id => "#{css_field}-option-1-label"}
%span{:class=>(add_is_checked ? "hide" : "")}
Other...
= select_tag(field, options_for_select(list_values, selected: :option ))
= select_tag field, options_for_select(list_values, selected: :option ), id: "#{css_field}-option-input"

- toggle_is_checked = false
- length = aggregate_field.length-1
Expand All @@ -85,7 +85,7 @@
%label{:for => "#{css_field}-option-#{i+2}",:id => "#{css_field}-option-#{i+2}-label"}
= field_display

= hidden_field_tag field, field_value, id: "#{css_field}-hidden"
= hidden_field_tag field, field_value

- if css_field == "location"
%div#geolocate-box
Expand Down
4 changes: 2 additions & 2 deletions spec/features/search/filters_spec.rb
Expand Up @@ -64,7 +64,7 @@
within("#location-options") do
find(".closed").trigger('mousedown')
expect(find(".available-options")).to have_css(".toggle-group", :count => 2)
expect(find_by_id("location").value).to eq "San Mateo, CA"
expect(find_by_id("location-option-input").value).to eq "San Mateo, CA"
end
end

Expand All @@ -75,7 +75,7 @@
within("#org-name-options") do
find(".closed").trigger('mousedown')
expect(find(".available-options")).to have_css(".toggle-group", :count => 2)
expect(find_by_id("org_name").value).to eq "United States Government"
expect(find_by_id("org-name-option-input").value).to eq "United States Government"
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Expand Up @@ -21,17 +21,17 @@
end

# To debug failures of javascript-enabled tests, you can add ":debug => true"
# as an additional option on line 16. For example:
# as an additional option on line 20. For example:
# Capybara::Poltergeist::Driver.new(app, :js_errors => true, :debug => true)
# This will result in verbose output in the Terminal when running tests.

# You can also use Poltergeist's experimental remote debugging feature by
# replacing line 15-17 with:
# replacing line 19-21 with:
# Capybara.register_driver :poltergeist_debug do |app|
# Capybara::Poltergeist::Driver.new(app, :inspector => true)
# end
# You will also need to add Capybara.javascript_driver = :poltergeist_debug
# on line 42. Add "page.driver.debug" at a spot where you want to pause a test.
# on line 45. Add "page.driver.debug" at a spot where you want to pause a test.
# When you run the test, it will pause at that spot, and will launch a browser
# window where you can inspect the page contents.
# Remember to remove "page.driver.debug" when you're done debugging!
Expand Down

0 comments on commit 9abe2bb

Please sign in to comment.