From bad80527a2083027835f072411a4eab8ac4df745 Mon Sep 17 00:00:00 2001 From: jpl Date: Wed, 21 Jun 2017 10:10:45 +0200 Subject: Refs #3804: updating OID formatting on VJ info modal --- .../vehicle_journeys/components/tools/EditVehicleJourney.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js index 932c56532..9919ee9dd 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -70,7 +70,7 @@ class EditVehicleJourney extends Component { -- cgit v1.2.3 From dc80c8b8a8bc3123973c471346c69445238d998e Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Wed, 21 Jun 2017 17:23:42 +0200 Subject: Refs #3338: Fix duplicate vj not multiplying departureDelta Signed-off-by: Thomas Shawarma Haddad --- .../javascripts/es6_browserified/vehicle_journeys/actions/index.js | 5 +++-- .../vehicle_journeys/components/tools/DuplicateVehicleJourney.js | 4 ++-- .../vehicle_journeys/containers/tools/DuplicateVehicleJourney.js | 4 ++-- .../es6_browserified/vehicle_journeys/reducers/vehicleJourneys.js | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js index 0af1bb53d..1997cc712 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js @@ -134,9 +134,10 @@ const actions = { type: 'SHIFT_VEHICLEJOURNEY', data }), - duplicateVehicleJourney : (data) => ({ + duplicateVehicleJourney : (data, departureDelta) => ({ type: 'DUPLICATE_VEHICLEJOURNEY', - data + data, + departureDelta }), deleteVehicleJourneys : () => ({ type: 'DELETE_VEHICLEJOURNEYS' diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 0cf102693..c136fda33 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -18,8 +18,8 @@ class DuplicateVehicleJourney extends Component { } } let val = actions.getDuplicateDelta(_.find(actions.getSelected(this.props.vehicleJourneys)[0].vehicle_journey_at_stops, {'dummy': false}), newDeparture) - this.refs.additional_time.value = parseInt(this.refs.additional_time.value) + val - this.props.onDuplicateVehicleJourney(this.refs) + this.refs.additional_time.value = parseInt(this.refs.additional_time.value) + this.props.onDuplicateVehicleJourney(this.refs, val) this.props.onModalClose() $('#DuplicateVehicleJourneyModal').modal('hide') } diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js index 6cf6f4039..224b52a19 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js @@ -19,8 +19,8 @@ const mapDispatchToProps = (dispatch) => { onOpenDuplicateModal: () =>{ dispatch(actions.openDuplicateModal()) }, - onDuplicateVehicleJourney: (data) =>{ - dispatch(actions.duplicateVehicleJourney(data)) + onDuplicateVehicleJourney: (data, departureDelta) =>{ + dispatch(actions.duplicateVehicleJourney(data, departureDelta)) } } } diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/vehicleJourneys.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/vehicleJourneys.js index c7e8d58e7..d463d4b8f 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/vehicleJourneys.js @@ -182,11 +182,12 @@ const vehicleJourneys = (state = [], action) => { let dupes = [] let selectedIndex let val = action.data.additional_time.value + let departureDelta = action.departureDelta state.map((vj, i) => { if(vj.selected){ selectedIndex = i for (i = 0; i< action.data.duplicate_number.value; i++){ - action.data.additional_time.value = val * (i + 1) + action.data.additional_time.value = (parseInt(val) * (i + 1)) + departureDelta dupeVj = vehicleJourney(vj, action, false) dupeVj.published_journey_name = dupeVj.published_journey_name + '-' + i dupeVj.selected = false -- cgit v1.2.3 From b565826d14db26bf9c77b68b6e90a6f209e6b5da Mon Sep 17 00:00:00 2001 From: jpl Date: Thu, 22 Jun 2017 09:38:41 +0200 Subject: Refs #3830: adding plural version for duplicate modal title on VJ --- .../vehicle_journeys/components/tools/DuplicateVehicleJourney.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index c136fda33..aa1a13b11 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -51,10 +51,9 @@ class DuplicateVehicleJourney extends Component {
-

Dupliquer une course

- {(this.props.modal.type == 'duplicate') && ( - Dupliquer les horaires de la course {actions.humanOID(actions.getSelected(this.props.vehicleJourneys)[0].objectid)} - )} +

