Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KG - Add Primary Contact Information to Homepage When Not Logged In #2173

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions app/helpers/application_helper.rb
Expand Up @@ -44,21 +44,13 @@ def format_datetime(datetime, opts={})
end

def format_phone(phone)
if phone.present?
if phone.present? && phone.match(DataTypeValidator::PHONE_REGEXP)
phone.gsub!(/[^0-9#]/, '')

formatted = ""
begin
formatted += "(#{phone.first(3)})"
formatted += " #{phone.from(3).to(2)}"
formatted += "-#{phone.from(6).to(3)}"
formatted += phone.from(10).gsub('#', " #{I18n.t('constants.phone.extension')} ") if phone.include?('#')
rescue
end

return formatted
formatted = "(#{phone.first(3)}) #{phone.from(3).to(2)}-#{phone.from(6).to(3)}"
formatted += phone.from(10).gsub('#', " #{I18n.t('constants.phone.extension')} ") if phone.length > 10
else
return phone
""
end
end

Expand Down
34 changes: 34 additions & 0 deletions app/helpers/identities_helper.rb
@@ -0,0 +1,34 @@
# Copyright © 2011-2019 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

module IdentitiesHelper
def identity_contact(identity)
content_tag :div, class: 'w-100 d-flex flex-wrap' do
contact = content_tag(:span, icon('fas', 'user mr-1') + identity.full_name, class: 'w-100')
contact += content_tag(:span, icon('far', 'envelope mr-1') + link_to(identity.email, "mailto:#{identity.email}"))

if (phone = format_phone(identity.phone)).present?
contact += content_tag(:span, icon('fas', 'phone mr-1') + phone, class: 'ml-3')
end

raw(contact)
end
end
end
1 change: 1 addition & 0 deletions app/models/organization.rb
Expand Up @@ -33,6 +33,7 @@ class Organization < ApplicationRecord
has_many :forms, -> { active }, as: :surveyable, dependent: :destroy
has_many :super_users, :dependent => :destroy
has_many :service_providers, :dependent => :destroy
has_many :primary_contacts, -> { where(is_primary_contact: true) }, class_name: 'ServiceProvider'
has_many :catalog_managers, :dependent => :destroy
has_many :clinical_providers, :dependent => :destroy
has_many :patient_registrars, :dependent => :destroy
Expand Down
1 change: 1 addition & 0 deletions app/views/catalogs/_description.html.haml
Expand Up @@ -26,6 +26,7 @@
- if organization.description.present?
%p.description
= raw(organization.description)
= render 'catalogs/primary_contacts', organization: organization
- if organization.type == "Program"
- if organization.services.any?
= render 'catalogs/accordion/services', organization: organization, service_request: service_request
Expand Down
29 changes: 29 additions & 0 deletions app/views/catalogs/_primary_contacts.html.haml
@@ -0,0 +1,29 @@
-# Copyright © 2011-2019 MUSC Foundation for Research Development
-# All rights reserved.

-# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

-# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

-# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided with the distribution.

-# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.

-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- if organization.primary_contacts.any? && !identity_signed_in?
.d-flex.flex-wrap.mb-3
%span.font-weight-bold.w-100
= t('proper.catalog.service_provider_text')
.w-100
.row
- organization.primary_contacts.each do |pc|
.col-6
= identity_contact(pc.identity)
1 change: 1 addition & 0 deletions app/views/catalogs/accordion/_cores.html.haml
Expand Up @@ -32,4 +32,5 @@
- if c.description.present?
%p
= raw(c.description)
= render 'catalogs/primary_contacts', organization: c
= render 'catalogs/accordion/services', organization: c, service_request: service_request
1 change: 1 addition & 0 deletions config/locales/proper.en.yml
Expand Up @@ -55,6 +55,7 @@ en:
text: "Please contact %{contact_name} at %{contact_info} to make changes to the existing request."
services_missing:
header: "Add Services to Continue"
service_provider_text: "To learn more about these Services, please contact one of the Service Providers listed below:"

############
# PROTOCOL #
Expand Down