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 (
@@ -128,6 +135,12 @@ export default class JourneyPattern extends Component{ {totalTime}
} + {this.hasFeature('costs_in_journey_patterns') && +
+ {commercialTotalDistance} + {commercialTotalTime} +
+ }
ID Mission
Code mission
Nb arrêts
+
{I18n.attribute_name('journey_pattern', 'full_journey_time')}
+
{I18n.attribute_name('journey_pattern', 'commercial_journey_time')}
{this.props.stopPointsList.map((sp, i) =>{ return ( diff --git a/app/views/api/v1/stop_areas/short_description.rabl b/app/views/api/v1/stop_areas/short_description.rabl index 7d571b0a2..2f27f04d8 100644 --- a/app/views/api/v1/stop_areas/short_description.rabl +++ b/app/views/api/v1/stop_areas/short_description.rabl @@ -1,7 +1,7 @@ object @stop_area extends "api/v1/trident_objects/short_description" -[:id, :name, :city_name, :zip_code, :area_type, :longitude, :latitude, :long_lat_type].each do |attr| +[:id, :name, :city_name, :zip_code, :area_type, :kind, :longitude, :latitude, :long_lat_type].each do |attr| attributes attr, :unless => lambda { |m| m.send( attr).nil?} end node(:parent_object_id) do |stop_area| diff --git a/config/locales/journey_patterns.en.yml b/config/locales/journey_patterns.en.yml index 9d9bc21e2..5f3de0b05 100644 --- a/config/locales/journey_patterns.en.yml +++ b/config/locales/journey_patterns.en.yml @@ -49,6 +49,9 @@ en: created_at: Created at updated_at: Updated at creator_id: "Created by" + full_journey_time: Full journey + commercial_journey_time: Commercial journey + formtastic: titles: journey_pattern: diff --git a/config/locales/journey_patterns.fr.yml b/config/locales/journey_patterns.fr.yml index fb69f4190..ad5869e84 100644 --- a/config/locales/journey_patterns.fr.yml +++ b/config/locales/journey_patterns.fr.yml @@ -49,6 +49,8 @@ fr: created_at: "Créé le" updated_at: "Edité le" creator_id: "Créé par" + full_journey_time: Parcours complet + commercial_journey_time: Parcours commercial formtastic: titles: journey_pattern: -- cgit v1.2.3