From 2de827ecb127827fdbb29520ba92987a8130154d Mon Sep 17 00:00:00 2001 From: Anselm Bradford Date: Sat, 26 Jul 2014 02:32:18 -0700 Subject: [PATCH 1/2] Fixes #476 - Adds missing location details - Adds keywords, service areas, and wait times fields to location details template. - Adds categories hierarchy styles. - Adds service_areas template. - Performs miscellaneous ruby style guide formatting. - Adds location details specs (keywords, service areas, and wait times). - Arranges location details spec checks in order they appear on details page. - Adds/edits description section titles for location and service. --- app/assets/stylesheets/_base.scss | 5 ++ app/controllers/organizations_controller.rb | 2 + .../component/detail/_accessibility.html.haml | 4 +- .../component/detail/_languages.html.haml | 4 +- .../component/detail/_mail_address.html.haml | 8 +-- .../component/detail/_service_areas.html.haml | 10 ++++ .../component/detail/_template.html.haml | 2 +- app/views/component/detail/_urls.html.haml | 2 +- .../organizations/detail/_body.html.haml | 24 ++++++-- .../features/details/location_details_spec.rb | 60 ++++++++++--------- 10 files changed, 76 insertions(+), 45 deletions(-) create mode 100644 app/views/component/detail/_service_areas.html.haml diff --git a/app/assets/stylesheets/_base.scss b/app/assets/stylesheets/_base.scss index c0d0be215..e2898e754 100644 --- a/app/assets/stylesheets/_base.scss +++ b/app/assets/stylesheets/_base.scss @@ -1676,6 +1676,11 @@ body { top: 0px !important; } padding: 35px; padding-top: 0px; padding-bottom: 20px; + + // Indentation for service category hierarchy. + .hierarchy-depth-1{ margin-left: 10px; } + .hierarchy-depth-2{ margin-left: 20px; } + .hierarchy-depth-3{ margin-left: 30px; } } > section > section > section diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 17ad54bcd..fa1a2a5fa 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -74,6 +74,8 @@ def show if @org[:services].present? @categories = @org.services.map { |s| s[:categories] }.flatten.compact + @keywords = @org.services.map { |s| s[:keywords] }.flatten.compact.uniq + @service_areas = @org.services.map { |s| s[:service_areas] }.flatten.compact.uniq end # To disable or remove the Result list button on details page diff --git a/app/views/component/detail/_accessibility.html.haml b/app/views/component/detail/_accessibility.html.haml index 494b89283..da3dbce30 100644 --- a/app/views/component/detail/_accessibility.html.haml +++ b/app/views/component/detail/_accessibility.html.haml @@ -1,7 +1,7 @@ - if org[:accessibility].present? - %section{:class=>css_class_format('accessibility')} + %section{ class: css_class_format('accessibility') } - if defined? iconclass - %i{:class=>iconclass} + %i{ class: iconclass } %h1 Accessibility Options: %ul - org.accessibility.sort.each do |accessibility_option| diff --git a/app/views/component/detail/_languages.html.haml b/app/views/component/detail/_languages.html.haml index 0366d1427..02dfa5478 100644 --- a/app/views/component/detail/_languages.html.haml +++ b/app/views/component/detail/_languages.html.haml @@ -1,7 +1,7 @@ - if org[:languages].present? - %section{:class=>css_class_format('languages')} + %section{ class: css_class_format('languages') } - if defined? iconclass - %i{:class=>iconclass} + %i{ class: iconclass } %h1 Languages Spoken: %ul - org.languages.sort.each do |lang| diff --git a/app/views/component/detail/_mail_address.html.haml b/app/views/component/detail/_mail_address.html.haml index fc107c576..45b265bf5 100644 --- a/app/views/component/detail/_mail_address.html.haml +++ b/app/views/component/detail/_mail_address.html.haml @@ -5,16 +5,16 @@ = org.mail_address.attention %br - %span.street-address{:itemprop=>"streetAddress"} + %span.street-address{ itemprop: 'streetAddress' } = superscript_ordinals(org.mail_address.street) %br - %span.city{:itemprop=>"addressLocality"}>< + %span.city{ itemprop: 'addressLocality' }>< = org.mail_address.city = ',' - %span.state{:itemprop=>"addressRegion"} + %span.state{ itemprop: 'addressRegion' } = org.mail_address.state - %span.zipcode{:itemprop=>"postalCode"} + %span.zipcode{ itemprop: 'postalCode' } = org.mail_address.zip diff --git a/app/views/component/detail/_service_areas.html.haml b/app/views/component/detail/_service_areas.html.haml new file mode 100644 index 000000000..b9786ec9e --- /dev/null +++ b/app/views/component/detail/_service_areas.html.haml @@ -0,0 +1,10 @@ +- if @service_areas.present? + %section{ class: 'service-areas' } + - if defined? stitle + - if stitle.present? + %h1 #{stitle}: + %ul + - @service_areas.sort.each do |f| + %li + %span + = f diff --git a/app/views/component/detail/_template.html.haml b/app/views/component/detail/_template.html.haml index 5bcf953fc..8c14b78f1 100644 --- a/app/views/component/detail/_template.html.haml +++ b/app/views/component/detail/_template.html.haml @@ -1,5 +1,5 @@ - if org[field].present? - %section{:class=>css_class_format(field.to_s)} + %section{ class: css_class_format(field.to_s) } - if defined? iconclass %i{ class: iconclass } - if defined? stitle diff --git a/app/views/component/detail/_urls.html.haml b/app/views/component/detail/_urls.html.haml index 4eb57e772..b50c7738f 100644 --- a/app/views/component/detail/_urls.html.haml +++ b/app/views/component/detail/_urls.html.haml @@ -1,5 +1,5 @@ - if org[:urls].present? - %section{:class=>'urls'} + %section{ class: 'urls' } - if defined? iconclass %i{ class: iconclass } - if defined? stitle diff --git a/app/views/component/organizations/detail/_body.html.haml b/app/views/component/organizations/detail/_body.html.haml index 32faf36bd..e3dac6f45 100644 --- a/app/views/component/organizations/detail/_body.html.haml +++ b/app/views/component/organizations/detail/_body.html.haml @@ -102,14 +102,24 @@ %section#categories-box %h1 Service Categories %section.services{ itemscope: '', itemtype: 'http://schema.org/Service' } - %ul{ itemscope: '', itemtype: 'http://schema.org/ServiceType' } + %ul{ itemscope: '', itemtype: 'http://schema.org/serviceType' } - @categories.each do |category| - %li{ class: "depth#{category.depth}" } + %li{ class: "hierarchy-depth-#{category.depth}" } %span{ itemprop: 'serviceType' } -# Category links are disabled till there's a corresponding filter that can be toggled! - = link_to category.name, organizations_path(@search_params.merge(:category => category.name)) + = link_to category.name, organizations_path(@search_params.merge(category: category.name)) = category.name + - if @keywords.present? + %section#keywords-box + %h1 Keyword Tags + %section.keywords + %ul + - @keywords.each do |keyword| + %li + %span + = link_to keyword, organizations_path(@search_params.merge(keyword: keyword)) + / Main detail content. %section @@ -118,7 +128,7 @@ %section = render partial: 'component/detail/template', locals: { org: @org, field: :short_desc } - = render partial: 'component/detail/template', locals: { org: @org, field: :description, stitle: 'Description' } + = render partial: 'component/detail/template', locals: { org: @org, field: :description, stitle: 'Location Description' } - if @org[:coordinates].present? || @org[:transportation].present? %section.map-box @@ -167,14 +177,16 @@ %section.service{ itemscope: '', itemtype: 'http://schema.org/Service' } = render partial: 'component/detail/template', locals: { org: service, field: :name} - = render partial: 'component/detail/template', locals: { org: service, field: :description} + = render partial: 'component/detail/template', locals: { org: service, field: :description, stitle: 'Service Description'} = render partial: 'component/detail/urls', locals: { org: service, field: :urls, stitle: 'Homepage' } = render partial: 'component/detail/template', locals: { org: service, field: :fees, stitle: 'Fees' } = render partial: 'component/detail/template', locals: { org: service, field: :audience, stitle: 'Audience' } = render partial: 'component/detail/template', locals: { org: service, field: :eligibility, stitle: 'Eligibility' } = render partial: 'component/detail/template', locals: { org: service, field: :how_to_apply, stitle: 'How to Apply' } + = render partial: 'component/detail/template', locals: { org: service, field: :wait, stitle: 'Service Wait Estimate' } + = render partial: 'component/detail/service_areas', locals: { org: service, field: :service_areas, stitle: 'Service Areas' } - / detail footer content + / Detail footer content. - if @org[:updated_at].present? %footer %section.metadata diff --git a/spec/features/details/location_details_spec.rb b/spec/features/details/location_details_spec.rb index 9a5b63651..1bec7a90c 100644 --- a/spec/features/details/location_details_spec.rb +++ b/spec/features/details/location_details_spec.rb @@ -92,19 +92,12 @@ expect(page).to have_content('Walk in or apply by phone or mail') end - # Wait time not included in the view. - # Till we have a consistent meaning for wait time - # it's best left out of the front-end view - xit 'includes wait info' do + it 'includes wait estimate info' do expect(page).to have_content('No wait to 2 weeks') end - # Service areas not included in view. - # Best to leave this out of the view, this is data that could easily be - # wrong and it's better that the client contact the agency and ask for - # services and be referred accordingly vs. going off this list. - xit 'includes service areas' do - expect(page).to have_content('Marin County') + it 'includes service areas info' do + expect(page).to have_content('San Mateo County') end it 'includes updated time' do @@ -121,8 +114,27 @@ end end - it 'includes URLs' do - expect(page).to have_link('www.smchealth.org') + it 'includes short description' do + within '.short-desc' do + expect(page). + to have_content('[NOTE THIS IS NOT A REAL ENTRY--') + end + end + + it 'includes description' do + expect(page).to have_content('Lorem ipsum') + end + + it 'includes transporation info' do + expect(page).to have_content('SAMTRANS stops within 1 block') + end + + it 'includes hours info' do + expect(page).to have_content('Monday-Friday, 8-5; Saturday, 10-6;') + end + + it 'includes languages info' do + expect(page).to have_content('Chinese (Cantonese)') end it 'includes accessibility info' do @@ -138,36 +150,26 @@ expect(page).to have_link('sanmaceo@co.sanmaceo.ca.us') end - it 'includes hours info' do - expect(page).to have_content('Monday-Friday, 8-5; Saturday, 10-6;') + it 'includes URLs' do + expect(page).to have_link('www.smchealth.org') end - it 'includes languages info' do - expect(page).to have_content('Chinese (Cantonese)') + it 'includes Physical Address info' do + expect(page).to have_content('Avenue of the fellows') end it 'includes Mailing Address info' do expect(page).to have_content('Hella Fellas') end - it 'includes description' do - expect(page).to have_content('Lorem ipsum') - end - - it 'includes short description' do - within '.short-desc' do - expect(page). - to have_content('[NOTE THIS IS NOT A REAL ENTRY--') - end - end - - it 'includes transporation info' do - expect(page).to have_content('SAMTRANS stops within 1 block') + it 'includes keywords' do + expect(page).to have_link('Ruby on Rails/MongoDB/Redis') end it 'sets the page title to the location name + site title' do expect(page).to have_title('San Maceo Agency | Ohana Web Search') end + end describe 'Edit link' do From 1a7a41c8ff3c3827c1ad08de591b6a3e5b044d63 Mon Sep 17 00:00:00 2001 From: Moncef Belyamani Date: Wed, 30 Jul 2014 09:24:24 -0400 Subject: [PATCH 2/2] Use separate partials for each Service field. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Localize field headers - The service areas field was being shown for each service area, but the value was an aggregation of all the service areas across all services, instead of showing each service’s service areas separately. --- app/controllers/organizations_controller.rb | 1 - .../component/detail/_service_areas.html.haml | 8 ++---- .../detail/_service_audience.html.haml | 5 ++++ .../detail/_service_description.html.haml | 5 ++++ .../detail/_service_eligibility.html.haml | 5 ++++ .../component/detail/_service_fees.html.haml | 5 ++++ .../detail/_service_how_to_apply.html.haml | 5 ++++ .../detail/_service_keywords.html.haml | 9 ++++++ .../component/detail/_service_name.html.haml | 4 +++ .../component/detail/_service_urls.html.haml | 10 +++++++ .../component/detail/_service_wait.html.haml | 5 ++++ app/views/component/detail/_urls.html.haml | 14 ---------- .../organizations/detail/_body.html.haml | 28 +++++++------------ config/locales/en.yml | 15 ++++++++++ 14 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 app/views/component/detail/_service_audience.html.haml create mode 100644 app/views/component/detail/_service_description.html.haml create mode 100644 app/views/component/detail/_service_eligibility.html.haml create mode 100644 app/views/component/detail/_service_fees.html.haml create mode 100644 app/views/component/detail/_service_how_to_apply.html.haml create mode 100644 app/views/component/detail/_service_keywords.html.haml create mode 100644 app/views/component/detail/_service_name.html.haml create mode 100644 app/views/component/detail/_service_urls.html.haml create mode 100644 app/views/component/detail/_service_wait.html.haml delete mode 100644 app/views/component/detail/_urls.html.haml diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index fa1a2a5fa..779745dcb 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -75,7 +75,6 @@ def show if @org[:services].present? @categories = @org.services.map { |s| s[:categories] }.flatten.compact @keywords = @org.services.map { |s| s[:keywords] }.flatten.compact.uniq - @service_areas = @org.services.map { |s| s[:service_areas] }.flatten.compact.uniq end # To disable or remove the Result list button on details page diff --git a/app/views/component/detail/_service_areas.html.haml b/app/views/component/detail/_service_areas.html.haml index b9786ec9e..ec3b0e971 100644 --- a/app/views/component/detail/_service_areas.html.haml +++ b/app/views/component/detail/_service_areas.html.haml @@ -1,10 +1,8 @@ -- if @service_areas.present? +- if service[:service_areas].present? %section{ class: 'service-areas' } - - if defined? stitle - - if stitle.present? - %h1 #{stitle}: + %h1= t('service_fields.service_areas') %ul - - @service_areas.sort.each do |f| + - service.service_areas.sort.each do |f| %li %span = f diff --git a/app/views/component/detail/_service_audience.html.haml b/app/views/component/detail/_service_audience.html.haml new file mode 100644 index 000000000..9a54a6a90 --- /dev/null +++ b/app/views/component/detail/_service_audience.html.haml @@ -0,0 +1,5 @@ +- if service[:audience].present? + %section{ class: 'audience' } + %h1= t('service_fields.audience') + %span + = service.audience \ No newline at end of file diff --git a/app/views/component/detail/_service_description.html.haml b/app/views/component/detail/_service_description.html.haml new file mode 100644 index 000000000..e8f7c5096 --- /dev/null +++ b/app/views/component/detail/_service_description.html.haml @@ -0,0 +1,5 @@ +- if service[:description].present? + %section{ class: 'description' } + %h1= t('service_fields.description') + %span + = service.description \ No newline at end of file diff --git a/app/views/component/detail/_service_eligibility.html.haml b/app/views/component/detail/_service_eligibility.html.haml new file mode 100644 index 000000000..383f0738c --- /dev/null +++ b/app/views/component/detail/_service_eligibility.html.haml @@ -0,0 +1,5 @@ +- if service[:eligibility].present? + %section{ class: 'eligibility' } + %h1= t('service_fields.eligibility') + %span + = service.eligibility \ No newline at end of file diff --git a/app/views/component/detail/_service_fees.html.haml b/app/views/component/detail/_service_fees.html.haml new file mode 100644 index 000000000..cc88ea114 --- /dev/null +++ b/app/views/component/detail/_service_fees.html.haml @@ -0,0 +1,5 @@ +- if service[:fees].present? + %section{ class: 'fees' } + %h1= t('service_fields.fees') + %span + = service.fees \ No newline at end of file diff --git a/app/views/component/detail/_service_how_to_apply.html.haml b/app/views/component/detail/_service_how_to_apply.html.haml new file mode 100644 index 000000000..789a1d2b6 --- /dev/null +++ b/app/views/component/detail/_service_how_to_apply.html.haml @@ -0,0 +1,5 @@ +- if service[:how_to_apply].present? + %section{ class: 'how-to-apply' } + %h1= t('service_fields.how_to_apply') + %span + = service.how_to_apply \ No newline at end of file diff --git a/app/views/component/detail/_service_keywords.html.haml b/app/views/component/detail/_service_keywords.html.haml new file mode 100644 index 000000000..597aa0229 --- /dev/null +++ b/app/views/component/detail/_service_keywords.html.haml @@ -0,0 +1,9 @@ +- if @keywords.present? + %section#keywords-box + %h1= t('service_fields.keywords') + %section.keywords + %ul + - @keywords.each do |keyword| + %li + %span + = link_to keyword, organizations_path(request.query_parameters.merge(keyword: keyword)) \ No newline at end of file diff --git a/app/views/component/detail/_service_name.html.haml b/app/views/component/detail/_service_name.html.haml new file mode 100644 index 000000000..660de204f --- /dev/null +++ b/app/views/component/detail/_service_name.html.haml @@ -0,0 +1,4 @@ +- if service[:name].present? + %section{ class: 'name' } + %span + = service.name \ No newline at end of file diff --git a/app/views/component/detail/_service_urls.html.haml b/app/views/component/detail/_service_urls.html.haml new file mode 100644 index 000000000..027f9fd3b --- /dev/null +++ b/app/views/component/detail/_service_urls.html.haml @@ -0,0 +1,10 @@ +- if service[:urls].present? + %section{ class: 'urls' } + %h1= t('service_fields.urls') + %ul + - service.urls.sort.each do |url| + %li + %span + %a{ href: url, target: '_blank' } + %span{ itemprop: 'url' } + = format_url(url) \ No newline at end of file diff --git a/app/views/component/detail/_service_wait.html.haml b/app/views/component/detail/_service_wait.html.haml new file mode 100644 index 000000000..13f61977a --- /dev/null +++ b/app/views/component/detail/_service_wait.html.haml @@ -0,0 +1,5 @@ +- if service[:wait].present? + %section{ class: 'wait' } + %h1= t('service_fields.wait') + %span + = service.wait \ No newline at end of file diff --git a/app/views/component/detail/_urls.html.haml b/app/views/component/detail/_urls.html.haml deleted file mode 100644 index b50c7738f..000000000 --- a/app/views/component/detail/_urls.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- if org[:urls].present? - %section{ class: 'urls' } - - if defined? iconclass - %i{ class: iconclass } - - if defined? stitle - - if stitle.present? - %h1 #{stitle}: - %ul - - org.urls.sort.each do |url| - %li - %span - %a{ href: url, target: '_blank' } - %span{ itemprop: 'url' } - = format_url(url) \ No newline at end of file diff --git a/app/views/component/organizations/detail/_body.html.haml b/app/views/component/organizations/detail/_body.html.haml index e3dac6f45..a4cb377f5 100644 --- a/app/views/component/organizations/detail/_body.html.haml +++ b/app/views/component/organizations/detail/_body.html.haml @@ -110,15 +110,7 @@ = link_to category.name, organizations_path(@search_params.merge(category: category.name)) = category.name - - if @keywords.present? - %section#keywords-box - %h1 Keyword Tags - %section.keywords - %ul - - @keywords.each do |keyword| - %li - %span - = link_to keyword, organizations_path(@search_params.merge(keyword: keyword)) + = render 'component/detail/service_keywords' / Main detail content. %section @@ -176,15 +168,15 @@ %section.service{ itemscope: '', itemtype: 'http://schema.org/Service' } - = render partial: 'component/detail/template', locals: { org: service, field: :name} - = render partial: 'component/detail/template', locals: { org: service, field: :description, stitle: 'Service Description'} - = render partial: 'component/detail/urls', locals: { org: service, field: :urls, stitle: 'Homepage' } - = render partial: 'component/detail/template', locals: { org: service, field: :fees, stitle: 'Fees' } - = render partial: 'component/detail/template', locals: { org: service, field: :audience, stitle: 'Audience' } - = render partial: 'component/detail/template', locals: { org: service, field: :eligibility, stitle: 'Eligibility' } - = render partial: 'component/detail/template', locals: { org: service, field: :how_to_apply, stitle: 'How to Apply' } - = render partial: 'component/detail/template', locals: { org: service, field: :wait, stitle: 'Service Wait Estimate' } - = render partial: 'component/detail/service_areas', locals: { org: service, field: :service_areas, stitle: 'Service Areas' } + = render 'component/detail/service_name', service: service + = render 'component/detail/service_description', service: service + = render 'component/detail/service_urls', service: service + = render 'component/detail/service_fees', service: service + = render 'component/detail/service_audience', service: service + = render 'component/detail/service_eligibility', service: service + = render 'component/detail/service_how_to_apply', service: service + = render 'component/detail/service_wait', service: service + = render 'component/detail/service_areas', service: service / Detail footer content. - if @org[:updated_at].present? diff --git a/config/locales/en.yml b/config/locales/en.yml index 91635ee10..245bebf62 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,7 @@ en: homepage_search: 'Search' services_near_me: 'Services near me' update_search_results: 'Update search results' + helpers: page_entries_info: one_page: @@ -35,15 +36,29 @@ en: other: "Displaying all %{count} %{entry_name}" more_pages: display_entries: "Displaying %{first} - %{last} of %{total} %{entry_name}" + labels: address_search: 'Address search' agency_search: 'Organization name search' homepage_search: 'I need...' + placeholders: address_search: 'address or ZIP code' agency_search: 'full or partial name...' homepage_keyword_search: 'what are you looking for?' results_page_keyword_search: 'search for...' + + service_fields: + audience: 'Audience:' + description: 'Service Description:' + eligibility: 'Eligibility:' + fees: 'Fees:' + how_to_apply: 'How to Apply:' + keywords: 'Keyword Tags' + service_areas: 'Service Areas:' + urls: 'Homepage:' + wait: 'Service Wait Estimate:' + views: pagination: first: "« First"