Add show-all-checkins route
This commit is contained in:
parent
6563a4b5e2
commit
f269b2cd8c
2 changed files with 30 additions and 7 deletions
|
@ -20,6 +20,9 @@
|
|||
<h1 class="page-title">@if ($trip->is_active) Where in the World is Ben? @else {{ $trip->name }} @endif</h1>
|
||||
<nav class="other-links">
|
||||
<ul>
|
||||
@if (!$trip->is_active)
|
||||
<li><p><a href="/">Current trip</a></p></li>
|
||||
@endif
|
||||
<li><p><a href="/past-trips">Past trips</a></p></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -41,7 +44,13 @@
|
|||
</section>
|
||||
<section id="checkinList">
|
||||
<ol start="{{ count($trip->checkins) }}" reversed>
|
||||
@foreach(array_slice(array_reverse($trip->checkins), 0, 15) as $checkin)
|
||||
@if($showAllCheckins)
|
||||
@php $checkinsList = array_reverse($trip->checkins) @endphp
|
||||
@else
|
||||
@php $checkinsList = array_slice(array_reverse($trip->checkins), 0, 10) @endphp
|
||||
@endif
|
||||
|
||||
@foreach($checkinsList as $checkin)
|
||||
<li>
|
||||
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
|
||||
<summary class="checkin__summary">
|
||||
|
@ -56,6 +65,9 @@
|
|||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@if ($trip->is_active)
|
||||
<p><a id="allCheckinsLink" href="#">Show all checkins</a></p>
|
||||
@endif
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
@ -100,11 +112,17 @@
|
|||
* (to help provide context).
|
||||
*/
|
||||
map.fitBounds([
|
||||
@foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location)
|
||||
@if ($trip->is_active)
|
||||
@foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location)
|
||||
[{{ $location->latitude }}, {{$location->longitude }}],
|
||||
@endforeach
|
||||
@endforeach
|
||||
@else
|
||||
@foreach($trip->locations as $location)
|
||||
[{{ $location->latitude }}, {{$location->longitude }}],
|
||||
@endforeach
|
||||
@endif
|
||||
]);
|
||||
map.zoomOut(2);
|
||||
@if ($trip->is_active) map.zoomOut(2.5); @endif
|
||||
|
||||
/*
|
||||
* Add the current location marker.
|
||||
|
@ -123,6 +141,11 @@
|
|||
).addTo(map).setZIndexOffset(1000);
|
||||
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
||||
|
||||
/*
|
||||
* Add all checkins link href.
|
||||
*/
|
||||
document.getElementById("allCheckinsLink").href = window.location.pathname + '/all';
|
||||
|
||||
/*
|
||||
* Changes the currently-selected popup.
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ Route::get('/past-trips', function () {
|
|||
return view('past-trips');
|
||||
});
|
||||
|
||||
Route::get('/{tripId?}', function ($tripId = null) {
|
||||
Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) {
|
||||
if (!$tripId && !config('app.current_trip_id')) return view('no-trip');
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,7 @@ Route::get('/{tripId?}', function ($tripId = null) {
|
|||
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
||||
$now = new DateTime();
|
||||
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) {
|
||||
return view('tracker', ['trip' => $cachedData->trip]);
|
||||
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ Route::get('/{tripId?}', function ($tripId = null) {
|
|||
}
|
||||
}
|
||||
|
||||
return view('tracker', ['trip' => $data->trip]);
|
||||
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
||||
} else {
|
||||
return 'Something went wrong';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue