Skip to content

Commit

Permalink
Fixes #411 - adds contacts details
Browse files Browse the repository at this point in the history
- Adds contacts details section.
- Adds missing fax department field.
- Updates dynamic VCR cassettes.
- Changes @location[:field] syntax to @location.field syntax.
- Moves home pages to the top and includes in general contact field.
The contacts could be an arbitrary number long, so better to have the
home page consistent at the top.
- Adds contact title test and enables contact name test.
- Fixes #416 - adds padding between numbers with departments, also
makes departments a smaller size and different color.
  • Loading branch information
anselmbradford committed Aug 1, 2014
1 parent a645629 commit 46e018a
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 350 deletions.
25 changes: 25 additions & 0 deletions app/assets/stylesheets/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,16 @@ body { top: 0px !important; }
color: $black;
padding-bottom: 20px;

> div > span
{
padding-bottom: 20px;
}

> div:last-child > span
{
padding-bottom: 0;
}

> div
{
display: table-row;
Expand Down Expand Up @@ -1726,6 +1736,21 @@ body { top: 0px !important; }
padding-bottom: 0px;
}
}

.contact-name
{
padding-bottom: 0;
}

.contact-title,
.phone-department,
.fax-department
{
font-size: $font_size_95;
line-height: $font_size_95;
color: $complementA;
}

}

// Adjust margin of main content to fit aside.
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/detail_format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def service_fields

# List of fields that determine whether or not to show the
# Aside section in the details view
def contact_details
[:phones, :faxes, :emails, :urls, :address]
def location_contact_details
[:phones, :faxes, :urls, :address, :mail_address, :contacts]
end

# List of fields that determine whether or not to show the
# Contact section in the details view
def contact_fields
[:phones, :faxes, :emails]
[:name, :title, :phones, :extension, :fax, :email]
end

# Formats address for use in map URLs, image title attributes, etc.
Expand Down
113 changes: 79 additions & 34 deletions app/views/component/locations/detail/_body.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@
= superscript_ordinals(@location.organization.name)

/ detail sidebar content
- if (@location.fields & contact_details).any? || @location[:services].present?
- if (@location.fields & location_contact_details).any? || @location[:services].present?
%aside
- if (@location.fields & contact_details).any?
- if (@location.fields & location_contact_details).any?
%section#contact-info

- if (@location.fields & contact_fields).any?
%section.contact-box
%h1 Contact
%h1 General Contact Info
%section

- if @location[:emails].present?
- if @location.urls.present?
%section.urls
- @location.urls.each do |url|
%div
%i{ class: 'fa fa-external-link-square' }
%a{ href: url, target: '_blank' }
%span{ itemprop: 'url' }
= format_url(url)

- if @location.emails.present?
%section.emails{ itemprop: 'email' }
- @location.emails.each do |email|
%div
Expand All @@ -33,24 +42,26 @@
= email


- if @location[:phones].present?
- if @location.phones.present?
%section.phones{ itemscope: '', itemtype: 'http://schema.org/ContactPoint' }
- @location.phones.each do |phone|
%div
%i{ class: 'fa fa-phone-square' }
%span
- if phone['number']
- if phone.number
%span{ itemprop: 'telephone' }
= format_phone(phone['number'])
- if phone['number_type']
= format_phone(phone.number)
- if phone.extension.present?
%sup.phone-extension
= phone.extension
- if phone.number_type
%sup.phone-type
= phone['number_type']
- if phone['department']
%p
%span{ itemprop: 'contactType' }
= phone['department']
= phone.number_type
- if phone.department
%p.phone-department{ itemprop: 'contactType' }
= phone.department

- if @location[:faxes].present?
- if @location.faxes.present?
%section.faxes
- @location.faxes.each do |fax|
%div
Expand All @@ -62,25 +73,59 @@
- elsif fax.is_a?(Sawyer::Resource)
- if fax["number"]
%span{ itemprop: 'faxNumber' }
= format_phone(fax['number'])
- if fax['department']
= format_phone(fax.number)
- if fax.department
%p.fax-department{ itemprop: 'contactType' }
= fax.department

- if @location.contacts.present? # && (@location[:contacts].fields & contact_fields).any?
- @location.contacts.each do |contact|
%section.contact-box
%h1 Specific Contact
%section
- if contact.name.present?
%section.contact-name
= contact.name
%section.contact-title
= contact.title

- if contact.email.present?
%section.emails{ itemprop: 'email' }
%div
%i{ class: 'fa fa-laptop' }
%a{ href: "mailto:#{contact.email}" }
%span{ itemprop: 'email' }
= contact.email

- if contact.phone.present?
%section.phones{ itemscope: '', itemtype: 'http://schema.org/ContactPoint' }
%div
%i{ class: 'fa fa-phone-square' }
%span
%span{ itemprop: 'telephone' }
= format_phone(contact.phone)
- if contact.extension.present?
%sup.phone-extension
= contact.extension

- if contact.fax.present?
%section.faxes
%div
%i{ class: 'fa fa-print fax' }
%span
- if contact.fax.is_a?(String)
%span{ itemprop: 'faxNumber' }
= format_phone(contact.fax)
- elsif fax.is_a?(Sawyer::Resource)
- if contact.fax.number
%span{ itemprop: 'faxNumber' }
= format_phone(contact.fax.number)
- if contact.fax.department
%p
%span{ itemprop: 'contactType' }
= fax['department']
%span.fax-department{ itemprop: 'contactType' }
= contact.fax.department

- if @location[:urls].present?
%section.urls-box
%h1 Homepage
%section
%section.urls
- @location.urls.each do |url|
%div
%i{ class: 'fa fa-external-link-square' }
%a{ href: url, target: '_blank' }
%span{ itemprop: 'url' }
= format_url(url)

- if @location[:address].present?
- if @location.address.present?
%section.address-box
%h1 Physical Address
%section
Expand All @@ -89,7 +134,7 @@
%i{ class: 'fa fa-map-marker' }
= render 'component/detail/address', location: @location, lines: 2

- if @location[:mail_address].present?
- if @location.mail_address.present?
%section.address-box
%h1 Mailing Address
%section
Expand All @@ -115,13 +160,13 @@
/ Main detail content.
%section

- if @location[:short_desc].present? || @location[:description].present?
- if @location.short_desc.present? || @location.description.present?
%section.overview-box
%section
= render 'component/detail/location_short_desc', location: @location
= render 'component/detail/location_description', location: @location

- if @location[:coordinates].present? || @location[:transportation].present?
- if @location.coordinates.present? || @location.transportation.present?
%section.map-box
%h1 Location

Expand Down
Loading

0 comments on commit 46e018a

Please sign in to comment.