Add handler for PIS object

This commit is contained in:
Fred Boniface 2024-01-16 20:34:31 +00:00
parent 6505ba7f60
commit e6ee0dc321
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,15 @@
<script lang="ts">
import type { OB_Pis_SimpleObject } from '@owlboard/ts-types';
export let pisObject: OB_Pis_SimpleObject;
</script>
{#if pisObject}
{#if typeof pisObject === 'string' || typeof pisObject === 'number'}
{pisObject}
{:else if pisObject['skipCount'] === 0}
{pisObject.code}
{:else if pisObject['skipCount'] > 0}
{pisObject.code} - (Skip {pisObject.skipType}{#if pisObject.skipCount > 1} {pisObject.skipCount} stops{:else} stop{/if})
{/if}
{/if}

View File

@ -4,6 +4,7 @@
import LoadingText from '$lib/navigation/loading-text.svelte';
import StylesToc from './styles-toc.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import PisHandler from '$lib/train/pis-handler.svelte';
export let service = '';
@ -48,7 +49,7 @@
{:then serviceDetail}
<div class="detailOperator"><StylesToc toc={service?.operator || ''} full={true} /></div>
{#if serviceDetail.pis}
<p class="pis">PIS: {serviceDetail.pis}</p>
<p class="pis">PIS: <PisHandler pisObject={serviceDetail.pis} /></p>
{/if}
<p class="svc-detail">
Planned Type: {parseInt(serviceDetail.planSpeed) || '--'}mph {serviceDetail.powerType || 'Non-Rail vehicle'}