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>
|
<h1 class="page-title">@if ($trip->is_active) Where in the World is Ben? @else {{ $trip->name }} @endif</h1>
|
||||||
<nav class="other-links">
|
<nav class="other-links">
|
||||||
<ul>
|
<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>
|
<li><p><a href="/past-trips">Past trips</a></p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -41,7 +44,13 @@
|
||||||
</section>
|
</section>
|
||||||
<section id="checkinList">
|
<section id="checkinList">
|
||||||
<ol start="{{ count($trip->checkins) }}" reversed>
|
<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>
|
<li>
|
||||||
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
|
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
|
||||||
<summary class="checkin__summary">
|
<summary class="checkin__summary">
|
||||||
|
@ -56,6 +65,9 @@
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ol>
|
</ol>
|
||||||
|
@if ($trip->is_active)
|
||||||
|
<p><a id="allCheckinsLink" href="#">Show all checkins</a></p>
|
||||||
|
@endif
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
@ -100,11 +112,17 @@
|
||||||
* (to help provide context).
|
* (to help provide context).
|
||||||
*/
|
*/
|
||||||
map.fitBounds([
|
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 }}],
|
[{{ $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.
|
* Add the current location marker.
|
||||||
|
@ -123,6 +141,11 @@
|
||||||
).addTo(map).setZIndexOffset(1000);
|
).addTo(map).setZIndexOffset(1000);
|
||||||
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
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.
|
* Changes the currently-selected popup.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ Route::get('/past-trips', function () {
|
||||||
return view('past-trips');
|
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');
|
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);
|
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) {
|
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 {
|
} else {
|
||||||
return 'Something went wrong';
|
return 'Something went wrong';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue