diff options
| author | Thomas Haddad | 2017-05-31 11:23:09 +0200 |
|---|---|---|
| committer | Thomas Haddad | 2017-05-31 11:24:30 +0200 |
| commit | 8eb1c7fc424d0801e9322a0c0cfffb6346fe6fc4 (patch) | |
| tree | 6a9fd45d897d76c40e388cdd37915ab1b3b8a43d /app/assets/javascripts | |
| parent | faaf85d83ec4e16db8e89218ad4f1503b2dbf240 (diff) | |
| download | chouette-core-8eb1c7fc424d0801e9322a0c0cfffb6346fe6fc4.tar.bz2 | |
Refs #3609: keep correct stoppoints order when being deleted
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/es6_browserified/itineraries/index.js | 13 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/app/assets/javascripts/es6_browserified/itineraries/index.js b/app/assets/javascripts/es6_browserified/itineraries/index.js index 53f7bc7f9..1cf171c72 100644 --- a/app/assets/javascripts/es6_browserified/itineraries/index.js +++ b/app/assets/javascripts/es6_browserified/itineraries/index.js @@ -73,4 +73,17 @@ document.querySelector('input[name=commit]').addEventListener('click', (event)=> addInput('for_boarding',stopPoint.for_boarding, i) addInput('for_alighting',stopPoint.for_alighting, i) }) + if(state.stopPoints.length < datas.length){ + for(var j= state.stopPoints.length; j < datas.length; j++){ + updateFormForDeletion(datas[j]) + } + } }) + +const updateFormForDeletion = (stop) =>{ + if (stop.stoppoint_id !== undefined){ + let now = Date.now() + addInput('id', stop.stoppoint_id, now) + addInput('_destroy', 'true', now) + } +} diff --git a/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js b/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js index 18fee8bd1..24c3e5d87 100644 --- a/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js +++ b/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js @@ -19,13 +19,6 @@ const stopPoint = (state = {}, action, length) => { return state } } -const updateFormForDeletion = (stop) =>{ - if (stop.stoppoint_id !== undefined){ - let now = Date.now() - addInput('id', stop.stoppoint_id, now) - addInput('_destroy', 'true', now) - } -} const stopPoints = (state = [], action) => { switch (action.type) { @@ -49,7 +42,6 @@ const stopPoints = (state = [], action) => { ...state.slice(action.index + 2) ] case 'DELETE_STOP': - updateFormForDeletion(state[action.index]) return [ ...state.slice(0, action.index), ...state.slice(action.index + 1).map((stopPoint)=>{ |
