Frontend: Add support for multiple Origin/Dest

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-22 10:38:30 +00:00
parent e8c6d3bfc5
commit e15824381e
3 changed files with 11 additions and 5 deletions

View File

@ -6,7 +6,7 @@
* Still need SVG Fallback option for alert icon on board.html
* Alerts box should not be clickable, bar should be.
* Issue page: Submit using API.
* Support multiple service origins/destinations:
* UNDER TEST:: Support multiple service origins/destinations:
- Where there are multiples an array is returned for trainServices.service
* Enable text search for `locationName` on find-code page.

View File

@ -67,8 +67,14 @@ async function parseTime(string){
}
// Sometimes the origin or destination names are undefined, need to catch that
async function parseName() {
return;
async function parseName(location) {
if (Array.isArray(location)) {
var name = `${location[0]['locationName']} & ${location[1]['locationName']}`
return name;
}
else {
return location.locationName;
}
}
// Display Alert Messages

View File

@ -171,8 +171,8 @@ async function displayFerryService(svc) {
var row = `
<table>
<tr>
<td class="name name-item">${svc.origin.location.locationName}</td>
<td class="name name-item">${svc.destination.location.locationName}</td>
<td class="name name-item">${parseName(svc.origin.location.locationName)}</td>
<td class="name name-item">${parseName(svc.destination.location.locationName)}</td>
<td class="plat}">${plt}</td>
<td class="time">${sta.data}</td>
<td class="time ${eta.changed}">${eta.data}</td>