From 767801b328fe13d186b225ffdd322f36e132f610 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 14 Sep 2023 14:07:04 +0100 Subject: [PATCH] Adjust formatting for 'via' destinations --- .../ldb/staff/table/table-generator.svelte | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/lib/ldb/staff/table/table-generator.svelte b/src/lib/ldb/staff/table/table-generator.svelte index 268b057..0e13b06 100644 --- a/src/lib/ldb/staff/table/table-generator.svelte +++ b/src/lib/ldb/staff/table/table-generator.svelte @@ -7,24 +7,32 @@ export let services: TrainServices[]; export let click: Function; + interface locationObject { + location: string, + via?: string, + } + function detail(event: any, rid: string, uid: string, tid: string) { const target = event.target; click(rid, uid, tid); } - async function formatLocations(locations: ServiceLocation[]): Promise { + async function formatLocations(locations: ServiceLocation[]): Promise { let tiplocs: string[] = []; for (const location of locations) { tiplocs.push(location.tiploc); } - let location = tiplocs.join(' & '); + let locationObj: locationObject = { + location: tiplocs.join(' & '), + }; if (locations[0]['via']) { - location = `${location} ${locations[0]['via']}` // Maybe this should be converted to TIPLOC server-side? + locationObj.via = locations[0]['via']; } - return location + return locationObj; } - async function classGenerator(service: TrainServices) { // This function needs updating next + async function classGenerator(service: TrainServices) { + // This function needs updating next let otherArr: string[] = []; let arrArr: string[] = []; let depArr: string[] = []; @@ -106,10 +114,10 @@ From To Plat - Sch - Exp - Sch - Exp + Sch + Exp + Sch + Exp @@ -123,18 +131,22 @@ on:keypress={(event) => detail(event, service.rid, service.uid, service.trainid)} > {#await classGenerator(service) then classes} + {service.trainid} - {#await formatLocations(service.origin) then origin}{origin}{/await} - {#await formatLocations(service.destination) then dest}{dest}{/await} - {service.platform || '-'} + + {#await formatLocations(service.origin) then origin}{origin.location}{#if origin.via}
{origin.via}{/if}{/await} + + {#await formatLocations(service.destination) then dest}{dest.location}{#if dest.via}
{dest.via}{/if}{/await} + + {service.platform || '-'} + {fmtTime(service?.sta) || '-'} - + {fmtTime(service.eta) || fmtTime(service.ata) || '-'} - + {fmtTime(service.std) || '-'} - + {fmtTime(service.etd) || fmtTime(service.atd) || '-'} - {/await} @@ -222,7 +234,11 @@ vertical-align: top; font-size: 12px; } - + .via { + font-size: 10px; + margin-bottom: 0px; + padding: 0px; + } /* Handle small screens */ .smallScreen { display: none; @@ -279,21 +295,21 @@ } /* Conditional Classes */ - .cancTxt { - color: grey !important; + .loc.canc, .id.canc, .canc { + color: grey; text-decoration: line-through; opacity: 0.8; } .nonPass { - opacity: 0.6; + opacity: 0.4; } .late { animation: pulse-late 1.5s linear infinite; } - .canc { + .canc.time { animation: pulse-cancel 1.5s linear infinite; }