Use form mixin for add field change handler
This commit is contained in:
parent
f599abb5dd
commit
b8a983f4dc
@ -1,12 +1,15 @@
|
|||||||
import createNumberMask from 'text-mask-addons/dist/createNumberMask'
|
import createNumberMask from 'text-mask-addons/dist/createNumberMask'
|
||||||
import { conformToMask } from 'vue-text-mask'
|
import { conformToMask } from 'vue-text-mask'
|
||||||
|
|
||||||
|
import FormMixin from '../../mixins/form'
|
||||||
import textinput from '../text_input'
|
import textinput from '../text_input'
|
||||||
import optionsinput from '../options_input'
|
import optionsinput from '../options_input'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'details-of-use',
|
name: 'details-of-use',
|
||||||
|
|
||||||
|
mixins: [FormMixin],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
textinput,
|
textinput,
|
||||||
optionsinput,
|
optionsinput,
|
||||||
@ -33,10 +36,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted: function () {
|
|
||||||
this.$root.$on('field-change', this.handleFieldChange)
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
annualSpend: function () {
|
annualSpend: function () {
|
||||||
const monthlySpend = this.estimated_monthly_spend || 0
|
const monthlySpend = this.estimated_monthly_spend || 0
|
||||||
@ -60,12 +59,6 @@ export default {
|
|||||||
formatDollars: function (intValue) {
|
formatDollars: function (intValue) {
|
||||||
const mask = createNumberMask({ prefix: '$', allowDecimal: true })
|
const mask = createNumberMask({ prefix: '$', allowDecimal: true })
|
||||||
return conformToMask(intValue.toString(), mask).conformedValue
|
return conformToMask(intValue.toString(), mask).conformedValue
|
||||||
},
|
|
||||||
handleFieldChange: function (event) {
|
|
||||||
const { value, name } = event
|
|
||||||
if (typeof this[name] !== undefined) {
|
|
||||||
this[name] = value
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
|
import FormMixin from '../../mixins/form'
|
||||||
import optionsinput from '../options_input'
|
import optionsinput from '../options_input'
|
||||||
import textinput from '../text_input'
|
import textinput from '../text_input'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'financial',
|
name: 'financial',
|
||||||
|
|
||||||
|
mixins: [FormMixin],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
optionsinput,
|
optionsinput,
|
||||||
textinput,
|
textinput,
|
||||||
@ -24,18 +27,5 @@ export default {
|
|||||||
return {
|
return {
|
||||||
funding_type
|
funding_type
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
mounted: function () {
|
|
||||||
this.$root.$on('field-change', this.handleFieldChange)
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
handleFieldChange: function (event) {
|
|
||||||
const { value, name } = event
|
|
||||||
if (typeof this[name] !== undefined) {
|
|
||||||
this[name] = value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import FormMixin from '../../mixins/form'
|
||||||
import optionsinput from '../options_input'
|
import optionsinput from '../options_input'
|
||||||
import textinput from '../text_input'
|
import textinput from '../text_input'
|
||||||
import checkboxinput from '../checkbox_input'
|
import checkboxinput from '../checkbox_input'
|
||||||
@ -5,6 +6,8 @@ import checkboxinput from '../checkbox_input'
|
|||||||
export default {
|
export default {
|
||||||
name: 'poc',
|
name: 'poc',
|
||||||
|
|
||||||
|
mixins: [FormMixin],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
optionsinput,
|
optionsinput,
|
||||||
textinput,
|
textinput,
|
||||||
@ -26,18 +29,5 @@ export default {
|
|||||||
return {
|
return {
|
||||||
am_poc
|
am_poc
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
mounted: function () {
|
|
||||||
this.$root.$on('field-change', this.handleFieldChange)
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
handleFieldChange: function (event) {
|
|
||||||
const { value, name } = event
|
|
||||||
if (typeof this[name] !== undefined) {
|
|
||||||
this[name] = value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
js/mixins/form.js
Normal file
14
js/mixins/form.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export default {
|
||||||
|
mounted: function () {
|
||||||
|
this.$root.$on('field-change', this.handleFieldChange)
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
handleFieldChange: function (event) {
|
||||||
|
const { value, name } = event
|
||||||
|
if (typeof this[name] !== undefined) {
|
||||||
|
this[name] = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user