diff options
| author | Thomas Haddad | 2017-02-28 17:41:00 +0100 |
|---|---|---|
| committer | Thomas Haddad | 2017-02-28 17:41:00 +0100 |
| commit | 070c93312ab8db54d6b5e5babbf5ea433ebd6f33 (patch) | |
| tree | 4856edf4a2a743ae93568cc855f6c516d89c6ad5 /app/assets/javascripts | |
| parent | b0bce148ef5648224d1ff261283455453e8c5634 (diff) | |
| download | chouette-core-070c93312ab8db54d6b5e5babbf5ea433ebd6f33.tar.bz2 | |
Fix fetch API in jp when no entries
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Signed-off-by: Jean-Paul Lescouzeres <jean-paul.lescouzeres@af83.com>
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js | 40 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js | 18 |
2 files changed, 32 insertions, 26 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 } |
