diff --git a/js/components/date_selector.js b/js/components/date_selector.js index e5e48128..be6a8c89 100644 --- a/js/components/date_selector.js +++ b/js/components/date_selector.js @@ -62,18 +62,23 @@ export default { isMonthValid: function() { var _month = parseInt(this.month) - - return _month >= 0 && _month <= 12 + var valid = _month >= 0 && _month <= 12 + this._emitChange('month', this.month, valid) + return valid }, isDayValid: function() { var _day = parseInt(this.day) - - return _day >= 0 && _day <= this.daysMaxCalculation + var valid = _day >= 0 && _day <= this.daysMaxCalculation + this._emitChange('day', this.day, valid) + return valid }, isYearValid: function() { - return parseInt(this.year) >= 1 + // Emit a change event + var valid = parseInt(this.year) >= 1 + this._emitChange('year', this.year, valid) + return valid }, isWithinDateRange: function() { @@ -128,6 +133,12 @@ export default { }, }, + methods: { + _emitChange: function(name, value, valid) { + this.$root.$emit('field-change', { value, valid, name }) + }, + }, + render: function(createElement) { return createElement('p', 'Please implement inline-template') }, diff --git a/templates/fragments/edit_user_form.html b/templates/fragments/edit_user_form.html index fe821b65..436d5218 100644 --- a/templates/fragments/edit_user_form.html +++ b/templates/fragments/edit_user_form.html @@ -4,37 +4,41 @@ {% from "components/phone_input.html" import PhoneInput %} {% from "components/date_picker.html" import DatePicker %} -