Fix cases for Public LDB service detail where previousStops or subsequentStops is not an Array
This commit is contained in:
parent
6803438c63
commit
fe31a8a8d1
@ -104,7 +104,6 @@
|
||||
}
|
||||
|
||||
async function loadService(sid) {
|
||||
console.log(`Loading: ${sid}`);
|
||||
for (const service of services) {
|
||||
if (service.serviceID == sid) {
|
||||
serviceDetail = service
|
||||
@ -112,6 +111,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBusService(sid) {
|
||||
for (const service of busServices) {
|
||||
if (service.serviceID == sid) {
|
||||
serviceDetail = service
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function closeService() {
|
||||
serviceDetail = null;
|
||||
}
|
||||
@ -141,7 +148,7 @@
|
||||
</tr>
|
||||
{#each services as service}
|
||||
<tr>
|
||||
<td class="origdest from" on:click={loadService(service.serviceID)}>
|
||||
<td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
|
||||
{#if Array.isArray(service.origin?.location)}
|
||||
{service.origin.location[0]['locationName'] +
|
||||
" & " +
|
||||
@ -150,7 +157,7 @@
|
||||
{service.origin?.location?.locationName || ''}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="origdest to" on:click={loadService(service.serviceID)}>
|
||||
<td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
|
||||
{#if Array.isArray(service.destination?.location)}
|
||||
{service.destination.location[0]['locationName'] +
|
||||
" & " +
|
||||
@ -200,8 +207,8 @@
|
||||
</tr>
|
||||
{#each busServices as service}
|
||||
<tr>
|
||||
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="time">{parseTime(service.sta).data}</td>
|
||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||
<td class="time">{parseTime(service.std).data}</td>
|
||||
@ -272,13 +279,21 @@
|
||||
<th>Exp</th>
|
||||
</tr>
|
||||
{#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint}
|
||||
{#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint}
|
||||
{#if Array.isArray(serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint)}
|
||||
{#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint}
|
||||
<tr>
|
||||
<td>{prevPoint.locationName}</td>
|
||||
<td>{prevPoint.st}</td>
|
||||
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{:else}
|
||||
<tr>
|
||||
<td>{prevPoint.locationName}</td>
|
||||
<td>{prevPoint.st}</td>
|
||||
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td>
|
||||
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td>
|
||||
<td class="time {parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).changed}">{parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
<tr class="thisStop">
|
||||
<td>{title}</td>
|
||||
@ -286,13 +301,21 @@
|
||||
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
|
||||
</tr>
|
||||
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
|
||||
{#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint}
|
||||
{#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)}
|
||||
{#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint}
|
||||
<tr>
|
||||
<td>{nextPoint.locationName}</td>
|
||||
<td>{nextPoint.st}</td>
|
||||
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{:else}
|
||||
<tr>
|
||||
<td>{nextPoint.locationName}</td>
|
||||
<td>{nextPoint.st}</td>
|
||||
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
|
||||
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td>
|
||||
<td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}">{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
</table>
|
||||
</OverlayIsland>
|
||||
|
Loading…
Reference in New Issue
Block a user