Skip to content

Commit

Permalink
Use separate partials for each Service field.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
monfresh committed Jul 30, 2014
1 parent 2de827e commit 1a7a41c
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 38 deletions.
1 change: 0 additions & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions app/views/component/detail/_service_areas.html.haml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_audience.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if service[:audience].present?
%section{ class: 'audience' }
%h1= t('service_fields.audience')
%span
= service.audience
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_description.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if service[:description].present?
%section{ class: 'description' }
%h1= t('service_fields.description')
%span
= service.description
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_eligibility.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if service[:eligibility].present?
%section{ class: 'eligibility' }
%h1= t('service_fields.eligibility')
%span
= service.eligibility
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_fees.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if service[:fees].present?
%section{ class: 'fees' }
%h1= t('service_fields.fees')
%span
= service.fees
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_how_to_apply.html.haml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions app/views/component/detail/_service_keywords.html.haml
Original file line number Diff line number Diff line change
@@ -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))
4 changes: 4 additions & 0 deletions app/views/component/detail/_service_name.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- if service[:name].present?
%section{ class: 'name' }
%span
= service.name
10 changes: 10 additions & 0 deletions app/views/component/detail/_service_urls.html.haml
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions app/views/component/detail/_service_wait.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if service[:wait].present?
%section{ class: 'wait' }
%h1= t('service_fields.wait')
%span
= service.wait
14 changes: 0 additions & 14 deletions app/views/component/detail/_urls.html.haml

This file was deleted.

28 changes: 10 additions & 18 deletions app/views/component/organizations/detail/_body.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down
15 changes: 15 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -35,15 +36,29 @@ en:
other: "Displaying <strong>all %{count}</strong> %{entry_name}"
more_pages:
display_entries: "Displaying <strong>%{first} - %{last}</strong> of <strong>%{total}</strong> %{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: "&laquo; First"
Expand Down

0 comments on commit 1a7a41c

Please sign in to comment.