Skip to content

Commit

Permalink
Fixes #44 - adds contact field
Browse files Browse the repository at this point in the history
Adds contacts field and performs syncing update with
codeforamerica#541
  • Loading branch information
anselmbradford committed Aug 2, 2014
1 parent c507827 commit 063ec65
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 73 deletions.
24 changes: 24 additions & 0 deletions app/assets/stylesheets/_base.scss.erb
Expand Up @@ -2119,6 +2119,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 @@ -2149,6 +2159,20 @@ 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: darkest($purple);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/detail_format_helper.rb
Expand Up @@ -24,14 +24,14 @@ def market_fields

# List of fields that determine whether or not to show the
# Aside section in the details view
def contact_details
[:ask_for,:phones,:faxes,:emails,:urls,:address]
def location_contact_details
[:phones, :faxes, :emails, :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
[:ask_for,:phones,:faxes,:emails]
def location_contact_fields
[:urls, :emails, :phones, :faxes]
end

# Formats address for use in map URLs, image title attributes, etc.
Expand Down
154 changes: 89 additions & 65 deletions app/views/component/organizations/detail/_body.html.haml
Expand Up @@ -20,82 +20,106 @@
= superscript_ordinals(@org.organization.name)

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

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

- if @org.key?(:ask_for)
%section.ask-for{:itemscope=>"", :itemtype=>"http://schema.org/ContactPoint"}
- @org.ask_for.each do |ask_for|
- if @org.key?(:urls)
%section.urls
- @org['urls'].each do |url|
%div
%i{:class=>"fa fa-user"}
%span
= ask_for
%i{ class: 'fa fa-external-link-square' }
%a{ href: url, target: '_blank' }
%span{ itemprop: 'url' }
= format_url(url)

- if @org.key?(:emails)
%section.emails{:itemprop=>"email"}
- @org.emails.each do |email|
- if @org.key?(:emails)
%section.emails{:itemprop=>"email"}
- @org['emails'].each do |email|
%div
%i{:class=>"fa fa-laptop"}
%a{:href=>("mailto:"+email)}
%span{:itemprop=>"email"}
= email


- if @org.key?(:phones)
%section.phones{ itemscope: '', itemtype: 'http://schema.org/ContactPoint' }
- @org['phones'].each do |phone|
%div
%i{ class: 'fa fa-phone-square' }
%span
- if phone['number']
%span{ itemprop: 'telephone' }
= 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.phone-department{ itemprop: 'contactType' }
= phone['department']

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

- if @org['contacts'].present?
- @org.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:"+email)}
%span{:itemprop=>"email"}
= email

%i{ class: 'fa fa-laptop' }
%a{ href: "mailto:#{contact.email}" }
%span{ itemprop: 'email' }
= contact['email']

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

- if @org.key?(:faxes)
%section.faxes
- @org.faxes.each do |fax|
- if contact['phone'].present?
%section.phones{ itemscope: '', itemtype: 'http://schema.org/ContactPoint' }
%div
%i{:class=>"fa fa-print fax"}
%i{ class: 'fa fa-phone-square' }
%span
- if fax.is_a?(String)
%span{:itemprop=>"faxNumber"}
= format_phone(fax)
- elsif fax.is_a?(Sawyer::Resource)
- if fax["number"]
%span{:itemprop=>"faxNumber"}
= format_phone(fax["number"])
- if fax["department"]
%p
%span{:itemprop=>"contactType"}
= fax["department"]

- if @org.key?(:urls)
%section.urls-box
%h1 Homepage
%section

- if @org.key?(:urls)
%section.urls
- @org.urls.each do |url|
%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-external-link-square"}
%a{:href=>url,:target=>"_blank"}
%span{:itemprop=>"url"}
= format_url(url)
%i{ class: 'fa fa-print fax' }
%span{ itemprop: 'faxNumber' }

- if @org.key?(:mail_address)
%section.address-box
Expand All @@ -104,8 +128,8 @@

%section.mail-address
%div
%i{:class=>"fa fa-envelope"}
= render :partial => "component/detail/mail_address", :locals => {:org=>@org,:lines=>2}
%i{ class: 'fa fa-envelope' }
= render partial: 'component/detail/mail_address', locals: { org: @org, lines: 2 }

-# has a physical address and the street address and zipcode differ from mailing address
- if @org.key?(:address) && !(@org.key?(:mail_address) && (@org.address.street == @org.mail_address.street && @org.address.zip == @org.mail_address.zip))
Expand Down
11 changes: 7 additions & 4 deletions spec/features/details/location_details_spec.rb
Expand Up @@ -44,7 +44,7 @@
end

it "includes the Contact header" do
expect(page).to have_content("Contact")
expect(page).to have_content("General Contact Info")
end

it "includes the department and phone type" do
Expand Down Expand Up @@ -124,9 +124,12 @@
expect(page).to have_content("Disabled Parking")
end

# Contact is not included with view because we have an ask_for field already
xit "includes Contact info" do
expect(page).to have_content("Suzanne Badenhoop")
it 'includes contact name' do
expect(page).to have_content('Suzanne Badenhoop')
end

it 'includes contact title' do
expect(page).to have_content('Board President')
end

it "includes email info" do
Expand Down

0 comments on commit 063ec65

Please sign in to comment.