From 6b7871830ad6c13b774f93f996e18cb28ad6ca84 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 6 Dec 2019 13:38:06 -0300 Subject: [PATCH] fix(dynamic-field): using v-model, fix component api --- src/components/html/EcDynamicField.html | 3 +-- src/components/js/EcDynamicField.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/components/html/EcDynamicField.html b/src/components/html/EcDynamicField.html index f0b1d95..8afdb00 100644 --- a/src/components/html/EcDynamicField.html +++ b/src/components/html/EcDynamicField.html @@ -4,8 +4,7 @@ v-bind="{name: field, schema: schema}" v-if="dynamicField" :key="field" - :value="value" - @input="$emit('input', $event)" + v-model="localValue" :is="dynamicField" /> diff --git a/src/components/js/EcDynamicField.js b/src/components/js/EcDynamicField.js index cc78e01..f1dfc3b 100644 --- a/src/components/js/EcDynamicField.js +++ b/src/components/js/EcDynamicField.js @@ -2,18 +2,23 @@ import { discover } from '../../utils/Discoverer.js' export default { name: 'EcDynamicField', + props: { - field: { - type: String - }, - schema: { - type: Object - }, - value: { - type: [String, Number, Boolean, Object] - } + field: String, + schema: Object, + value: [String, Number, Boolean, Object] }, + computed: { + localValue: { + get () { + return this.value + }, + set (value) { + this.$emit('input', value) + } + }, + dynamicFields () { return discover(this.field, this.schema) }