From df1cd23f150a35c5f331a9a7d19d75dcbf9aa20c Mon Sep 17 00:00:00 2001 From: "daniel.xiao" Date: Wed, 12 Aug 2020 19:49:07 +0800 Subject: [PATCH] fix(ncform): fixed array paths value when changed fix #162 --- .../components/vue-ncform/_others.html | 65 +++++++++++++++++-- .../src/components/vue-ncform/form-item.vue | 2 +- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/packages/ncform/examples/components/vue-ncform/_others.html b/packages/ncform/examples/components/vue-ncform/_others.html index ea648de..ed430a9 100644 --- a/packages/ncform/examples/components/vue-ncform/_others.html +++ b/packages/ncform/examples/components/vue-ncform/_others.html @@ -12,14 +12,17 @@ @@ -125,6 +128,56 @@ } } }, + { + id: md5('change paths'), + title: 'change paths', + isFormDirty: false, + formName: 'form_' + Math.random(), + formSchema: { + type: 'object', + properties: { + user: { + type: 'object', + properties: { + name: { + type: 'string' + } + } + }, + names: { + type: 'array', + items: { + type: 'string', + }, + ui: { + widgetConfig: { + showOneIfEmpty: true + } + } + }, + users: { + type: 'array', + items: { + type: 'object', + properties: { + firstname: { + type: 'string' + }, + lastname: { + type: 'string' + } + } + }, + ui: { + widgetConfig: { + showOneIfEmpty: true + } + } + + } + } + } + }, ] }, methods: { @@ -137,7 +190,7 @@ changeModel(formSchema) { formSchema.value = { user: { name: 'daniel' } }; }, - onChange({paths, itemValue, formValue, itemOldValue}) { + onChange({ paths, itemValue, formValue, itemOldValue }) { console.log('paths:', paths); console.log('itemValue:', itemValue); console.log('formValue:', JSON.stringify(formValue, null, 2)); diff --git a/packages/ncform/src/components/vue-ncform/form-item.vue b/packages/ncform/src/components/vue-ncform/form-item.vue index 54cfe1b..e7cab45 100755 --- a/packages/ncform/src/components/vue-ncform/form-item.vue +++ b/packages/ncform/src/components/vue-ncform/form-item.vue @@ -15,7 +15,7 @@