Compare commits

...

3 Commits

Author SHA1 Message Date
455d54355c Display trip title 2025-07-06 18:53:19 +02:00
3698f79731 Deduplicate saved legs 2025-07-06 18:39:49 +02:00
4060e29ade Wait for trips to finish fetching before updating drafing board 2025-07-06 18:27:05 +02:00
4 changed files with 23 additions and 6 deletions

View File

@@ -69,11 +69,14 @@ export class LegsDataStore {
DataStore.set("legs", this.data);
}
remember(trip_id, origin_id, destination_id) {
remember(trip_id, origin_location_id, destination_location_id) {
this.data = this.data.filter((leg) => {
return !(leg.trip_id == trip_id && leg.origin_location_id == origin_location_id && leg.destination_location_id == destination_location_id);
});
this.data.push({
trip_id: trip_id,
origin_location_id: origin_id,
destination_location_id: destination_id,
origin_location_id: origin_location_id,
destination_location_id: destination_location_id,
});
this.write();

View File

@@ -5,14 +5,18 @@ import { fetchTrip } from './api.js';
let element_board = document.querySelector("#drafting-board-content");
export function addJourneyToDraftingBoard(journey) {
let awaiting_promises = [];
for (let leg of journey.legs.filter(item => !("walking" in item))) {
window.dataStore.legs.remember(leg.tripId, leg.origin.id, leg.destination.id);
fetchTrip(leg.tripId).then(result => {
awaiting_promises.push(fetchTrip(leg.tripId).then(result => {
window.dataStore.trips.remember(result.trip);
});
}));
}
drawDraftingBoard();
Promise.all(awaiting_promises)
.then(results => {
drawDraftingBoard();
});
}
export function drawDraftingBoard() {

View File

@@ -30,6 +30,8 @@ body {
color: white;
display: none;
overflow: scroll;
}
#journeys-search {
@@ -54,6 +56,10 @@ body {
margin-bottom: 20px;
}
.popup h1 {
margin-bottom: 30px;
}
.popup input {
color: white;
}

View File

@@ -11,6 +11,10 @@ export function displayTripDetails(trip_id) {
fetchTrip(trip_id).then(result => {
element_response.innerText = "";
let el_headline = EL("h1", {});
el_headline.innerText = result.trip.line.name + ": " + result.trip.destination.name;
element_response.appendChild(el_headline);
for (let stopover of result.trip.stopovers) {
let el = EL("div", {});
el.innerText = stopover.stop.name;