From 5e8c860948cd4e7e4627417f7fc8beb1b0943c1e Mon Sep 17 00:00:00 2001 From: LukasBoll Date: Wed, 1 Mar 2023 10:52:39 +0100 Subject: [PATCH 01/17] vue: Fix onChange triggering twice by making additionalError and data proxies Fixes #2003 --- packages/vue/vue/src/components/JsonForms.vue | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/vue/vue/src/components/JsonForms.vue b/packages/vue/vue/src/components/JsonForms.vue index 673ecb3aa..555351adc 100644 --- a/packages/vue/vue/src/components/JsonForms.vue +++ b/packages/vue/vue/src/components/JsonForms.vue @@ -7,7 +7,7 @@ - - + + diff --git a/packages/vue/vue-vanilla/src/array/ArrayListElement.vue b/packages/vue/vue-vanilla/src/array/ArrayListElement.vue index 781f325a4..62e8da464 100644 --- a/packages/vue/vue-vanilla/src/array/ArrayListElement.vue +++ b/packages/vue/vue-vanilla/src/array/ArrayListElement.vue @@ -1,27 +1,27 @@ @@ -49,26 +49,26 @@ import { JsonFormsRendererRegistryEntry, rankWith, ControlElement, - schemaTypeIs + schemaTypeIs, } from '@jsonforms/core'; import { defineComponent } from 'vue'; import { DispatchRenderer, rendererProps, useJsonFormsArrayControl, - RendererProps + RendererProps, } from '../../config/jsonforms'; import { useVanillaArrayControl } from '../util'; import ArrayListElement from './ArrayListElement.vue'; const controlRenderer = defineComponent({ - name: 'array-list-renderer', + name: 'ArrayListRenderer', components: { ArrayListElement, - DispatchRenderer + DispatchRenderer, }, props: { - ...rendererProps() + ...rendererProps(), }, setup(props: RendererProps) { return useVanillaArrayControl(useJsonFormsArrayControl(props)); @@ -76,7 +76,7 @@ const controlRenderer = defineComponent({ computed: { noData(): boolean { return !this.control.data || this.control.data.length === 0; - } + }, }, methods: { composePaths, @@ -86,14 +86,14 @@ const controlRenderer = defineComponent({ this.control.path, createDefaultValue(this.control.schema) )(); - } - } + }, + }, }); export default controlRenderer; export const entry: JsonFormsRendererRegistryEntry = { renderer: controlRenderer, - tester: rankWith(2, schemaTypeIs('array')) + tester: rankWith(2, schemaTypeIs('array')), }; diff --git a/packages/vue/vue-vanilla/src/array/index.ts b/packages/vue/vue-vanilla/src/array/index.ts index 2d7e3c0b8..83d9c9029 100644 --- a/packages/vue/vue-vanilla/src/array/index.ts +++ b/packages/vue/vue-vanilla/src/array/index.ts @@ -2,6 +2,4 @@ export { default as ArrayListRenderer } from './ArrayListRenderer.vue'; import { entry as arrayListRendererEntry } from './ArrayListRenderer.vue'; -export const arrayRenderers = [ - arrayListRendererEntry -] +export const arrayRenderers = [arrayListRendererEntry]; diff --git a/packages/vue/vue-vanilla/src/controls/BooleanControlRenderer.vue b/packages/vue/vue-vanilla/src/controls/BooleanControlRenderer.vue index 59c816fa5..d8332eb82 100644 --- a/packages/vue/vue-vanilla/src/controls/BooleanControlRenderer.vue +++ b/packages/vue/vue-vanilla/src/controls/BooleanControlRenderer.vue @@ -2,13 +2,13 @@ () + ...rendererProps(), }, setup(props: RendererProps) { - return useVanillaControl(useJsonFormsControl(props), target => target.checked); - } + return useVanillaControl( + useJsonFormsControl(props), + (target) => target.checked + ); + }, }); export default controlRenderer; export const entry: JsonFormsRendererRegistryEntry = { renderer: controlRenderer, - tester: rankWith(1, isBooleanControl) + tester: rankWith(1, isBooleanControl), }; diff --git a/packages/vue/vue-vanilla/src/controls/ControlWrapper.vue b/packages/vue/vue-vanilla/src/controls/ControlWrapper.vue index 72b044370..9880e1008 100644 --- a/packages/vue/vue-vanilla/src/controls/ControlWrapper.vue +++ b/packages/vue/vue-vanilla/src/controls/ControlWrapper.vue @@ -1,5 +1,5 @@ @@ -33,30 +32,36 @@ import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, - isEnumControl + isEnumControl, } from '@jsonforms/core'; import { defineComponent } from 'vue'; -import { rendererProps, useJsonFormsEnumControl, RendererProps } from '../../config/jsonforms'; +import { + rendererProps, + useJsonFormsEnumControl, + RendererProps, +} from '../../config/jsonforms'; import { default as ControlWrapper } from './ControlWrapper.vue'; import { useVanillaControl } from '../util'; const controlRenderer = defineComponent({ - name: 'enum-control-renderer', + name: 'EnumControlRenderer', components: { - ControlWrapper + ControlWrapper, }, props: { - ...rendererProps() + ...rendererProps(), }, setup(props: RendererProps) { - return useVanillaControl(useJsonFormsEnumControl(props), target => target.selectedIndex === 0 ? undefined : target.value); - } + return useVanillaControl(useJsonFormsEnumControl(props), (target) => + target.selectedIndex === 0 ? undefined : target.value + ); + }, }); export default controlRenderer; export const entry: JsonFormsRendererRegistryEntry = { renderer: controlRenderer, - tester: rankWith(2, isEnumControl) + tester: rankWith(2, isEnumControl), }; diff --git a/packages/vue/vue-vanilla/src/controls/EnumOneOfControlRenderer.vue b/packages/vue/vue-vanilla/src/controls/EnumOneOfControlRenderer.vue index 14e6106ec..7dd3855a4 100644 --- a/packages/vue/vue-vanilla/src/controls/EnumOneOfControlRenderer.vue +++ b/packages/vue/vue-vanilla/src/controls/EnumOneOfControlRenderer.vue @@ -2,8 +2,8 @@ + > + @@ -33,30 +32,36 @@ import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, - isOneOfEnumControl + isOneOfEnumControl, } from '@jsonforms/core'; import { defineComponent } from 'vue'; -import { rendererProps, useJsonFormsOneOfEnumControl, RendererProps } from '../../config/jsonforms'; +import { + rendererProps, + useJsonFormsOneOfEnumControl, + RendererProps, +} from '../../config/jsonforms'; import { default as ControlWrapper } from './ControlWrapper.vue'; import { useVanillaControl } from '../util'; const controlRenderer = defineComponent({ - name: 'enum-oneof-control-renderer', + name: 'EnumOneofControlRenderer', components: { - ControlWrapper + ControlWrapper, }, props: { - ...rendererProps() + ...rendererProps(), }, setup(props: RendererProps) { - return useVanillaControl(useJsonFormsOneOfEnumControl(props), target => target.selectedIndex === 0 ? undefined : target.value ); - } + return useVanillaControl(useJsonFormsOneOfEnumControl(props), (target) => + target.selectedIndex === 0 ? undefined : target.value + ); + }, }); export default controlRenderer; export const entry: JsonFormsRendererRegistryEntry = { renderer: controlRenderer, - tester: rankWith(2, isOneOfEnumControl) + tester: rankWith(2, isOneOfEnumControl), }; diff --git a/packages/vue/vue-vanilla/src/controls/IntegerControlRenderer.vue b/packages/vue/vue-vanilla/src/controls/IntegerControlRenderer.vue index 8f72afb5c..0e0654c5d 100644 --- a/packages/vue/vue-vanilla/src/controls/IntegerControlRenderer.vue +++ b/packages/vue/vue-vanilla/src/controls/IntegerControlRenderer.vue @@ -2,13 +2,13 @@ () + ...rendererProps(), }, setup(props: RendererProps) { - return useVanillaControl(useJsonFormsControl(props), target => target.value === '' ? undefined : parseInt(target.value, 10)); + return useVanillaControl(useJsonFormsControl(props), (target) => + target.value === '' ? undefined : parseInt(target.value, 10) + ); }, }); @@ -50,6 +56,6 @@ export default controlRenderer; export const entry: JsonFormsRendererRegistryEntry = { renderer: controlRenderer, - tester: rankWith(1, isIntegerControl) + tester: rankWith(1, isIntegerControl), }; diff --git a/packages/vue/vue-vanilla/src/controls/MultiStringControlRenderer.vue b/packages/vue/vue-vanilla/src/controls/MultiStringControlRenderer.vue index 6d785e8dc..0d1b80e36 100644 --- a/packages/vue/vue-vanilla/src/controls/MultiStringControlRenderer.vue +++ b/packages/vue/vue-vanilla/src/controls/MultiStringControlRenderer.vue @@ -2,8 +2,8 @@