forked from eclipsesource/jsonforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectRenderer.vue
More file actions
84 lines (78 loc) · 1.92 KB
/
ObjectRenderer.vue
File metadata and controls
84 lines (78 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<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 {
JsonFormsRendererRegistryEntry,
rankWith,
ControlElement,
Generate,
GroupLayout,
UISchemaElement,
findUISchema,
isObjectControl,
} from '@jsonforms/core';
import { defineComponent } from 'vue';
import {
DispatchRenderer,
rendererProps,
RendererProps,
useJsonFormsControlWithDetail,
} from '../../config/jsonforms';
import { useVanillaControl } from '../util';
import { isEmpty } from 'lodash';
const controlRenderer = defineComponent({
name: 'ObjectRenderer',
components: {
DispatchRenderer,
},
props: {
...rendererProps<ControlElement>(),
},
setup(props: RendererProps<ControlElement>) {
const control = useVanillaControl(useJsonFormsControlWithDetail(props));
return {
...control,
input: control,
};
},
computed: {
detailUiSchema(): UISchemaElement {
const uiSchemaGenerator = () => {
const uiSchema = Generate.uiSchema(this.control.schema, 'Group');
if (isEmpty(this.control.path)) {
uiSchema.type = 'VerticalLayout';
} else {
(uiSchema as GroupLayout).label = this.control.label;
}
return uiSchema;
};
const result = findUISchema(
this.control.uischemas,
this.control.schema,
this.control.uischema.scope,
this.control.path,
uiSchemaGenerator,
this.control.uischema,
this.control.rootSchema
);
return result;
},
},
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(2, isObjectControl),
};
</script>