From efbd9f90ae41b357ad8559fbc3b29fc59524bb73 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Mon, 14 Aug 2017 15:04:52 +0200 Subject: Timetable Period form update --- .../javascripts/es6_browserified/time_tables/actions/index.js | 4 ++-- .../es6_browserified/time_tables/components/PeriodForm.js | 4 ++-- .../es6_browserified/time_tables/containers/PeriodForm.js | 7 ++++--- .../javascripts/es6_browserified/time_tables/reducers/modal.js | 2 +- .../javascripts/es6_browserified/time_tables/reducers/timetable.js | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js index a1e41027a..f88d64d4d 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js +++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js @@ -105,12 +105,12 @@ const actions = { group, selectType }), - validatePeriodForm: (modalProps, timeTablePeriods, metas, timeTableDates) => ({ + validatePeriodForm: (modalProps, timeTablePeriods, metas, currentMonthDaysIn) => ({ type: 'VALIDATE_PERIOD_FORM', modalProps, timeTablePeriods, metas, - timeTableDates + currentMonthDaysIn }), includeDateInPeriod: (index, dayTypes) => ({ type: 'INCLUDE_DATE_IN_PERIOD', diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js index 2194bd46a..1426a5908 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js +++ b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js @@ -32,7 +32,7 @@ const makeYearsOptions = (yearSelected) => { return arr } -const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}) => ( +const PeriodForm = ({modal, timetable, metas, currentMonthDaysIn, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}) => (
@@ -108,7 +108,7 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js b/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js index d6ba64241..813f9d795 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js +++ b/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js @@ -7,7 +7,8 @@ const mapStateToProps = (state) => { return { modal: state.modal, timetable: state.timetable, - metas: state.metas + metas: state.metas, + currentMonthDaysIn: _.filter(state.timetable.current_month, ['include_date', true]) } } @@ -27,8 +28,8 @@ const mapDispatchToProps = (dispatch) => { val = (val < 10) ? '0' + String(val) : String(val) dispatch(actions.updatePeriodForm(val, group, 'day')) }, - onValidatePeriodForm: (modalProps, timeTablePeriods, metas, timeTableDates) => { - dispatch(actions.validatePeriodForm(modalProps, timeTablePeriods, metas, timeTableDates)) + onValidatePeriodForm: (modalProps, timeTablePeriods, metas, currentMonthDaysIn) => { + dispatch(actions.validatePeriodForm(modalProps, timeTablePeriods, metas, currentMonthDaysIn)) } } } diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js index 4af2dc307..eaa5ad385 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js @@ -64,7 +64,7 @@ const modal = (state = {}, action) => { } let newPeriods = JSON.parse(JSON.stringify(action.timeTablePeriods)) - let newDays = JSON.parse(JSON.stringify(action.timeTableDates)) + let newDays = JSON.parse(JSON.stringify(action.currentMonthDaysIn)) let error = actions.checkErrorsInPeriods(period_start, period_end, action.modalProps.index, newPeriods) if (error == '') error = actions.checkErrorsInDates(period_start, period_end, newDays) newModalProps.error = error 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 aa3ea55e3..057e9a380 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js @@ -64,7 +64,7 @@ const timetable = (state = {}, action) => { return state } let newPeriods = JSON.parse(JSON.stringify(action.timeTablePeriods)) - let newDays = JSON.parse(JSON.stringify(action.timeTableDates)) + let newDays = JSON.parse(JSON.stringify(action.currentMonthDaysIn)) let error = actions.checkErrorsInPeriods(period_start, period_end, action.modalProps.index, newPeriods) if (error == '') error = actions.checkErrorsInDates(period_start, period_end, newDays) -- cgit v1.2.3