-
Notifications
You must be signed in to change notification settings - Fork 133
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
DT-4910: New texts for infobox #4875
Conversation
app/translations.js
Outdated
@@ -1295,6 +1295,8 @@ const translations = { | |||
'number-of-minutes': | |||
'{number, plural, =0 {0 minutes} one {1 minute} other {{number} minutes}}', | |||
'number-of-spaces': 'Number of spaces:', | |||
'nysse-ticket-limited': | |||
'Nysse tickets are valid on trains in the Nysse area with some limitations. Read more on ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tekstin tulisi olla geneerinen nimeltään tyyliin 'train-ticket-limited' ja "Nysse"n voisi korvata muuttujalla tyyliin {{agencyName}}. Tai koko teksti tampereen config tiedostoon.
app/translations.js
Outdated
@@ -2431,6 +2433,8 @@ const translations = { | |||
'number-of-minutes': | |||
'{number, plural, =0 {0 minuuttia} one {1 minuutti} other {{number} minuuttia}}', | |||
'number-of-spaces': 'Paikkojen määrä:', | |||
'nysse-ticket-limited': | |||
'Nyssen liput käyvät junaliikenteessä rajoitetusti vain Nysse-alueella. Lue lisää ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sama kuin ylempänä.
app/translations.js
Outdated
@@ -4347,6 +4351,8 @@ const translations = { | |||
'number-of-minutes': | |||
'{number, plural, =0 {0 minuter} one {1 minut} other {{number} minuter}}', | |||
'number-of-spaces': 'Antalet platser:', | |||
'nysse-ticket-limited': | |||
'Nysse-biljetter är giltiga på tåg i Nysse-området, med vissa begränsningar. Läs mer på ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sama kuin ylempänä.
app/component/TransitLeg.js
Outdated
{leg.fare && | ||
leg.fare.isUnknown && | ||
shouldShowFareInfo(config) && | ||
(config.showTrainLimitationInfo ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tälle parempi sijainti voisi olla RailLeg, samaan tyyliin kuin CallAgencyLeg pitää oman infoboksinsa sisällään.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tarkemmin katsottuja RailLeg ei ole samantyyppinen kuin callAgencyLeg ja pitääkin sisällään TransitLegin ja määrittelee sille junan parametrejä, eli lokaatio on oikea. Tarkistuksen voisi kuitenkin lisätä että kyseessä on junaliikenne, joka onnistunee mode muuttujan avulla.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode === 'RAIL' on lisätty, mutta tämä on vain lisä turha koodi lisämine sinne. Koska oli testattu kävelly, bussin, polkupyörä, lentokonen matkat ja vain junan kanssa infoteksti tulee sinne jos tarvitaessa.
app/component/ItineraryTab.js
Outdated
); | ||
} | ||
|
||
if (config.showTrainLimitationInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tässä olisi hyvä varmistaa, että ehdotukset sisältävät junaliikennettä (esim. samaan tyyliin kuin yllä kutsuliikenteellä itineraryContainsCallLegs).
app/util/legUtils.js
Outdated
@@ -34,6 +34,13 @@ export function isCallAgencyPickupType(leg) { | |||
); | |||
} | |||
|
|||
export function isTrainLimitationPickupType(leg) { | |||
return ( | |||
filterLegStops(leg, stoptime => stoptime.pickupType === 'SCHEDULED') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Junia ei voi tarkistaa pickupTypestä, koska muillakin kuin junilla on scheduled pickuptype. Legin modesta tiedon kyllä saa ("rail").
app/component/InfoBox.js
Outdated
import Icon from './Icon'; | ||
|
||
const InfoBox = ( | ||
{ textId, values, href = null, configData = null }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component name cannot be generic InfoBox, because it renders very specific fare disclaimer .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FareDisclaimer.js
app/component/ItineraryTab.js
Outdated
const itineraryContainsCallLegs = itinerary.legs.some(leg => | ||
isCallAgencyPickupType(leg), | ||
); | ||
const isTrainLimitation = itinerary.legs.some(leg => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poor naming:
- isTrainLimitation -> hasTrainLegs. Actually this could be more generic: configuration could include a map of disclaimers per mode.
- isShowItineraryContainsCallLegsInfo is totally incomprehensible, change it to 'showCallAgencyDisclaimer'
- isShowTrainLimitationInfo -> showLegModeDisclaimer
app/util/legUtils.js
Outdated
); | ||
} | ||
|
||
export function isTrainLimitationPickupType(leg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad name. This has nothing to do with pickup types.
'Trains in the Nysse area - Nysse, Tampere regional transport', | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modeDisclaimers: {
train: {
fi: {
showTrainLimitationInfoLink: 'https://www.nysse.fi/junat',
showTrainLimitationInfoLinkText: 'nysse.fi/junat',
},
sv: {
showTrainLimitationInfoLink:
'https://www.nysse.fi/en/ways-to-get-around/train',
showTrainLimitationInfoLinkText:
'Trains in the Nysse area - Nysse, Tampere regional transport',
},
en: {
showTrainLimitationInfoLink:
'https://www.nysse.fi/en/ways-to-get-around/train',
showTrainLimitationInfoLinkText:
'Trains in the Nysse area - Nysse, Tampere regional transport',
},
},
}
}
fi: { | ||
showTrainLimitationInfoLink: 'https://www.nysse.fi/junat', | ||
showTrainLimitationInfoLinkText: 'nysse.fi/junat', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Muuta showTrainLimitationInfoLink -> link, showTrainLimitationInfoLinkText -> text
leg.fare.isUnknown && | ||
shouldShowFareInfo(config) && | ||
(mode === LegMode.Rail && config.modeDisclaimers.rail ? ( | ||
<div className="disclaimer-container unknown-fare-disclaimer__leg"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Koeta koodata tämä näin:
(config.modeDisclaimers[mode] ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suora käytä mode en pysty, koska tämä tulee kun 'RAIL', mutta tarvitseen configille 'rail'.
Onko sitten parempi käytää tällä mode.toLowerCase() tai sitten sama tiedostossa oli jo aikasemmin kirjoitety
const modeClassName = mode.toLowerCase();
Tämä on hyvä käytä, mutta tuntuu, että muttoja nimi modeClassName ei ole hyvä ???
app/util/legUtils.js
Outdated
} | ||
|
||
export function hasLegMode(leg) { | ||
return getLegMode(leg) === LegMode.Rail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tässä funktiossa ei ole järkeä. Poista ja siirrä yhden rivin koodi ItineraryTab.js:lle
isCallAgencyPickupType(leg), | ||
); | ||
const hasTrainLegs = itinerary.legs.some(leg => hasLegMode(leg)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seuraava olisi hyvä ratkaisu:
Rakenna taulukko FareDisclaimereja. Taulukoon pusketaan CallAgency yms disclaimerit, ja lisäksi n kpl mode disclaimereja. Eli iteroi kaikki legit ja katso onko käytössä leg.mode disclaimer. Jos on puske taulukkoon.
Tekstit kannattaa siirtää pois translations.txt tiedostosta config .modeDisclaimer objektiin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Muutokset menee oikeaan suuntaan, mutta vieläkin voi parantaa.
Proposed Changes
Pull Request Check List
Review