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) {
|
async function loadService(sid) {
|
||||||
console.log(`Loading: ${sid}`);
|
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
if (service.serviceID == sid) {
|
if (service.serviceID == sid) {
|
||||||
serviceDetail = service
|
serviceDetail = service
|
||||||
@ -112,6 +111,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadBusService(sid) {
|
||||||
|
for (const service of busServices) {
|
||||||
|
if (service.serviceID == sid) {
|
||||||
|
serviceDetail = service
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function closeService() {
|
async function closeService() {
|
||||||
serviceDetail = null;
|
serviceDetail = null;
|
||||||
}
|
}
|
||||||
@ -141,7 +148,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{#each services as service}
|
{#each services as service}
|
||||||
<tr>
|
<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)}
|
{#if Array.isArray(service.origin?.location)}
|
||||||
{service.origin.location[0]['locationName'] +
|
{service.origin.location[0]['locationName'] +
|
||||||
" & " +
|
" & " +
|
||||||
@ -150,7 +157,7 @@
|
|||||||
{service.origin?.location?.locationName || ''}
|
{service.origin?.location?.locationName || ''}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</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)}
|
{#if Array.isArray(service.destination?.location)}
|
||||||
{service.destination.location[0]['locationName'] +
|
{service.destination.location[0]['locationName'] +
|
||||||
" & " +
|
" & " +
|
||||||
@ -200,8 +207,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{#each busServices as service}
|
{#each busServices as service}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="origdest from">{service.origin?.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">{service.destination?.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.sta).data}</td>
|
||||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||||
<td class="time">{parseTime(service.std).data}</td>
|
<td class="time">{parseTime(service.std).data}</td>
|
||||||
@ -272,13 +279,21 @@
|
|||||||
<th>Exp</th>
|
<th>Exp</th>
|
||||||
</tr>
|
</tr>
|
||||||
{#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint}
|
{#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>
|
<tr>
|
||||||
<td>{prevPoint.locationName}</td>
|
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||||
<td>{prevPoint.st}</td>
|
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td>
|
||||||
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</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>
|
</tr>
|
||||||
{/each}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<tr class="thisStop">
|
<tr class="thisStop">
|
||||||
<td>{title}</td>
|
<td>{title}</td>
|
||||||
@ -286,13 +301,21 @@
|
|||||||
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
|
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
|
{#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>
|
<tr>
|
||||||
<td>{nextPoint.locationName}</td>
|
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||||
<td>{nextPoint.st}</td>
|
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td>
|
||||||
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
|
<td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}">{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</table>
|
</table>
|
||||||
</OverlayIsland>
|
</OverlayIsland>
|
||||||
|
Loading…
Reference in New Issue
Block a user