From 913d6935727ace3ac94c08adb4e1ec378741fb19 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 3 Jan 2018 16:31:33 +0100 Subject: Refs #5455 @6h; Add time and distance between stops in Journey Patterns - Adds a `JSON` attribute in the model - Adds the fields in the editor --- app/javascript/journey_patterns/actions/index.js | 14 +++++ .../journey_patterns/components/JourneyPattern.js | 73 ++++++++++++++++++++-- .../journey_patterns/components/JourneyPatterns.js | 3 +- .../containers/JourneyPatternList.js | 5 +- .../journey_patterns/reducers/journeyPatterns.js | 16 ++++- app/javascript/packs/journey_patterns/index.js | 1 + 6 files changed, 103 insertions(+), 9 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 1c2eb68b2..09e2001c1 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -64,6 +64,11 @@ const actions = { type : 'DELETE_JOURNEYPATTERN', index, }), + updateJourneyPatternCosts : (index, costs) => ({ + type : 'UPDATE_JOURNEYPATTERN_COSTS', + index, + costs + }), closeModal : () => ({ type : 'CLOSE_MODAL' }), @@ -194,6 +199,7 @@ const actions = { } }) } +<<<<<<< HEAD journeyPatterns.push({ name: val.name, object_id: val.object_id, @@ -204,6 +210,14 @@ const actions = { stop_points: val.route_short_description.stop_points, deletable: false }) +======= + journeyPatterns.push( + _.assign({}, val, { + stop_points: val.route_short_description.stop_points, + deletable: false + }) + ) +>>>>>>> Refs #5455 @6h; Add time and distance between stops in Journey Patterns } } window.currentItemsLength = journeyPatterns.length diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index d4c9816ec..40a6899e2 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -5,6 +5,17 @@ export default class JourneyPattern extends Component{ constructor(props){ super(props) this.previousCity = undefined + this.previousSpId = undefined + this.updateCosts = this.updateCosts.bind(this) + } + + updateCosts(e) { + let costs = { + [e.target.dataset.costsKey]: { + [e.target.name]: parseInt(e.target.value) + } + } + this.props.onUpdateJourneyPatternCosts(costs) } vehicleJourneyURL(jpOid) { @@ -16,16 +27,26 @@ export default class JourneyPattern extends Component{ ) } + hasFeature(key) { + return this.props.status.features[key] + } + cityNameChecker(sp) { let bool = false + if(sp.city_name != this.previousCity){ bool = true this.previousCity = sp.city_name } + return bool + } + + spNode(sp, headlined){ return (
+ + km +
++ + min +
+{(costs['distance'] || 0) + " km"}
+{time_in_words}
+