From 85b6287e0c9cd3f75850cb6c80c2d60bef724b61 Mon Sep 17 00:00:00 2001 From: Montana Date: Fri, 19 Apr 2019 11:06:19 -0400 Subject: [PATCH] Emit field's parent uid on mount --- js/components/text_input.js | 7 ++++--- js/lib/emitters.js | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/components/text_input.js b/js/components/text_input.js index 51972d82..75c9d5f0 100644 --- a/js/components/text_input.js +++ b/js/components/text_input.js @@ -1,7 +1,7 @@ import MaskedInput, { conformToMask } from 'vue-text-mask' import inputValidations from '../lib/input_validations' import { formatDollars } from '../lib/dollars' -import { emitFieldChange } from '../lib/emitters' +import { emitFieldChange, emitFieldMount } from '../lib/emitters' export default { name: 'textinput', @@ -27,6 +27,7 @@ export default { paragraph: String, noMaxWidth: String, optional: Boolean, + parent_uid: String, }, data: function() { @@ -67,9 +68,9 @@ export default { }, created: function() { - this.$root.$emit('field-mount', { - name: this.name, + emitFieldMount(this, { optional: this.optional, + name: this.name, }) }, diff --git a/js/lib/emitters.js b/js/lib/emitters.js index 8bed5096..c4cc3bf4 100644 --- a/js/lib/emitters.js +++ b/js/lib/emitters.js @@ -4,3 +4,10 @@ export const emitFieldChange = (el, data) => { parent_uid: el.$parent && el.$parent._uid, }) } + +export const emitFieldMount = (el, data) => { + el.$root.$emit('field-mount', { + ...data, + parent_uid: el.$parent && el.$parent._uid, + }) +}