+ Dupliquer { actions.getSelected(this.props.vehicleJourneys).length > 1 ? 'plusieurs courses' : 'une course' } +

{(this.props.modal.type == 'duplicate') && ( -- cgit v1.2.3 From 5a67b671e6d3bed8ff401d1c83d05a65c976f2aa Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Thu, 22 Jun 2017 15:46:05 +0200 Subject: Fix shifting vj before midnight Signed-off-by: Thomas Shawarma Haddad Signed-off-by: Cédric Njanga --- .../es6_browserified/vehicle_journeys/actions/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js index 1997cc712..e90d2d307 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js @@ -459,20 +459,20 @@ const actions = { schedule.arrival_time.hour = parseInt(schedule.arrival_time.hour) + hours } - if(schedule.departure_time.hour > 23){ + if(parseInt(schedule.departure_time.hour) > 23){ schedule.departure_time.hour = '23' schedule.departure_time.minute = '59' } - if(schedule.arrival_time.hour > 23){ + if(parseInt(schedule.arrival_time.hour) > 23){ schedule.arrival_time.hour = '23' schedule.arrival_time.minute = '59' } - if(schedule.departure_time.hour < 0){ + if(parseInt(schedule.departure_time.hour) < 0){ schedule.departure_time.hour = '00' schedule.departure_time.minute = '00' } - if(schedule.arrival_time.hour > 23){ + if(parseInt(schedule.arrival_time.hour) < 0){ schedule.arrival_time.hour = '00' schedule.arrival_time.minute = '00' } -- cgit v1.2.3 From 970954938043d8d73c4457ee2d91e22c0e422e65 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 23 Jun 2017 11:43:56 +0200 Subject: JS for date validation --- app/assets/javascripts/calendars.coffee | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/assets/javascripts/calendars.coffee (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/calendars.coffee b/app/assets/javascripts/calendars.coffee new file mode 100644 index 000000000..ac5330cc8 --- /dev/null +++ b/app/assets/javascripts/calendars.coffee @@ -0,0 +1,35 @@ + +isEmpty = (x) -> x == '' + +daySelector = '#q_contains_date_3i' +monthSelector = '#q_contains_date_2i' +yearSelector = '#q_contains_date_1i' + +dateSelectors = [ daySelector, monthSelector, yearSelector ] + +checkDate = (args...) -> + vals = args.map((ele) -> ele.val()) + return if vals.find( isEmpty ) == "" # no checking needed, no checking possible yet + + dates = vals.map (x) -> parseInt(x) + return if isLegalDate(dates) + $('.alert').text('illegal date') + $('.alert').show() + +legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +isLeapYear = (year) -> + (year % 4 == 0) && ((year % 100 != 0) || (year % 1000 == 0)) + +isLegalDate = (dates) -> + [day, month, year] = dates + return true if legalDaysPerMonth[month-1] >= day + return true if day == 29 && isLeapYear(year) + false + +defineChangeHandler = (selector) -> + $(selector).on 'change', -> + checkDate $(daySelector), $(monthSelector), $(yearSelector) + +$ -> + defineChangeHandler selector for selector in dateSelectors -- cgit v1.2.3 From b6f8729454b94c099332c972ff7e7992006b7483 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 27 Jun 2017 16:19:10 +0200 Subject: Refs: 3595@2h Coffee Script implemented --- app/assets/javascripts/calendars.coffee | 35 -------------------------------- app/assets/javascripts/smart_date.coffee | 17 ++++++++++++++++ 2 files changed, 17 insertions(+), 35 deletions(-) delete mode 100644 app/assets/javascripts/calendars.coffee create mode 100644 app/assets/javascripts/smart_date.coffee (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/calendars.coffee b/app/assets/javascripts/calendars.coffee deleted file mode 100644 index ac5330cc8..000000000 --- a/app/assets/javascripts/calendars.coffee +++ /dev/null @@ -1,35 +0,0 @@ - -isEmpty = (x) -> x == '' - -daySelector = '#q_contains_date_3i' -monthSelector = '#q_contains_date_2i' -yearSelector = '#q_contains_date_1i' - -dateSelectors = [ daySelector, monthSelector, yearSelector ] - -checkDate = (args...) -> - vals = args.map((ele) -> ele.val()) - return if vals.find( isEmpty ) == "" # no checking needed, no checking possible yet - - dates = vals.map (x) -> parseInt(x) - return if isLegalDate(dates) - $('.alert').text('illegal date') - $('.alert').show() - -legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - -isLeapYear = (year) -> - (year % 4 == 0) && ((year % 100 != 0) || (year % 1000 == 0)) - -isLegalDate = (dates) -> - [day, month, year] = dates - return true if legalDaysPerMonth[month-1] >= day - return true if day == 29 && isLeapYear(year) - false - -defineChangeHandler = (selector) -> - $(selector).on 'change', -> - checkDate $(daySelector), $(monthSelector), $(yearSelector) - -$ -> - defineChangeHandler selector for selector in dateSelectors diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee new file mode 100644 index 000000000..1698bee06 --- /dev/null +++ b/app/assets/javascripts/smart_date.coffee @@ -0,0 +1,17 @@ +legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +correctDay = (dateValues) -> + [day, month, year] = dates + return day if legalDaysPerMonth[month-1] >= day + return 29 if day == 29 && isLeapYear(year) + legalDaysPerMonth[month-1] + +smartCorrectDate = -> + allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ? + allVals = allSelectors.map (sel) -> paeseInt(sel.val()) + correctedDay = correctDay allVals + daySelector = allSelectors.first() + $(daySelector).val(correctedDay) + +$ -> + $(smartDateSelectSelector).on 'change', smartCorrectDate -- cgit v1.2.3 From 0a147aec1d594884478e9d7006941e7ab5167bec Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 27 Jun 2017 17:05:51 +0200 Subject: Refs: #3595@1h debugging smart_date.coffee --- app/assets/javascripts/smart_date.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee index 1698bee06..901b7a545 100644 --- a/app/assets/javascripts/smart_date.coffee +++ b/app/assets/javascripts/smart_date.coffee @@ -1,4 +1,7 @@ -legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +smartDateSelector = '.smart_date' +smartDateSelectSelector = "#{smartDateSelector} select" +legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] correctDay = (dateValues) -> [day, month, year] = dates @@ -8,7 +11,9 @@ correctDay = (dateValues) -> smartCorrectDate = -> allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ? - allVals = allSelectors.map (sel) -> paeseInt(sel.val()) + console.log allSelectors + allVals = allSelectors.map (sel) -> parseInt($(sel).val()) + console.log allVals correctedDay = correctDay allVals daySelector = allSelectors.first() $(daySelector).val(correctedDay) -- cgit v1.2.3 From dcf8868773491c66c4527fe768ceacef38cf0e16 Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Tue, 27 Jun 2017 17:34:55 +0200 Subject: Refs #3595: Fix coffeescript map not being compliant Signed-off-by: Thomas Shawarma Haddad --- app/assets/javascripts/smart_date.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee index 901b7a545..d9228670d 100644 --- a/app/assets/javascripts/smart_date.coffee +++ b/app/assets/javascripts/smart_date.coffee @@ -4,16 +4,15 @@ smartDateSelectSelector = "#{smartDateSelector} select" legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] correctDay = (dateValues) -> - [day, month, year] = dates + [day, month, year] = dateValues return day if legalDaysPerMonth[month-1] >= day return 29 if day == 29 && isLeapYear(year) legalDaysPerMonth[month-1] smartCorrectDate = -> allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ? - console.log allSelectors - allVals = allSelectors.map (sel) -> parseInt($(sel).val()) - console.log allVals + allVals = allSelectors.map (index, sel) -> + parseInt($(sel).val()) correctedDay = correctDay allVals daySelector = allSelectors.first() $(daySelector).val(correctedDay) -- cgit v1.2.3 From 083d23585935139b5e87b99bf5cc2a79f4a53cca Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 27 Jun 2017 19:58:48 +0200 Subject: Refs: #3595@0.5h live event subscription & smart_date class added to all date input elements --- app/assets/javascripts/smart_date.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee index d9228670d..7ea634a19 100644 --- a/app/assets/javascripts/smart_date.coffee +++ b/app/assets/javascripts/smart_date.coffee @@ -1,8 +1,8 @@ - -smartDateSelector = '.smart_date' -smartDateSelectSelector = "#{smartDateSelector} select" legalDaysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] +isLeapYear = (year) -> + (year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0)) + correctDay = (dateValues) -> [day, month, year] = dateValues return day if legalDaysPerMonth[month-1] >= day @@ -18,4 +18,4 @@ smartCorrectDate = -> $(daySelector).val(correctedDay) $ -> - $(smartDateSelectSelector).on 'change', smartCorrectDate + $(document).on 'change', '.smart_date select', smartCorrectDate -- cgit v1.2.3 From 5aae96793b28d083b16d5188068106eeb34e6071 Mon Sep 17 00:00:00 2001 From: jpl Date: Wed, 28 Jun 2017 12:09:58 +0200 Subject: Refs #3855: adding default value to shift modal, updating OID display --- .../vehicle_journeys/components/tools/ShiftVehicleJourney.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/ShiftVehicleJourney.js index ee7d01cf5..2164344c2 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/ShiftVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/ShiftVehicleJourney.js @@ -40,7 +40,7 @@ class ShiftVehicleJourney extends Component {

Mettre à jour une course

{(this.props.modal.type == 'shift') && ( - Mettre à jour les horaires de la course {actions.getSelected(this.props.vehicleJourneys)[0].objectid} + Mettre à jour les horaires de la course {actions.humanOID(actions.getSelected(this.props.vehicleJourneys)[0].objectid)} )}
@@ -57,6 +57,7 @@ class ShiftVehicleJourney extends Component { min='-59' max='59' className='form-control' + defaultValue='0' onKeyDown={(e) => actions.resetValidation(e.currentTarget)} required /> -- cgit v1.2.3 From 6d3d5d2da94b8c68a0d4930ed2f72c6a016260cb Mon Sep 17 00:00:00 2001 From: jpl Date: Wed, 28 Jun 2017 14:15:47 +0200 Subject: Refs #3902: fix clearFilter on VJ --- .../javascripts/es6_browserified/vehicle_journeys/reducers/filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js index 09588f824..b4a70ec08 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js @@ -15,7 +15,7 @@ const filters = (state = {}, action) => { minute: '59' } } - newQuery = _.assign({}, state.query, {interval: interval, journeyPattern: {}, vehicleJourney: {}, timetable: {}, withoutSchedule: true, withoutTimeTable: false }) + newQuery = _.assign({}, state.query, {interval: interval, journeyPattern: {}, vehicleJourney: {}, timetable: {}, withoutSchedule: true, withoutTimeTable: true }) return _.assign({}, state, {query: newQuery, queryString: ''}) case 'TOGGLE_WITHOUT_SCHEDULE': newQuery = _.assign({}, state.query, {withoutSchedule: !state.query.withoutSchedule}) -- cgit v1.2.3 From 87c3cb8bc4bb8127133f384609a727ad13281bfb Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Wed, 28 Jun 2017 14:24:31 +0200 Subject: Refs #3905 @3h : Use smart_date in timetable#edit Signed-off-by: Thomas Shawarma Haddad --- .../time_tables/components/PeriodForm.js | 16 ++++++++-------- .../time_tables/containers/PeriodForm.js | 6 ++++-- app/assets/javascripts/smart_date.coffee | 8 ++++---- 3 files changed, 16 insertions(+), 14 deletions(-) (limited to 'app/assets/javascripts') 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 1a6c67b6b..a8a92c522 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js +++ b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js @@ -61,30 +61,30 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
-
+
- onUpdatePeriodForm(e, 'begin', 'day')} id="q_validity_period_begin_gteq_3i" className="date required form-control"> {makeDaysOptions(modal.modalProps.begin.day)} - onUpdatePeriodForm(e, 'begin', 'month')} id="q_validity_period_begin_gteq_2i" className="date required form-control"> {makeMonthsOptions(modal.modalProps.begin.month)} - onUpdatePeriodForm(e, 'begin', 'year')} id="q_validity_period_begin_gteq_1i" className="date required form-control"> {makeYearsOptions(modal.modalProps.begin.year)}
-
+
- onUpdatePeriodForm(e, 'end', 'day')} id="q_validity_period_end_gteq_3i" className="date required form-control"> {makeDaysOptions(modal.modalProps.end.day)} - onUpdatePeriodForm(e, 'end', 'month')} id="q_validity_period_end_gteq_2i" className="date required form-control"> {makeMonthsOptions(modal.modalProps.end.month)} - 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