aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets
diff options
context:
space:
mode:
authorcedricnjanga2017-08-25 16:27:59 +0200
committercedricnjanga2017-08-25 16:46:55 +0200
commitb240f38d661e6e11428e3f09258ba29bcbf228bb (patch)
tree25b4c6df208780ada787791f696c2db2301ff504 /app/assets
parent2434f8e41b7b718b115a023aa8cdbb99045e092d (diff)
downloadchouette-core-b240f38d661e6e11428e3f09258ba29bcbf228bb.tar.bz2
Clean timetable dates after updating day types
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
index 64db1ccc1..84d90d53c 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
@@ -59,6 +59,17 @@ const timetable = (state = {}, action) => {
})
newState = _.assign({}, state, {current_month: newCMe, time_table_dates: newDates})
return _.assign({}, newState, {current_month: actions.updateSynthesis(newState, action.dayTypes)})
+ case 'UPDATE_DAY_TYPES':
+ // We get the week days of the activated day types to reject the out_dates that that are out of newDayTypes
+ let weekDays = _.reduce(action.dayTypes, (array, dt, i) => {
+ if (dt) array.push(i)
+ return array
+ }, [])
+
+ newDates = _.reject(state.time_table_dates, (d) => {
+ return d.in_out == false && !weekDays.includes(new Date(d.date).getDay())
+ })
+ return _.assign({}, state, {time_table_dates: newDates})
case 'UPDATE_CURRENT_MONTH_FROM_DAYTYPES':
return _.assign({}, state, {current_month: actions.updateSynthesis(state, action.dayTypes)})
case 'VALIDATE_PERIOD_FORM':