Skip to content

Commit

Permalink
Show direction link next to the address on studio page.
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelJ committed Jul 28, 2020
1 parent bebc566 commit 987b467
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 88 deletions.
11 changes: 1 addition & 10 deletions app/views/account/bookings/show.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ <h3 class="text-sans-serif">
<hr>

<p class="address">

@tags.address(studio.location.address)<br>

@defining(studio.location.coordinates) { coords =>
<a
href="http://maps.google.com/maps?daddr=@coords.lat,@coords.long"
target="_blank">
Get directions
</a>
}
@tags.location(studio.location, showDirections = true)
</p>

<p>
Expand Down
4 changes: 1 addition & 3 deletions app/views/studios/show.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,14 @@ <h3 id="availability">Availability</h3>
<h3>Location</h3>

<p class="address">
@tags.address(studio.location.address)
@tags.location(studio.location, showDirections = true)
</p>

<location-map
:lat="@studio.location.coordinates.lat"
:long="@studio.location.coordinates.long"
:zoom="13">
</location-map>

<hr>
</div>
</div>

Expand Down
75 changes: 0 additions & 75 deletions app/views/tags/address.scala.html

This file was deleted.

89 changes: 89 additions & 0 deletions app/views/tags/location.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@* Noisycamp is a platform for booking music studios.
* Copyright (C) 2019 Raphael Javaux <raphaeljavaux@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Displays the location's address in the country's format.
*@

@import _root_.i18n.AddressFormat

@(location: Location, showDirections: Boolean = false)

@defining(location.address) { address =>
@address.country.addressFormat match {
case AddressFormat.American => {
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.city, @address.stateCode.get @address.zipcode.get<br>
@address.country.name
}
case AddressFormat.British => {
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.city<br>
@address.zipcode.get<br>
@address.country.name
}
case AddressFormat.English => {
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.city @for(stateCode <- address.stateCode) { stateCode } @address.zipcode.get<br>
@address.country.name
}
case AddressFormat.European => {
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.zipcode.get @address.city<br>
@address.country.name
}
case AddressFormat.HongKong => {
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.city<br>
@address.country.name
}
case AddressFormat.Hungarian => {
@address.city<br>
@address.address1<br>
@for(address2 <- address.address2) {
@address2<br>
}
@address.zipcode.get<br>
@address.country.name
}
}
}

@if(showDirections) {
<br>

@defining(location.coordinates) { coords =>
<a
href="http://maps.google.com/maps?daddr=@coords.lat,@coords.long"
target="_blank">
Get directions
</a>
}
}

0 comments on commit 987b467

Please sign in to comment.