|
6 | 6 | import AccordionItem from '$components/containers/AccordionItem.svelte';
|
7 | 7 | import SurveyModal from '$components/surveys/SurveyModal.svelte';
|
8 | 8 | import ServiceAlerts from '$components/service-alerts/ServiceAlerts.svelte';
|
| 9 | + import OpenStreetMap from './OpenStreetMap.svelte'; // Import the new component |
9 | 10 | import { onDestroy } from 'svelte';
|
10 | 11 | import '$lib/i18n.js';
|
11 | 12 | import { isLoading, t } from 'svelte-i18n';
|
|
41 | 42 |
|
42 | 43 | let abortController = null;
|
43 | 44 | async function loadData(stopID) {
|
44 |
| - // Cancel the previous request if it exists |
| 45 | + |
45 | 46 | if (abortController) {
|
46 | 47 | abortController.abort();
|
47 | 48 | }
|
|
126 | 127 | return;
|
127 | 128 | }
|
128 | 129 |
|
129 |
| - // If there are more questions, show the modal |
| 130 | + |
130 | 131 | if (remainingSurveyQuestions.length > 0) {
|
131 | 132 | showSurveyModal.set(true);
|
132 | 133 | }
|
|
167 | 168 | });
|
168 | 169 | </script>
|
169 | 170 |
|
170 |
| -{#if $isLoading} |
171 |
| - <p>Loading...</p> |
172 |
| -{:else} |
173 |
| - <div> |
174 |
| - {#if loading && isLoading && tripSelected} |
175 |
| - <LoadingSpinner /> |
176 |
| - {/if} |
177 |
| -
|
178 |
| - {#if error} |
179 |
| - <p>{error}</p> |
180 |
| - {/if} |
181 |
| - {#if arrivalsAndDepartures} |
182 |
| - <div class="space-y-4"> |
183 |
| - <div> |
184 |
| - <div |
185 |
| - class="relative flex flex-col gap-y-1 rounded-lg bg-brand-secondary bg-opacity-80 p-4" |
186 |
| - > |
187 |
| - <h1 class="h1 mb-0 text-white">{stop.name}</h1> |
188 |
| - <h2 class="h2 mb-0 text-white">{$t('stop')} #{stop.id}</h2> |
189 |
| - {#if routeShortNames()} |
190 |
| - <h2 class="h2 mb-0 text-white">{$t('routes')}: {routeShortNames().join(', ')}</h2> |
191 |
| - {/if} |
| 171 | +<div class="flex h-[700px] w-full flex-col overflow-hidden"> |
| 172 | + {#if $isLoading} |
| 173 | + <p>Loading...</p> |
| 174 | + {:else} |
| 175 | + <div class="scrollbar-none flex-1 overflow-auto"> |
| 176 | + {#if loading && isLoading && tripSelected} |
| 177 | + <LoadingSpinner /> |
| 178 | + {/if} |
| 179 | +
|
| 180 | + {#if error} |
| 181 | + <p>{error}</p> |
| 182 | + {/if} |
| 183 | + {#if arrivalsAndDepartures} |
| 184 | + <div class="space-y-4"> |
| 185 | + <div class="relative rounded-md"> |
| 186 | + |
| 187 | + <OpenStreetMap lat={stop.lat} lon={stop.lon} name={stop.name} /> |
192 | 188 |
|
193 |
| - {#if tripSelected} |
194 |
| - <div class="mt-auto flex justify-end"> |
| 189 | + {#if !tripSelected} |
| 190 | + <div class="absolute right-2 top-2"> |
195 | 191 | <a
|
196 | 192 | href={`/stops/${stop.id}/schedule`}
|
197 | 193 | class="inline-block rounded-lg border border-brand bg-brand px-3 py-1 text-sm font-medium text-white shadow-md transition duration-200 ease-in-out hover:bg-brand-secondary"
|
|
202 | 198 | </div>
|
203 | 199 | {/if}
|
204 | 200 | </div>
|
205 |
| - </div> |
| 201 | + <div> |
| 202 | + <div |
| 203 | + class="relative flex flex-col gap-y-1 rounded-lg bg-brand-secondary bg-opacity-80 p-4" |
| 204 | + > |
| 205 | + <h1 class="h1 mb-0 text-white">{stop.name}</h1> |
206 | 206 |
|
207 |
| - {#if serviceAlerts} |
208 |
| - <ServiceAlerts bind:serviceAlerts /> |
209 |
| - {/if} |
210 |
| -
|
211 |
| - {#if showHeroQuestion && currentStopSurvey} |
212 |
| - <HeroQuestion |
213 |
| - {currentStopSurvey} |
214 |
| - {handleSkip} |
215 |
| - {handleSurveyButtonClick} |
216 |
| - {handleHeroQuestionChange} |
217 |
| - remainingQuestionsLength={remainingSurveyQuestions.length} |
218 |
| - /> |
219 |
| - {/if} |
220 |
| - {#if nextSurveyQuestion} |
221 |
| - <SurveyModal |
222 |
| - currentSurvey={currentStopSurvey} |
223 |
| - {stop} |
224 |
| - skipHeroQuestion={true} |
225 |
| - surveyPublicId={surveyPublicIdentifier} |
226 |
| - /> |
227 |
| - {/if} |
228 |
| -
|
229 |
| - {#if arrivalsAndDepartures.arrivalsAndDepartures.length === 0} |
230 |
| - <div class="flex items-center justify-center"> |
231 |
| - <p>{$t('no_arrivals_or_departures_in_next_30_minutes')}</p> |
| 207 | + <h2 class="h2 mb-0 text-white">{$t('stop')} #{stop.id}</h2> |
| 208 | + {#if routeShortNames()} |
| 209 | + <h2 class="h2 mb-0 text-white">{$t('routes')}: {routeShortNames().join(', ')}</h2> |
| 210 | + {/if} |
| 211 | +
|
| 212 | + {#if tripSelected} |
| 213 | + <div class="mt-auto flex justify-end"> |
| 214 | + <a |
| 215 | + href={`/stops/${stop.id}/schedule`} |
| 216 | + class="inline-block rounded-lg border border-brand bg-brand px-3 py-1 text-sm font-medium text-white shadow-md transition duration-200 ease-in-out hover:bg-brand-secondary" |
| 217 | + target="_blank" |
| 218 | + > |
| 219 | + {$t('schedule_for_stop.view_schedule')} |
| 220 | + </a> |
| 221 | + </div> |
| 222 | + {/if} |
| 223 | + </div> |
232 | 224 | </div>
|
233 |
| - {:else} |
234 |
| - {#key arrivalsAndDepartures.stopId} |
235 |
| - <Accordion {handleAccordionSelectionChanged}> |
236 |
| - {#each arrivalsAndDepartures.arrivalsAndDepartures as arrival} |
237 |
| - <AccordionItem data={arrival}> |
238 |
| - {#snippet header()} |
239 |
| - <span> |
240 |
| - <ArrivalDeparture arrivalDeparture={arrival} /> |
241 |
| - </span> |
242 |
| - {/snippet} |
243 |
| - <TripDetailsPane |
244 |
| - {stop} |
245 |
| - tripId={arrival.tripId} |
246 |
| - serviceDate={arrival.serviceDate} |
247 |
| - /> |
248 |
| - </AccordionItem> |
249 |
| - {/each} |
250 |
| - </Accordion> |
251 |
| - {/key} |
252 |
| - {/if} |
253 |
| - </div> |
254 |
| - {/if} |
255 |
| - </div> |
256 |
| -{/if} |
| 225 | +
|
| 226 | + {#if serviceAlerts} |
| 227 | + <ServiceAlerts bind:serviceAlerts /> |
| 228 | + {/if} |
| 229 | +
|
| 230 | + {#if showHeroQuestion && currentStopSurvey} |
| 231 | + <HeroQuestion |
| 232 | + {currentStopSurvey} |
| 233 | + {handleSkip} |
| 234 | + {handleSurveyButtonClick} |
| 235 | + {handleHeroQuestionChange} |
| 236 | + remainingQuestionsLength={remainingSurveyQuestions.length} |
| 237 | + /> |
| 238 | + {/if} |
| 239 | + {#if nextSurveyQuestion} |
| 240 | + <SurveyModal |
| 241 | + currentSurvey={currentStopSurvey} |
| 242 | + {stop} |
| 243 | + skipHeroQuestion={true} |
| 244 | + surveyPublicId={surveyPublicIdentifier} |
| 245 | + /> |
| 246 | + {/if} |
| 247 | +
|
| 248 | + {#if arrivalsAndDepartures.arrivalsAndDepartures.length === 0} |
| 249 | + <div class="flex items-center justify-center"> |
| 250 | + <p>{$t('no_arrivals_or_departures_in_next_30_minutes')}</p> |
| 251 | + </div> |
| 252 | + {:else} |
| 253 | + {#key arrivalsAndDepartures.stopId} |
| 254 | + <Accordion {handleAccordionSelectionChanged}> |
| 255 | + {#each arrivalsAndDepartures.arrivalsAndDepartures as arrival} |
| 256 | + <AccordionItem data={arrival}> |
| 257 | + {#snippet header()} |
| 258 | + <span> |
| 259 | + <ArrivalDeparture arrivalDeparture={arrival} /> |
| 260 | + </span> |
| 261 | + {/snippet} |
| 262 | + <TripDetailsPane |
| 263 | + {stop} |
| 264 | + tripId={arrival.tripId} |
| 265 | + serviceDate={arrival.serviceDate} |
| 266 | + /> |
| 267 | + </AccordionItem> |
| 268 | + {/each} |
| 269 | + </Accordion> |
| 270 | + {/key} |
| 271 | + {/if} |
| 272 | + </div> |
| 273 | + {/if} |
| 274 | + </div> |
| 275 | + {/if} |
| 276 | +</div> |
| 277 | +
|
| 278 | +<style> |
| 279 | + /* Hide scrollbar for Chrome, Safari and Opera */ |
| 280 | + .scrollbar-none::-webkit-scrollbar { |
| 281 | + display: none; |
| 282 | + } |
| 283 | +
|
| 284 | + /* Hide scrollbar for IE, Edge and Firefox */ |
| 285 | + .scrollbar-none { |
| 286 | + -ms-overflow-style: none; /* IE and Edge */ |
| 287 | + scrollbar-width: none; /* Firefox */ |
| 288 | + } |
| 289 | +</style> |
0 commit comments