- onUpdatePeriodForm(e.currentTarget.value, 'end', 'day')} id="q_validity_period_end_gteq_3i" className="date required form-control">
+ onUpdatePeriodForm(e, 'end', 'day')} id="q_validity_period_end_gteq_3i" className="date required form-control">
{makeDaysOptions(modal.modalProps.end.day)}
- onUpdatePeriodForm(e.currentTarget.value, 'end', 'month')} id="q_validity_period_end_gteq_2i" className="date required form-control">
+ onUpdatePeriodForm(e, 'end', 'month')} id="q_validity_period_end_gteq_2i" className="date required form-control">
{makeMonthsOptions(modal.modalProps.end.month)}
- onUpdatePeriodForm(e.currentTarget.value, 'end', 'year')} id="q_validity_period_end_gteq_1i" className="date required form-control">
+ onUpdatePeriodForm(e, 'end', 'year')} id="q_validity_period_end_gteq_1i" className="date required form-control">
{makeYearsOptions(modal.modalProps.end.year)}
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 b6004c7f1..a7edbc328 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/containers/PeriodForm.js
@@ -18,8 +18,10 @@ const mapDispatchToProps = (dispatch) => {
onClosePeriodForm: () => {
dispatch(actions.closePeriodForm())
},
- onUpdatePeriodForm: (val, group, selectType) => {
- dispatch(actions.updatePeriodForm(val, group, selectType))
+ onUpdatePeriodForm: (e, group, selectType) => {
+ dispatch(actions.updatePeriodForm(e.currentTarget.value, group, selectType))
+ let selector = '#q_validity_period_' + group + '_gteq_3i'
+ dispatch(actions.updatePeriodForm($(selector).val(), group, 'day'))
},
onValidatePeriodForm: (modalProps, timeTablePeriods, metas) => {
dispatch(actions.validatePeriodForm(modalProps, timeTablePeriods, metas))
diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee
index 7ea634a19..8e416de82 100644
--- a/app/assets/javascripts/smart_date.coffee
+++ b/app/assets/javascripts/smart_date.coffee
@@ -1,15 +1,15 @@
-legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+window.legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
-isLeapYear = (year) ->
+window.isLeapYear = (year) ->
(year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0))
-correctDay = (dateValues) ->
+window.correctDay = (dateValues) ->
[day, month, year] = dateValues
return day if legalDaysPerMonth[month-1] >= day
return 29 if day == 29 && isLeapYear(year)
legalDaysPerMonth[month-1]
-smartCorrectDate = ->
+window.smartCorrectDate = ->
allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ?
allVals = allSelectors.map (index, sel) ->
parseInt($(sel).val())
--
cgit v1.2.3
From 3b0c79da928859988b6da5a8358a0b953c334ca9 Mon Sep 17 00:00:00 2001
From: Robert
Date: Wed, 28 Jun 2017 16:24:17 +0200
Subject: Hotfix Fixes: #3906@1h
---
app/assets/javascripts/smart_date.coffee | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
(limited to 'app/assets/javascripts')
diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee
index 8e416de82..afc0c7ddf 100644
--- a/app/assets/javascripts/smart_date.coffee
+++ b/app/assets/javascripts/smart_date.coffee
@@ -1,16 +1,21 @@
-window.legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+window.legalDaysPerMonth =
+ false: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ true: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
-window.isLeapYear = (year) ->
- (year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0))
+window.legal
window.correctDay = (dateValues) ->
[day, month, year] = dateValues
- return day if legalDaysPerMonth[month-1] >= day
- return 29 if day == 29 && isLeapYear(year)
- legalDaysPerMonth[month-1]
+ return day unless day > 0 && month > 0 && year > 0
+
+ legallyMaximumDay = legalDaysPerMonth[isLeapYear(year)][month - 1]
+ Math.min day, legallyMaximumDay
+
+window.isLeapYear = (year) ->
+ (year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0))
window.smartCorrectDate = ->
- allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ?
+ allSelectors = $(@).parent().children('select')
allVals = allSelectors.map (index, sel) ->
parseInt($(sel).val())
correctedDay = correctDay allVals
--
cgit v1.2.3