Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1342 update rejseplans template to remove hack yay #153

Conversation

sinejespersen
Copy link
Contributor

https://leantime.itkdev.dk/#/tickets/showTicket/1342

I replaced the current solution ("hack") with a solution where all the ids from the station-array are added to the url for the iframe. this means, that the admin has a multiselect, and the stations the user wants to be displayed can now be displayed. This was made possible because Rejseplanen updated their api.

This works with data from the new api, and data from the old - it does not break anything per se. That being said, when we are removing the existing hack, the current templates will only show a bus/tram in one direction, not both directions. The people with installations this affects will be notified.

@sinejespersen sinejespersen requested a review from tuj May 24, 2024 13:15
// After meeting*s* about this, we have concluded that the ids follow a pattern, where the last character
// in the string is defining which direction, and can be anything from 0-9.
// So, here we replace the last character of the id with 0-9, and then the rejseplan-api disregards ids that
// are not connected to a station (we hope).
const getStationIds = () => {
if (!(station instanceof Array) || station.length === 0) {
return "";
}

let ids = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace all below with:

Suggested change
let ids = "";
return station.reduce((carry, {id}) => `${carry}${id}@`, '');

The if (!station) is handled above...

@sinejespersen sinejespersen merged commit 1c7297a into develop Jun 3, 2024
4 checks passed
@sinejespersen sinejespersen deleted the feature/1342-update-rejseplans-template-to-remove-hack-yay branch December 11, 2024 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants