From 6c23d0045d9b58738c4ffaa5270bdf5fc0d68a5f Mon Sep 17 00:00:00 2001 From: Anselm Bradford Date: Tue, 29 Jul 2014 02:24:32 -0700 Subject: [PATCH] Fixes #495 - Adds input clear button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Adds search input manager for handling input clear button—little (x). - Disables autocomplete because field highlight color can’t be overridden. - Removes unused data-list attributes. - Adds tests for clearing the input fields. --- .../javascripts/search/input-manager.js | 52 ++++++ app/assets/javascripts/search/search-init.js | 10 +- app/assets/stylesheets/_mixins.scss | 5 +- .../stylesheets/components/_input-search.scss | 51 +++++- app/views/component/search/_agency.html.haml | 6 +- app/views/component/search/_aside.html.haml | 10 +- app/views/component/search/_box.html.haml | 4 +- .../component/search/_location.html.haml | 6 +- ...ars_the_contents_of_the_location_field.yml | 162 ++++++++++++++++++ ...ears_the_contents_of_the_keyword_field.yml | 159 +++++++++++++++++ ...ars_the_contents_of_the_location_field.yml | 159 +++++++++++++++++ .../search/results_page_search_spec.rb | 24 +++ 12 files changed, 626 insertions(+), 22 deletions(-) create mode 100644 app/assets/javascripts/search/input-manager.js create mode 100644 spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_agency/clears_the_contents_of_the_location_field.yml create mode 100644 spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_keyword/clears_the_contents_of_the_keyword_field.yml create mode 100644 spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_location/clears_the_contents_of_the_location_field.yml diff --git a/app/assets/javascripts/search/input-manager.js b/app/assets/javascripts/search/input-manager.js new file mode 100644 index 000000000..a8c56214c --- /dev/null +++ b/app/assets/javascripts/search/input-manager.js @@ -0,0 +1,52 @@ +// Handles functionality of search inputs, such as how the inputs are cleared. +define( +function () { + 'use strict'; + + function init() { + + var inputs = document.querySelectorAll('.clearable'); + + for (var i = 0, len = inputs.length; i < len; i++) { + _initCloseButton(inputs[i]) + } + } + + function _initCloseButton(inputContainer) { + + // Retrieve first and only input element. + var input = inputContainer.getElementsByTagName('input')[0]; + var buttonClose = document.createElement('button'); + buttonClose.className = 'button-close'; + if (input.value === '') + buttonClose.className += ' hide'; + inputContainer.appendChild(buttonClose); + + //var buttonClose = input.querySelector('.close'); + buttonClose.addEventListener('click', function (evt) { + evt.preventDefault(); + input.value = ''; + buttonClose.classList.add('hide'); + input.focus(); + }) + + input.addEventListener('keyup', function (evt) { + _checkCloseButtonVisibility(input, buttonClose); + }) + + input.addEventListener('change', function (evt) { + _checkCloseButtonVisibility(input, buttonClose); + }) + } + + function _checkCloseButtonVisibility(input, buttonClose) { + if (input.value === '') + buttonClose.classList.add('hide'); + else + buttonClose.classList.remove('hide'); + } + + return { + init:init + }; +}); diff --git a/app/assets/javascripts/search/search-init.js b/app/assets/javascripts/search/search-init.js index 703dddbd2..f7fb2acaa 100644 --- a/app/assets/javascripts/search/search-init.js +++ b/app/assets/javascripts/search/search-init.js @@ -1,7 +1,11 @@ -// manages search initialization -require(['search/search-filter-manager'], - function (filter) { +// Manages search initialization. +require([ + 'search/search-filter-manager', + 'search/input-manager' +], +function (filter, input) { 'use strict'; filter.init(); + input.init(); }); diff --git a/app/assets/stylesheets/_mixins.scss b/app/assets/stylesheets/_mixins.scss index a2830b0fd..03872f09e 100644 --- a/app/assets/stylesheets/_mixins.scss +++ b/app/assets/stylesheets/_mixins.scss @@ -73,16 +73,17 @@ // Turns off proprietary default webkit styling of search input fields. @mixin reset-input-webkit() { + // Turns off iOS input rounding. input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration, input[type=search]::-webkit-search-results-button, input[type=search]::-webkit-search-results-decoration { - -webkit-appearance:none; + -webkit-appearance: none; } input[type=search] { -webkit-appearance: none; border-radius: 0; - -webkit-box-sizing:content-box; + -webkit-box-sizing: content-box; } } diff --git a/app/assets/stylesheets/components/_input-search.scss b/app/assets/stylesheets/components/_input-search.scss index 7b4469d78..1101a9012 100644 --- a/app/assets/stylesheets/components/_input-search.scss +++ b/app/assets/stylesheets/components/_input-search.scss @@ -25,7 +25,7 @@ height: 45px; padding: 3px; padding-left: 45px; - padding-right: 6px; + padding-right: 25px; width: 100%; vertical-align: bottom; @@ -38,7 +38,7 @@ color: $white; } - > button + > .button-icon { cursor: pointer; background: none; @@ -107,7 +107,7 @@ color: $black; } - > button + > .button-icon { position: absolute; top: 0; @@ -181,7 +181,7 @@ > .filter-input-group { - > button + > .button-icon { font-size: $font_size_110; position: absolute; @@ -268,3 +268,46 @@ } } } + +// Clearable input fields have a (x) that can be clicked for clearing the +// field's content. +.clearable +{ + position: relative; + + &:hover + { + .button-close { + color: rgba($black, .4); + } + } + + .button-close + { + position: absolute; + right: 0px; + top: 50%; + margin-top: -15px; + + color: $greyscale_midtone; // IE Fallback + color: rgba($black, .1); + font-size: $font_size_110; + + border-collapse: collapse; + border: none; + outline: none; + background: transparent; + } + + .button-close:after, + .button-close::after + { + content: "×"; + } + + .button-close:hover + { + color: $black; + cursor: pointer; + } +} diff --git a/app/views/component/search/_agency.html.haml b/app/views/component/search/_agency.html.haml index 7ceb2de7d..7a4eced4c 100644 --- a/app/views/component/search/_agency.html.haml +++ b/app/views/component/search/_agency.html.haml @@ -1,6 +1,6 @@ = field_set_tag nil, id: 'org-name-options', class: 'input-search-filter' do = label_tag 'org_name', t('labels.agency_search') - = content_tag :div, '', class: 'filter-input-group' do - = button_tag(type: 'submit', name: nil) do + = content_tag :div, '', class: 'filter-input-group clearable' do + = button_tag(type: 'submit', name: nil, class: 'button-icon') do = content_tag :i, '', class: 'fa fa-institution' - = search_field_tag :org_name, params[:org_name], placeholder: t('placeholders.agency_search'), list: 'search-agency' + = search_field_tag :org_name, params[:org_name], autocomplete: 'off', placeholder: t('placeholders.agency_search') diff --git a/app/views/component/search/_aside.html.haml b/app/views/component/search/_aside.html.haml index dde2c352b..0317dfb91 100644 --- a/app/views/component/search/_aside.html.haml +++ b/app/views/component/search/_aside.html.haml @@ -2,10 +2,10 @@ %section#search-box = form_tag('/organizations', method: :get, id: 'search-form') do %section#keyword-search-box - %div.input-search-small - = button_tag(type: 'submit', name: nil, id: 'find-btn', title: 'Search') do + %div.input-search-small.clearable + = button_tag(type: 'submit', name: nil, id: 'find-btn', class: 'button-icon', title: 'Search') do %i{ class: 'fa fa-search' } - = search_field_tag :keyword, params[:keyword], placeholder: t('placeholders.results_page_keyword_search'), list: 'search-keywords' + = search_field_tag :keyword, params[:keyword], autocomplete: 'off', placeholder: t('placeholders.results_page_keyword_search') %section#search-options = render 'component/search/location' @@ -13,10 +13,10 @@ %ul#search-controls %li - = button_tag(type:'submit', name: nil, class: 'update-btn button-small') do + = button_tag(type:'submit', name: nil, class: 'button-small update-btn') do %i{ class: 'fa fa-refresh' } = t('buttons.update_search_results') %li - = button_tag(type: 'reset', name: nil, id: 'reset-btn', class: 'reset-btn button-small') do + = button_tag(type: 'reset', name: nil, id: 'reset-btn', class: 'button-small reset-btn') do %i{ class: 'fa fa-times-circle' } = t('buttons.clear_search_fields') diff --git a/app/views/component/search/_box.html.haml b/app/views/component/search/_box.html.haml index 710ce5f71..926312f2f 100644 --- a/app/views/component/search/_box.html.haml +++ b/app/views/component/search/_box.html.haml @@ -5,9 +5,9 @@ %section#keyword-search-box> = label_tag 'keyword', t('labels.homepage_search') %div.input-search-big - = search_field_tag :keyword, params[:keyword], placeholder: t('placeholders.homepage_keyword_search'), list: 'search-keywords' + = search_field_tag :keyword, params[:keyword], autocomplete: 'off', placeholder: t('placeholders.homepage_keyword_search') - = button_tag(type: 'submit', name: nil, id: 'find-btn', title: 'Search') do + = button_tag(type: 'submit', name: nil, id: 'find-btn', class: 'button-icon', title: 'Search') do %i{ class: 'fa fa-search' } %span = t('buttons.homepage_search') diff --git a/app/views/component/search/_location.html.haml b/app/views/component/search/_location.html.haml index 31ced176c..166117ba0 100644 --- a/app/views/component/search/_location.html.haml +++ b/app/views/component/search/_location.html.haml @@ -1,7 +1,7 @@ = field_set_tag nil, id: 'location-options', class: 'input-search-filter input-search-filter-option' do = label_tag 'location', t('labels.address_search') - = content_tag :div, '', class: 'filter-input-group' do - = button_tag(type: 'submit', name: nil) do + = content_tag :div, '', class: 'filter-input-group clearable' do + = button_tag(type: 'submit', name: nil, class: 'button-icon') do = content_tag :i, '', class: 'fa fa-map-marker' - = search_field_tag :location, params[:location], placeholder: t('placeholders.address_search'), list: 'search-location' + = search_field_tag :location, params[:location], autocomplete: 'off', placeholder: t('placeholders.address_search') = render 'component/search/geolocate', context_class: 'input-search-filter-option' \ No newline at end of file diff --git a/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_agency/clears_the_contents_of_the_location_field.yml b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_agency/clears_the_contents_of_the_location_field.yml new file mode 100644 index 000000000..f36ee38a3 --- /dev/null +++ b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_agency/clears_the_contents_of_the_location_field.yml @@ -0,0 +1,162 @@ +--- +http_interactions: +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword= + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; rel="last", + ; rel="next" + X-Total-Count: + - '24' + X-Total-Pages: + - '24' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 3e6fbc05-e8e3-47e7-b08c-0ad5f6dff8f8 + X-Runtime: + - '0.035505' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:15 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":1,"admin_emails":[],"coordinates":[-122.213221,37.477227],"description":"A + walk-in center for older adults that provides social services, wellness, recreational, + educational and creative activities including arts and crafts, computer classes + and gardening classes. Coffee and healthy breakfasts are available daily. + A hot lunch is served Tuesday-Friday for persons age 60 or over and spouse. Provides + case management (including in-home assessments) and bilingual information + and referral about community services to persons age 60 or over on questions + of housing, employment, household help, recreation and social activities, + home delivered meals, health and counseling services and services to shut-ins. + Health insurance and legal counseling is available by appointment. Lectures + on a variety of health and fitness topics are held monthly in both English + and Spanish. Provides a variety of physical fitness opportunities, including + a garden club, yoga, tai chi, soul line dance and aerobics classes geared + toward older adults. Also provides free monthly blood pressure screenings, + quarterly blood glucose monitoring and health screenings by a visiting nurse. + Offers a Brown Bag Program in which low-income seniors can receive a bag of + groceries each week for a membership fee of $10 a year. Offers Spanish lessons. + Formerly known as Peninsula Family Service, Fair Oaks Intergenerational Center. + Formerly known as the Fair Oaks Senior Center. Formerly known as Family Service + Agency of San Mateo County, Fair Oaks Intergenerational Center.","latitude":37.477227,"longitude":-122.213221,"name":"Fair + Oaks Adult Activity Center","short_desc":"A multipurpose senior citizens'' + center serving the Redwood City area.","slug":"fair-oaks-adult-activity-center","updated_at":"2014-05-09T20:49:18.836-07:00","urls":["http://www.peninsulafamilyservice.org"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/services","url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center","address":{"id":1,"street":"2600 + Middlefield Road","city":"Redwood City","state":"CA","zip":"94063"},"organization":{"id":1,"name":"Peninsula + Family Service","slug":"peninsula-family-service","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service/locations"},"phones":[{"id":1,"department":null,"extension":null,"number":"650 + 780-7525","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:15 GMT +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword=&location=&org_name=samaritan&utf8=%E2%9C%93 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; + rel="last", ; + rel="next" + X-Total-Count: + - '4' + X-Total-Pages: + - '4' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 88188ee3-d83a-4dd8-8677-be24d0b14d19 + X-Runtime: + - '0.030778' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:15 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":18,"admin_emails":[],"coordinates":[-122.207057,37.468678],"description":"Provides + free medical care to those in need. Offers basic medical exams for adults + and tuberculosis screening. Assists the individual to access other services + in the community. By appointment only, Project Smile provides a free dental + exam, dental cleaning and oral hygiene instruction for children, age 3-12, + of Samaritan House clients.","latitude":37.468678,"longitude":-122.207057,"name":"Redwood + City Free Medical Clinic","short_desc":"Provides free medical care to those + in need.","slug":"redwood-city-free-medical-clinic","updated_at":"2014-07-15T13:20:11.599-07:00","urls":["http://www.samaritanhouse.com"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/redwood-city-free-medical-clinic/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/redwood-city-free-medical-clinic/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/redwood-city-free-medical-clinic/services","url":"http://ohana-api-test.herokuapp.com/api/locations/redwood-city-free-medical-clinic","address":{"id":18,"street":"114 + Fifth Avenue","city":"Redwood City","state":"CA","zip":"94063"},"organization":{"id":5,"name":"Samaritan + House","slug":"samaritan-house","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house/locations"},"phones":[{"id":18,"department":null,"extension":null,"number":"650 + 839-1447","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:15 GMT +recorded_with: VCR 2.9.2 diff --git a/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_keyword/clears_the_contents_of_the_keyword_field.yml b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_keyword/clears_the_contents_of_the_keyword_field.yml new file mode 100644 index 000000000..596268bfc --- /dev/null +++ b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_keyword/clears_the_contents_of_the_keyword_field.yml @@ -0,0 +1,159 @@ +--- +http_interactions: +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword= + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; rel="last", + ; rel="next" + X-Total-Count: + - '24' + X-Total-Pages: + - '24' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 103ec571-1919-4ed9-8ee8-c07a3183fdd1 + X-Runtime: + - '0.032939' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:16 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":1,"admin_emails":[],"coordinates":[-122.213221,37.477227],"description":"A + walk-in center for older adults that provides social services, wellness, recreational, + educational and creative activities including arts and crafts, computer classes + and gardening classes. Coffee and healthy breakfasts are available daily. + A hot lunch is served Tuesday-Friday for persons age 60 or over and spouse. Provides + case management (including in-home assessments) and bilingual information + and referral about community services to persons age 60 or over on questions + of housing, employment, household help, recreation and social activities, + home delivered meals, health and counseling services and services to shut-ins. + Health insurance and legal counseling is available by appointment. Lectures + on a variety of health and fitness topics are held monthly in both English + and Spanish. Provides a variety of physical fitness opportunities, including + a garden club, yoga, tai chi, soul line dance and aerobics classes geared + toward older adults. Also provides free monthly blood pressure screenings, + quarterly blood glucose monitoring and health screenings by a visiting nurse. + Offers a Brown Bag Program in which low-income seniors can receive a bag of + groceries each week for a membership fee of $10 a year. Offers Spanish lessons. + Formerly known as Peninsula Family Service, Fair Oaks Intergenerational Center. + Formerly known as the Fair Oaks Senior Center. Formerly known as Family Service + Agency of San Mateo County, Fair Oaks Intergenerational Center.","latitude":37.477227,"longitude":-122.213221,"name":"Fair + Oaks Adult Activity Center","short_desc":"A multipurpose senior citizens'' + center serving the Redwood City area.","slug":"fair-oaks-adult-activity-center","updated_at":"2014-05-09T20:49:18.836-07:00","urls":["http://www.peninsulafamilyservice.org"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/services","url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center","address":{"id":1,"street":"2600 + Middlefield Road","city":"Redwood City","state":"CA","zip":"94063"},"organization":{"id":1,"name":"Peninsula + Family Service","slug":"peninsula-family-service","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service/locations"},"phones":[{"id":1,"department":null,"extension":null,"number":"650 + 780-7525","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:16 GMT +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword=clinic&location=&org_name=&utf8=%E2%9C%93 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; + rel="last", ; + rel="next" + X-Total-Count: + - '2' + X-Total-Pages: + - '2' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 9d2ae3f6-2562-4b5a-aaa2-ef79139c7ddf + X-Runtime: + - '0.044603' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:17 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":19,"admin_emails":[],"coordinates":[-122.2931236,37.5326941],"description":"Provides + free medical and dental care to those in need. Offers basic medical care for + adults.","latitude":37.5326941,"longitude":-122.2931236,"name":"San Mateo + Free Medical Clinic","short_desc":"Provides free medical and dental care to + those in need. Offers basic medical care for adults.","slug":"san-mateo-free-medical-clinic","updated_at":"2014-07-15T13:20:13.307-07:00","urls":["http://www.samaritanhouse.com"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/services","url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic","address":{"id":19,"street":"19 + West 39th Avenue","city":"San Mateo","state":"CA","zip":"94403"},"organization":{"id":5,"name":"Samaritan + House","slug":"samaritan-house","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house/locations"},"phones":[{"id":19,"department":null,"extension":null,"number":"650 + 578-0400","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:17 GMT +recorded_with: VCR 2.9.2 diff --git a/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_location/clears_the_contents_of_the_location_field.yml b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_location/clears_the_contents_of_the_location_field.yml new file mode 100644 index 000000000..1c75b8015 --- /dev/null +++ b/spec/cassettes/searching_from_results_page/when_clicking_the_clear_button_for_location/clears_the_contents_of_the_location_field.yml @@ -0,0 +1,159 @@ +--- +http_interactions: +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword= + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; rel="last", + ; rel="next" + X-Total-Count: + - '24' + X-Total-Pages: + - '24' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 6dff3f48-40de-494a-8429-fd1f287effac + X-Runtime: + - '0.048847' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:17 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":1,"admin_emails":[],"coordinates":[-122.213221,37.477227],"description":"A + walk-in center for older adults that provides social services, wellness, recreational, + educational and creative activities including arts and crafts, computer classes + and gardening classes. Coffee and healthy breakfasts are available daily. + A hot lunch is served Tuesday-Friday for persons age 60 or over and spouse. Provides + case management (including in-home assessments) and bilingual information + and referral about community services to persons age 60 or over on questions + of housing, employment, household help, recreation and social activities, + home delivered meals, health and counseling services and services to shut-ins. + Health insurance and legal counseling is available by appointment. Lectures + on a variety of health and fitness topics are held monthly in both English + and Spanish. Provides a variety of physical fitness opportunities, including + a garden club, yoga, tai chi, soul line dance and aerobics classes geared + toward older adults. Also provides free monthly blood pressure screenings, + quarterly blood glucose monitoring and health screenings by a visiting nurse. + Offers a Brown Bag Program in which low-income seniors can receive a bag of + groceries each week for a membership fee of $10 a year. Offers Spanish lessons. + Formerly known as Peninsula Family Service, Fair Oaks Intergenerational Center. + Formerly known as the Fair Oaks Senior Center. Formerly known as Family Service + Agency of San Mateo County, Fair Oaks Intergenerational Center.","latitude":37.477227,"longitude":-122.213221,"name":"Fair + Oaks Adult Activity Center","short_desc":"A multipurpose senior citizens'' + center serving the Redwood City area.","slug":"fair-oaks-adult-activity-center","updated_at":"2014-05-09T20:49:18.836-07:00","urls":["http://www.peninsulafamilyservice.org"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center/services","url":"http://ohana-api-test.herokuapp.com/api/locations/fair-oaks-adult-activity-center","address":{"id":1,"street":"2600 + Middlefield Road","city":"Redwood City","state":"CA","zip":"94063"},"organization":{"id":1,"name":"Peninsula + Family Service","slug":"peninsula-family-service","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/peninsula-family-service/locations"},"phones":[{"id":1,"department":null,"extension":null,"number":"650 + 780-7525","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:17 GMT +- request: + method: get + uri: http://ohana-api-test.herokuapp.com/api/search?action=index&controller=organizations&keyword=&location=94403&org_name=&utf8=%E2%9C%93 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/vnd.ohanapi-v1+json + User-Agent: + - Ohanakapa Ruby Gem 1.1.1 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Status: + - 200 OK + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Link: + - ; + rel="last", ; + rel="next" + X-Total-Count: + - '6' + X-Total-Pages: + - '6' + X-Current-Page: + - '1' + X-Next-Page: + - '2' + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 8a1d1498-b0b5-4277-a4de-858591ebcbde + X-Runtime: + - '0.088380' + X-Powered-By: + - Phusion Passenger 4.0.46 + Date: + - Tue, 29 Jul 2014 09:13:17 GMT + Server: + - nginx/1.6.0 + Phusion Passenger 4.0.46 + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"id":19,"admin_emails":[],"coordinates":[-122.2931236,37.5326941],"description":"Provides + free medical and dental care to those in need. Offers basic medical care for + adults.","latitude":37.5326941,"longitude":-122.2931236,"name":"San Mateo + Free Medical Clinic","short_desc":"Provides free medical and dental care to + those in need. Offers basic medical care for adults.","slug":"san-mateo-free-medical-clinic","updated_at":"2014-07-15T13:20:13.307-07:00","urls":["http://www.samaritanhouse.com"],"contacts_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/contacts","faxes_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/faxes","services_url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic/services","url":"http://ohana-api-test.herokuapp.com/api/locations/san-mateo-free-medical-clinic","address":{"id":19,"street":"19 + West 39th Avenue","city":"San Mateo","state":"CA","zip":"94403"},"organization":{"id":5,"name":"Samaritan + House","slug":"samaritan-house","urls":[],"url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house","locations_url":"http://ohana-api-test.herokuapp.com/api/organizations/samaritan-house/locations"},"phones":[{"id":19,"department":null,"extension":null,"number":"650 + 578-0400","number_type":null,"vanity_number":null}]}]' + http_version: + recorded_at: Tue, 29 Jul 2014 09:13:17 GMT +recorded_with: VCR 2.9.2 diff --git a/spec/features/search/results_page_search_spec.rb b/spec/features/search/results_page_search_spec.rb index 22242a119..9051c0dfe 100644 --- a/spec/features/search/results_page_search_spec.rb +++ b/spec/features/search/results_page_search_spec.rb @@ -122,4 +122,28 @@ to have_content('That search was improperly formatted.') end end + + context 'when clicking the clear button for keyword', :js do + it 'clears the contents of the keyword field' do + search(keyword: 'clinic') + find('#keyword-search-box').find('.button-close').click + expect(find_field('keyword').value).to eq '' + end + end + + context 'when clicking the clear button for location', :js do + it 'clears the contents of the location field' do + search(location: '94403') + find('#location-options').find('.button-close').click + expect(find_field('location').value).to eq '' + end + end + + context 'when clicking the clear button for agency', :js do + it 'clears the contents of the agency field' do + search(org_name: 'samaritan') + find('#org-name-options').find('.button-close').click + expect(find_field('org_name').value).to eq '' + end + end end