From 84c7eb8f171e1a353a06496b088f73837a3425ff Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 12 Mar 2018 11:52:48 +0100 Subject: Refs #6102; Add label in JourneyPattern Editor header Refs #6104; Add commercial-only journey time in JourneyPattern Editor --- .../journey_patterns/components/JourneyPattern.js | 23 +++++++++++++++++----- .../journey_patterns/components/JourneyPatterns.js | 2 ++ app/views/api/v1/stop_areas/short_description.rabl | 2 +- config/locales/journey_patterns.en.yml | 3 +++ config/locales/journey_patterns.fr.yml | 2 ++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 35765b99a..d20294594 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -74,17 +74,22 @@ export default class JourneyPattern extends Component{ return !this.props.status.policy[`journey_patterns.${action}`] } - totals(){ + totals(onlyCommercial=false){ let totalTime = 0 let totalDistance = 0 let from = null this.props.value.stop_points.map((stopPoint, i) =>{ - if(from && stopPoint.checked){ + let usePoint = stopPoint.checked + console.log(stopPoint) + if(onlyCommercial && (i == 0 || i == this.props.value.stop_points.length - 1) && stopPoint.kind == "non_commercial"){ + usePoint = false + } + if(from && usePoint){ let [costsKey, costs, time, distance] = this.getTimeAndDistanceBetweenStops(from, stopPoint.id) totalTime += time totalDistance += distance } - if(stopPoint.checked){ + if(usePoint){ from = stopPoint.id } }) @@ -109,13 +114,15 @@ export default class JourneyPattern extends Component{ } else{ let hours = parseInt(time/60) - return hours + " h " + (time - 60*hours) + let minutes = (time - 60*hours) + return hours + " h " + (minutes > 0 ? minutes : '') } } render() { this.previousSpId = undefined - let [totalTime, totalDistance] = this.totals() + let [totalTime, totalDistance] = this.totals(false) + let [commercialTotalTime, commercialTotalDistance] = this.totals(true) return (