Update TO form and nested components to emit directly to parent components instead of emitting from the root component

This commit is contained in:
leigh-mil
2019-11-07 15:02:20 -05:00
parent 92ce3420b6
commit c94570f83e
14 changed files with 131 additions and 79 deletions

View File

@@ -50,8 +50,12 @@ export default {
}
},
mounted: function() {
this.$on('field-change', this.handleFieldChange)
},
methods: {
handleDateChange: function(event) {
handleFieldChange: function(event) {
if (event.name.includes(START_DATE) && event.valid) {
let date = new Date(event.value)
this.minEndDate = this.calcMinEndDate(date)
@@ -59,6 +63,7 @@ export default {
let date = new Date(event.value)
this.maxStartDate = this.calcMaxStartDate(date)
}
this.$parent.$emit('field-change')
},
calcMaxStartDate: function(date) {
@@ -86,5 +91,9 @@ export default {
minEndProp: function() {
return format(this.minEndDate, 'YYYY-MM-DD')
},
valid: function() {
return this.$children.every(child => child.valid)
},
},
}