add train type information to journeysView
This commit is contained in:
parent
688c782485
commit
8b370d277d
|
@ -68,7 +68,8 @@ const journeyOverviewTemplate = (data, key) => {
|
|||
let departure = data.journeys[key].legs[0].departure;
|
||||
let arrival = data.journeys[key].legs[data.journeys[key].legs.length - 1].arrival;
|
||||
let changes = 0;
|
||||
let products = [];
|
||||
let products = {};
|
||||
let productsString = "";
|
||||
let changesDuration = 0;
|
||||
let cancelled = false;
|
||||
|
||||
|
@ -82,10 +83,18 @@ const journeyOverviewTemplate = (data, key) => {
|
|||
if (leg.isWalking || leg.isTransfer) continue;
|
||||
|
||||
changes = changes+1;
|
||||
products.push(leg.line.productName);
|
||||
if (!products[leg.line.productName]) products[leg.line.productName] = [];
|
||||
if (leg.line && leg.line.trainTypeShort) products[leg.line.productName].push(leg.line.trainTypeShort);
|
||||
}
|
||||
|
||||
products = [...new Set(products)];
|
||||
productsString = Object.entries(products).map(([prod, types]) => {
|
||||
if (types.length >= 2) {
|
||||
prod += " (" + types.join(", ") + ")";
|
||||
} else if (types.length) {
|
||||
prod += " " + types[0];
|
||||
}
|
||||
return prod;
|
||||
}).join(", ");
|
||||
|
||||
return html`
|
||||
<tr @click=${() => go('/'+data.reqId + '/' + key)}">
|
||||
|
@ -93,7 +102,7 @@ const journeyOverviewTemplate = (data, key) => {
|
|||
<td><span>${timeTemplate(arrival, 'arrival')}</span></td>
|
||||
<td title="${changesDuration > 0 ? 'Davon '+formatDuration(changesDuration)+' Umstiegsdauer' : ''}"><span>${formatDuration(duration)}</span></td>
|
||||
<td><span>${changes-1}</span></td>
|
||||
<td><span>${products.join(', ')}</span></td>
|
||||
<td><span>${productsString}</span></td>
|
||||
<td><a class="details-button icon-arrow3"></a></td>
|
||||
</tr>`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue