aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/vehicle_journeys/reducers
diff options
context:
space:
mode:
authorZog2018-01-11 15:42:37 +0100
committerZog2018-01-11 15:42:37 +0100
commited0faeaaa7bddc135c7b55f6d12fd09a739afacc (patch)
tree488e5536757df1d7ac4bcf14436290c0c1d22244 /app/javascript/vehicle_journeys/reducers
parentcb0564d4d7d35c8a43e166b68d8c7dc94341fc9d (diff)
downloadchouette-core-ed0faeaaa7bddc135c7b55f6d12fd09a739afacc.tar.bz2
Refs #5551 @0.5h; Implement the custom fields in the creation modal
And Refactor the component in the process
Diffstat (limited to 'app/javascript/vehicle_journeys/reducers')
-rw-r--r--app/javascript/vehicle_journeys/reducers/custom_fields.js6
-rw-r--r--app/javascript/vehicle_journeys/reducers/index.js4
-rw-r--r--app/javascript/vehicle_journeys/reducers/vehicleJourneys.js7
3 files changed, 13 insertions, 4 deletions
diff --git a/app/javascript/vehicle_journeys/reducers/custom_fields.js b/app/javascript/vehicle_journeys/reducers/custom_fields.js
new file mode 100644
index 000000000..482fd91cb
--- /dev/null
+++ b/app/javascript/vehicle_journeys/reducers/custom_fields.js
@@ -0,0 +1,6 @@
+export default function custom_fields(state = [], action) {
+ switch (action.type) {
+ default:
+ return state
+ }
+}
diff --git a/app/javascript/vehicle_journeys/reducers/index.js b/app/javascript/vehicle_journeys/reducers/index.js
index 862c864ae..1963f7c6d 100644
--- a/app/javascript/vehicle_journeys/reducers/index.js
+++ b/app/javascript/vehicle_journeys/reducers/index.js
@@ -7,6 +7,7 @@ import filters from './filters'
import editMode from './editMode'
import stopPointsList from './stopPointsList'
import missions from './missions'
+import custom_fields from './custom_fields'
const vehicleJourneysApp = combineReducers({
vehicleJourneys,
@@ -16,7 +17,8 @@ const vehicleJourneysApp = combineReducers({
filters,
editMode,
stopPointsList,
- missions
+ missions,
+ custom_fields
})
export default vehicleJourneysApp
diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
index 4ed85316f..8d68ad2db 100644
--- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
@@ -54,6 +54,7 @@ const vehicleJourney= (state = {}, action, keep) => {
pristineVjasList.push(newVjas)
})
+
return {
company: action.selectedCompany,
journey_pattern: action.selectedJourneyPattern,
@@ -68,7 +69,8 @@ const vehicleJourney= (state = {}, action, keep) => {
selected: false,
deletable: false,
transport_mode: window.transportMode ? window.transportMode : 'undefined',
- transport_submode: window.transportSubmode ? window.transportSubmode : 'undefined'
+ transport_submode: window.transportSubmode ? window.transportSubmode : 'undefined',
+ custom_fields: action.data.custom_fields
}
case 'DUPLICATE_VEHICLEJOURNEY':
case 'SHIFT_VEHICLEJOURNEY':
@@ -144,9 +146,8 @@ export default function vehicleJourneys(state = [], action) {
case 'EDIT_VEHICLEJOURNEY':
return state.map((vj, i) => {
if (vj.selected){
- let custom_fields = _.assign({}, vj.custom_fields)
+ let custom_fields = _.assign({}, action.data.custom_fields)
_.each(custom_fields, (cf, code) => {
- console.log(action.data.custom_fields)
let value = action.data.custom_fields[code]
custom_fields[code] = _.assign({}, custom_fields[code], {value})
})