aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/smart_date.coffee9
-rw-r--r--app/views/calendars/_period_fields.html.slim4
2 files changed, 9 insertions, 4 deletions
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)
diff --git a/app/views/calendars/_period_fields.html.slim b/app/views/calendars/_period_fields.html.slim
index 1e201a39f..95e204554 100644
--- a/app/views/calendars/_period_fields.html.slim
+++ b/app/views/calendars/_period_fields.html.slim
@@ -8,8 +8,8 @@
.wrapper
div
- = f.input :begin, as: :date, label: false, wrapper_html: { class: 'date' }
+ = f.input :begin, as: :date, label: false, wrapper_html: { class: 'date smart_date' }
div
- = f.input :end, as: :date, label: false, wrapper_html: { class: 'date' }
+ = f.input :end, as: :date, label: false, wrapper_html: { class: 'date smart_date' }
div
= link_to_remove_association '', f, class: 'fa fa-trash', data: { confirm: 'Etes-vous sûr(e) ?' }, title: t('actions.delete')