Hey @sdirix ,
Nice! I managed to implement it quite easily since most of my renderers are already custom.
I’m just having an issue with my ObjectRenderer. In this case, it only displays/computes the errors when something is inserted. Meaning, before any letter is inserted in one of the fields, none of the fields get evaluated for errors (only the parent property does).
Not sure if there is anything I need to change in my ObjectRenderer? Now I’d rather this show all the errors even for ObjectRenderers, since I can now control them via the new touched
property I created.
Here is my Object Renderer:
<template>
<div v-if="control.visible">
<dispatch-renderer :visible="control.visible"
:enabled="control.enabled"
:schema="control.schema"
:uischema="detailUiSchema"
:path="control.path"
:renderers="control.renderers"
:cells="control.cells" />
</div>
</template>
<script lang="ts">
import {
ControlElement,
findUISchema,
Generate,
isObjectControl,
JsonFormsRendererRegistryEntry,
rankWith,
UISchemaElement,
} from '@jsonforms/core'
import { DispatchRenderer, rendererProps, RendererProps, useJsonFormsControlWithDetail } from '@jsonforms/vue'
import { defineComponent } from 'vue'
import { useVanillaControl } from '@jsonforms/vue-vanilla'
const applyFormRenderObject = defineComponent({
name: 'object-renderer',
components: { DispatchRenderer },
props: {
...rendererProps<ControlElement>(),
},
setup (props: RendererProps<ControlElement>) {
const control = useVanillaControl(useJsonFormsControlWithDetail(props))
return {
...control,
input: control,
}
},
computed: {
detailUiSchema (): UISchemaElement {
const uiSchemaGenerator = () => {
return Generate.uiSchema(this.control.schema, 'VerticalLayout')
}
return findUISchema(
this.control.uischemas,
this.control.schema,
this.control.uischema.scope,
this.control.path,
uiSchemaGenerator,
this.control.uischema,
this.control.rootSchema,
)
},
},
})
export default applyFormRenderObject
export const entry: JsonFormsRendererRegistryEntry = {
renderer: applyFormRenderObject,
tester: rankWith(2, isObjectControl),
}
</script>