aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcedricnjanga2017-08-14 15:04:52 +0200
committercedricnjanga2017-08-16 09:28:48 +0200
commitefbd9f90ae41b357ad8559fbc3b29fc59524bb73 (patch)
tree40e0baefe7c2b91456606747e7b820f1379483ee
parentd1c1e5628679ee41956d0b05e24807ef84b98928 (diff)
downloadchouette-core-efbd9f90ae41b357ad8559fbc3b29fc59524bb73.tar.bz2
Timetable Period form update
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/actions/index.js4
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js4
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js7
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js2
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js2
-rw-r--r--spec/javascripts/time_table/actions_spec.js6
-rw-r--r--spec/javascripts/time_table/reducers/modal_spec.js6
-rw-r--r--spec/javascripts/time_table/reducers/timetable_spec.js2
8 files changed, 17 insertions, 16 deletions
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}) => (
<div className="container-fluid">
<div className="row">
<div className="col lg-6 col-lg-offset-3">
@@ -108,7 +108,7 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
<button
type='button'
className='btn btn-outline-primary mr-sm'
- onClick={() => onValidatePeriodForm(modal.modalProps, timetable.time_table_periods, metas, _.reject(timetable.current_month, ['include_date', false]))}
+ onClick={() => onValidatePeriodForm(modal.modalProps, timetable.time_table_periods, metas, currentMonthDaysIn)}
>
Valider
</button>
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)
diff --git a/spec/javascripts/time_table/actions_spec.js b/spec/javascripts/time_table/actions_spec.js
index 01e5ba0f7..d3618834a 100644
--- a/spec/javascripts/time_table/actions_spec.js
+++ b/spec/javascripts/time_table/actions_spec.js
@@ -157,16 +157,16 @@ describe('actions', () => {
it('should create an action to validate period form', () => {
let modalProps = {}
let timeTablePeriods = []
- let timeTableDates = []
let metas = {}
+ let currentMonthDaysIn = []
const expectedAction = {
type: 'VALIDATE_PERIOD_FORM',
modalProps,
timeTablePeriods,
metas,
- timeTableDates
+ currentMonthDaysIn
}
- expect(actions.validatePeriodForm(modalProps, timeTablePeriods, metas, timeTableDates)).toEqual(expectedAction)
+ expect(actions.validatePeriodForm(modalProps, timeTablePeriods, metas, currentMonthDaysIn)).toEqual(expectedAction)
})
it('should create an action to include date in period', () => {
diff --git a/spec/javascripts/time_table/reducers/modal_spec.js b/spec/javascripts/time_table/reducers/modal_spec.js
index 8e9ebcd11..f125052b3 100644
--- a/spec/javascripts/time_table/reducers/modal_spec.js
+++ b/spec/javascripts/time_table/reducers/modal_spec.js
@@ -177,7 +177,7 @@ describe('modal reducer', () => {
type: 'VALIDATE_PERIOD_FORM',
modalProps : modProps,
timeTablePeriods: ttperiods,
- timeTableDates: ttdates
+ currentMonthDaysIn: ttdates
})
).toEqual(Object.assign({}, state, {modalProps: newModalProps}))
})
@@ -247,7 +247,7 @@ describe('modal reducer', () => {
type: 'VALIDATE_PERIOD_FORM',
modalProps : modProps2,
timeTablePeriods: ttperiods2,
- timeTableDates: ttdates2
+ currentMonthDaysIn: ttdates2
})
).toEqual(Object.assign({}, state2, {modalProps: newModalProps2}))
})
@@ -312,7 +312,7 @@ describe('modal reducer', () => {
type: 'VALIDATE_PERIOD_FORM',
modalProps : modProps3,
timeTablePeriods: ttperiods3,
- timeTableDates: ttdates3
+ currentMonthDaysIn: ttdates3
})
).toEqual(Object.assign({}, state3, {modalProps: newModalProps3}))
})
diff --git a/spec/javascripts/time_table/reducers/timetable_spec.js b/spec/javascripts/time_table/reducers/timetable_spec.js
index d9cc2fc07..b832c0a86 100644
--- a/spec/javascripts/time_table/reducers/timetable_spec.js
+++ b/spec/javascripts/time_table/reducers/timetable_spec.js
@@ -182,7 +182,7 @@ describe('timetable reducer with filled state', () => {
metas: {
day_types: arrDayTypes
},
- timeTableDates: state.time_table_dates
+ currentMonthDaysIn: time_table_dates
})
).toEqual(state)
})