aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js40
-rw-r--r--app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js18
-rw-r--r--app/views/journey_patterns_collections/show.html.slim4
-rw-r--r--app/views/routes/show.html.slim2
4 files changed, 35 insertions, 29 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 e98460099..f5a3357eb 100644
--- a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js
+++ b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js
@@ -169,27 +169,29 @@ const actions = {
if(hasError == true) {
dispatch(actions.unavailableServer())
} else {
- let val
- for (val of json){
- for (let stop_point of val.route_short_description.stop_points){
- stop_point.checked = false
- val.stop_area_short_descriptions.map((element) => {
- if(element.stop_area_short_description.id === stop_point.id){
- stop_point.checked = true
- }
+ if(json.length != 0){
+ let val
+ for (val of json){
+ for (let stop_point of val.route_short_description.stop_points){
+ stop_point.checked = false
+ 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,
+ registration_number: val.registration_number,
+ stop_points: val.route_short_description.stop_points,
+ deletable: false
})
}
- journeyPatterns.push({
- name: val.name,
- object_id: val.object_id,
- published_name: val.published_name,
- registration_number: val.registration_number,
- stop_points: val.route_short_description.stop_points,
- deletable: false
- })
- }
- if(journeyPatterns.length != window.journeyPatternsPerPage){
- dispatch(actions.updateTotalCount(journeyPatterns.length - window.journeyPatternsPerPage))
+ if(journeyPatterns.length != window.journeyPatternsPerPage){
+ dispatch(actions.updateTotalCount(journeyPatterns.length - window.journeyPatternsPerPage))
+ }
}
dispatch(actions.receiveJourneyPatterns(journeyPatterns))
}
diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js
index 407a8e382..904f3cdc4 100644
--- a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js
+++ b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js
@@ -1,12 +1,16 @@
-const stopPointsList = (state = {}, action) => {
+const stopPointsList = (state = [], action) => {
switch (action.type) {
case 'RECEIVE_JOURNEY_PATTERNS':
- let sp = action.json[0].stop_points
- let spArray = []
- sp.map((s) => {
- spArray.push(s.name)
- })
- return [...spArray]
+ if(action.json.length != 0){
+ let sp = action.json[0].stop_points
+ let spArray = []
+ sp.map((s) => {
+ spArray.push(s.name)
+ })
+ return [...spArray]
+ }else{
+ return state
+ }
default:
return state
}
diff --git a/app/views/journey_patterns_collections/show.html.slim b/app/views/journey_patterns_collections/show.html.slim
index 28fdaf1ae..bfcc963cc 100644
--- a/app/views/journey_patterns_collections/show.html.slim
+++ b/app/views/journey_patterns_collections/show.html.slim
@@ -2,7 +2,7 @@
= pageheader 'map-marker',
"Missions de #{@route.name}",
'Lorem ipsum dolor sit amet',
- t('last_update', time: l(@journey_patterns.last.updated_at, format: :short))
+ (@journey_patterns.any? ? t('last_update', time: l(@journey_patterns.last.updated_at, format: :short)) : '')
/ PageContent
.page_content
@@ -11,8 +11,8 @@
.col-lg-12
#journey_patterns
-
= javascript_tag do
+ | window.stopPoints = #{(@route.stop_points.to_json).html_safe};
| window.journeyPatternLength = #{@journey_patterns.total_entries()};
| window.journeyPatternsPerPage = #{@ppage}
= javascript_include_tag 'es6_browserified/journey_patterns/index.js'
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index 428c82c58..f6243564b 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -8,8 +8,8 @@
/ Below is secundary actions & optional contents (filters, ...)
.row.mb-sm
.col-lg-12.text-right
+ = link_to t('journey_patterns.index.title'), [@referential, @line, @route, :journey_patterns_collection], class: 'btn btn-primary'
- if @route.journey_patterns.present?
- = link_to t('journey_patterns.index.title'), [@referential, @line, @route, :journey_patterns_collection], class: 'btn btn-primary'
= link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], class: 'btn btn-primary'
= link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, format: :zip), class: 'btn btn-primary'