aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorThomas Haddad2017-04-13 16:28:59 +0200
committerThomas Haddad2017-04-13 16:29:22 +0200
commitae87a040fe5b81c03a5bd1d93c8742760fadae90 (patch)
tree7c82f6cdf752ac1c9bcb123641d5116c83c90a76 /app/assets/javascripts
parent7dbafc403f96c6aad2ed6862f1234ce76d7d123a (diff)
downloadchouette-core-ae87a040fe5b81c03a5bd1d93c8742760fadae90.tar.bz2
Refs #2892: State refactoring for tt
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/Metas.js6
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js7
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/containers/Metas.js2
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/containers/Timetable.js3
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/index.js15
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/day_types.js12
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/index.js12
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js18
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js16
12 files changed, 57 insertions, 64 deletions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js b/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
index 1440dcb1d..fa72a76aa 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
@@ -8,8 +8,8 @@ const reorderArray = (arr) =>{
return arr
}
-const Metas = ({day_types}) => {
- day_types = reorderArray(day_types)
+const Metas = ({metas}) => {
+ let day_types = reorderArray(metas.day_types)
return (
<div className='form-horizontal'>
<div className="row">
@@ -57,7 +57,7 @@ const Metas = ({day_types}) => {
}
Metas.propTypes = {
- day_types: PropTypes.array.isRequired
+ metas: PropTypes.object.isRequired
}
module.exports = Metas
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js b/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
index 716b33ba4..8f25d1f10 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
@@ -1,12 +1,12 @@
var React = require('react')
var PropTypes = require('react').PropTypes
-const Timetable = ({current_month, time_table_periods}) => {
+const Timetable = ({timetable}) => {
return (
<div>
<h2>Calendrier</h2>
<ul>
- {current_month.map((day, i) =>
+ {timetable.current_month.map((day, i) =>
<li
key={i}
>
@@ -19,8 +19,7 @@ const Timetable = ({current_month, time_table_periods}) => {
}
Timetable.propTypes = {
- current_month: PropTypes.array.isRequired,
- time_table_periods: PropTypes.array.isRequired
+ timetable: PropTypes.object.isRequired,
}
module.exports = Timetable
diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/Metas.js b/app/assets/javascripts/es6_browserified/time_tables/containers/Metas.js
index 4a1465f6e..b2add391d 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/containers/Metas.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/containers/Metas.js
@@ -4,7 +4,7 @@ var MetasComponent = require('../components/Metas')
const mapStateToProps = (state) => {
return {
- day_types: state.day_types
+ metas: state.metas
}
}
diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/Timetable.js b/app/assets/javascripts/es6_browserified/time_tables/containers/Timetable.js
index c92dc5abf..2282afe80 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/containers/Timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/containers/Timetable.js
@@ -3,8 +3,7 @@ var TimetableComponent = require('../components/Timetable')
const mapStateToProps = (state) => {
return {
- current_month: state.current_month,
- time_table_periods: state.time_table_periods
+ timetable: state.timetable
}
}
diff --git a/app/assets/javascripts/es6_browserified/time_tables/index.js b/app/assets/javascripts/es6_browserified/time_tables/index.js
index 4213b307c..cc04a9a36 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/index.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/index.js
@@ -17,10 +17,17 @@ var initialState = {
fetchSuccess: true,
isFetching: false
},
- current_month: [],
- time_table_periods: [],
- periode_range: [],
- day_types: [],
+ timetable: {
+ current_month: [],
+ time_table_periods: [],
+ periode_range: [],
+ },
+ metas: {
+ comment: '',
+ day_types: [],
+ tags: [],
+ color: ''
+ },
pagination: {
page : 1,
totalCount: window.journeyPatternLength,
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js
deleted file mode 100644
index 425e897d1..000000000
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js
+++ /dev/null
@@ -1,10 +0,0 @@
-const currentMonth = (state = [], action) => {
- switch (action.type) {
- case 'RECEIVE_TIME_TABLES':
- return action.json.current_month
- default:
- return state
- }
-}
-
-module.exports = currentMonth
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/day_types.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/day_types.js
deleted file mode 100644
index c511f8dbe..000000000
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/day_types.js
+++ /dev/null
@@ -1,12 +0,0 @@
-const actions = require('../actions')
-
-const dayTypes = (state = "", action) => {
- switch (action.type) {
- case 'RECEIVE_TIME_TABLES':
- return actions.strToArrayDayTypes(action.json.day_types)
- default:
- return state
- }
-}
-
-module.exports = dayTypes
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js
index 55ece38c4..5b05aadda 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js
@@ -2,16 +2,12 @@ var combineReducers = require('redux').combineReducers
var status = require('./status')
var pagination = require('./pagination')
var modal = require('./modal')
-var current_month = require('./current_month')
-var periode_range = require('./periode_range')
-var time_table_periods = require('./time_table_periods')
-var day_types = require('./day_types')
+var timetable = require('./timetable')
+var metas = require('./metas')
const timeTablesApp = combineReducers({
- current_month,
- periode_range,
- time_table_periods,
- day_types,
+ timetable,
+ metas,
status,
pagination,
modal
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js
new file mode 100644
index 000000000..5f80cb5db
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js
@@ -0,0 +1,18 @@
+const _ = require('lodash')
+const actions = require('../actions')
+
+const metas = (state = {}, action) => {
+ switch (action.type) {
+ case 'RECEIVE_TIME_TABLES':
+ return _.assign({}, state, {
+ comment: action.json.comment,
+ day_types: actions.strToArrayDayTypes(action.json.day_types),
+ tags: action.json.tags,
+ color: action.json.color
+ })
+ default:
+ return state
+ }
+}
+
+module.exports = metas
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js
deleted file mode 100644
index 095069f8a..000000000
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js
+++ /dev/null
@@ -1,10 +0,0 @@
-const periodeRange = (state = [], action) => {
- switch (action.type) {
- case 'RECEIVE_TIME_TABLES':
- return action.json.periode_range
- default:
- return state
- }
-}
-
-module.exports = periodeRange
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js
deleted file mode 100644
index 614e63894..000000000
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js
+++ /dev/null
@@ -1,10 +0,0 @@
-const timeTablePeriods = (state = [], action) => {
- switch (action.type) {
- case 'RECEIVE_TIME_TABLES':
- return action.json.time_table_periods
- default:
- return state
- }
-}
-
-module.exports = timeTablePeriods
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
new file mode 100644
index 000000000..8f689ad92
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
@@ -0,0 +1,16 @@
+const _ = require('lodash')
+
+const timetable = (state = {}, action) => {
+ switch (action.type) {
+ case 'RECEIVE_TIME_TABLES':
+ return _.assign({}, state, {
+ current_month: action.json.current_month,
+ time_table_periods: action.json.time_table_periods,
+ periode_range: action.json.periode_range
+ })
+ default:
+ return state
+ }
+}
+
+module.exports = timetable