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

Show service area information on location lozenges #968

Merged
merged 5 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/stylesheets/base/turf.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.neighbourhood
.neighbourhood, .service-area
// padding-top: 0.5rem
span
margin-top: 0.8rem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<li class="preview">
<div class="preview__header">
<h3><%= link_to name, link %></h3>

<% if show_service_area? %>
<div class="service-area service-area--secondary preview__service-area">
<span><%= service_area_name %></span>
</div>
<% end %>

<% if show_neighbourhoods %>
<div class="neighbourhood <%= primary_neighbourhood? ? 'neighbourhood--primary' : 'neighbourhood--secondary' %> preview__neighbourhood">
<span><%= neighbourhood_name(badge_zoom_level) %></span>
</div>
<% end %>
</div>

<% if description %>
<div class="preview__details">
<%= content_tag :p, description %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# app/components/place/place_partner_preview_component.rb
class PlacePartnerPreviewComponent < MountainView::Presenter
properties :primary_neighbourhood, :previewee, :show_neighbourhoods, :badge_zoom_level
properties :primary_neighbourhood,
:previewee, :show_neighbourhoods, :badge_zoom_level, :service_areas

def name
previewee.name
Expand All @@ -28,6 +29,18 @@ def primary_neighbourhood?
primary_neighbourhood && (previewee.address&.neighbourhood == primary_neighbourhood)
end

def show_service_area?
service_areas.count > 0
end

def service_area_name
if previewee.service_areas.count > 1
"various areas"
else
previewee.service_areas.first&.neighbourhood&.shortname
end
end

private

def previewee
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<ul>
<% current_user.neighbourhoods.each do |neighbourhood| %>
<li>
<%= link_to neighbourhood.name, edit_admin_neighbourhood_path(neighbourhood) %>
<%= link_to neighbourhood.contextual_name, edit_admin_neighbourhood_path(neighbourhood) %>
</li>
<% end %>
</ul>
Expand Down
1 change: 1 addition & 0 deletions app/views/partners/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<%= render_component("place_partner_preview",
previewee: partner,
primary_neighbourhood: @primary_neighbourhood,
service_areas: partner.service_areas,
show_neighbourhoods: @current_site.show_neighbourhoods?,
badge_zoom_level: @current_site.badge_zoom_level) %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/admin/user_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AdminUserIntegrationTest < ActionDispatch::IntegrationTest
assert_select 'h3', text: 'Your neighbourhoods'
assert_select 'a[href=?]',
edit_admin_neighbourhood_path(@neighbourhood),
text: @neighbourhood.name
text: @neighbourhood.contextual_name
end

test "Profile form has correct fields for neighbourhood admin" do
Expand Down
22 changes: 22 additions & 0 deletions test/integration/partners_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,26 @@ class PartnersIntegrationTest < ActionDispatch::IntegrationTest
assert_select '.preview__header', text: @region_site_partners.first.name
assert_select '.preview__details', text: @region_site_partners.first.summary
end

test 'partner shows service area if available' do
partner = @default_site_partners.first
partner.service_areas.create! neighbourhood: @neighbourhood3

get partners_url
assert_response :success

assert_select '.service-area span', text: @neighbourhood3.shortname
end

test 'partner shows "various areas" if more than one service area present' do
partner = @default_site_partners.first
partner.service_areas.create! neighbourhood: @neighbourhood3
partner.service_areas.create! neighbourhood: @neighbourhood2

get partners_url
assert_response :success

assert_select '.service-area span', text: 'various areas'
end

end