From dfa3e092c2e23db62cd348040dfcb4e5d210bf48 Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Mon, 19 Dec 2016 12:07:48 +0100 Subject: Fix stopAreas array, add stopArea id in json, and is now properly rendered Signed-off-by: Thomas Shawarma Haddad Signed-off-by: Jean-Paul Lescouzeres --- .../es6_browserified/journey_patterns/actions/index.js | 12 ++++++------ .../journey_patterns/components/JourneyPattern.js | 8 +++++++- app/views/api/v1/stop_areas/short_description.rabl | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js index fea293c95..ec9df63f2 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js @@ -51,19 +51,19 @@ const actions = { .then((json) => { let val for (val of json){ - let stop_points = [] for (let stop_point of val.route_short_description.stop_points){ stop_point.checked = false - stop_points[stop_point.object_id] = stop_point - } - for (let stopArea of val.stop_area_short_descriptions){ - stop_points[stopArea.stop_area_short_description.object_id].checked = true + val.stop_area_short_descriptions.map((element) => { + if(element.stop_area_short_description.id === stop_point.id){ + stop_point.checked = true + } + }) } journeyPatterns.push({ name: val.name, object_id: val.object_id, published_name: val.published_name, - stop_points: stop_points + stop_points: val.route_short_description.stop_points }) } dispatch(actions.receiveJourneyPatterns(journeyPatterns)) diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js index 460805176..f808bbb83 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js @@ -11,7 +11,13 @@ const JourneyPattern = (props) => {

Stop points:

) diff --git a/app/views/api/v1/stop_areas/short_description.rabl b/app/views/api/v1/stop_areas/short_description.rabl index 7b6a72491..fb0213510 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" -[ :name, :area_type, :longitude, :latitude, :long_lat_type].each do |attr| +[ :id, :name, :area_type, :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| -- cgit v1.2.3