1313</template >
1414
1515<script setup lang="ts">
16- import { JsonForms } from ' @jsonforms/vue' ;
17- import {
18- defaultStyles ,
19- mergeStyles ,
20- vanillaRenderers ,
21- } from " @jsonforms/vue-vanilla" ;
22-
23- import type { JsonFormsChangeEvent } from ' @jsonforms/vue' ;
24- import { QuasarJsonformRenderer } from ' ./quasar-jsonform' ;
25- import { computed , provide , ref } from ' vue' ;
26- import { useFetch } from ' nuxt/app' ;
27- import type { ErrorObject } from ' ajv' ;
16+ import { JsonForms } from ' @jsonforms/vue'
17+ import { defaultStyles , mergeStyles , vanillaRenderers } from ' @jsonforms/vue-vanilla'
18+
19+ import type { JsonFormsChangeEvent } from ' @jsonforms/vue'
20+ import { QuasarJsonformRenderer } from ' ./quasar-jsonform'
21+ import { computed , provide , ref } from ' vue'
22+ import { useFetch } from ' nuxt/app'
23+ import type { ErrorObject } from ' ajv'
2824import type { components , operations } from ' #build/types/service-api'
2925type Identity = components [' schemas' ][' IdentitiesDto' ] & { _id: string }
3026
@@ -33,15 +29,15 @@ const customStyle = mergeStyles(defaultStyles, {
3329 input: ' inputstyle' ,
3430 error: ' errorstyle' ,
3531 },
36- });
32+ })
3733
38- provide (' styles' , customStyle );
34+ provide (' styles' , customStyle )
3935
4036const renderers = Object .freeze ([
4137 // ...vanillaRenderers,
4238 ... QuasarJsonformRenderer ,
4339 // Add custom renderers here
44- ]);
40+ ])
4541
4642const props = defineProps ({
4743 schemaName: {
@@ -56,23 +52,23 @@ const props = defineProps({
5652 type: Boolean ,
5753 default: false ,
5854 },
59- });
55+ })
6056
6157const validations = defineModel (' validations' , {
6258 type: Object ,
6359 default: {},
64- });
60+ })
6561
6662const data = defineModel (' data' , {
6763 type: Object ,
68- required: true ,
69- });
64+ // required: true,
65+ })
7066
7167function onChange(event : JsonFormsChangeEvent ) {
72- data .value = event .data ;
68+ data .value = event .data
7369
7470 if (! event .data ) {
75- console .error (' error' , event .errors );
71+ console .error (' error' , event .errors )
7672 throw createError ({
7773 message: ' Data is empty' ,
7874 status: 500 ,
@@ -82,36 +78,46 @@ function onChange(event: JsonFormsChangeEvent) {
8278
8379const getSchemaValidations = computed (() => {
8480 if (! props .validations || ! props .validations [props .schemaName ]) {
85- return [];
81+ return []
8682 }
87- const errorObject: ErrorObject [] = [];
83+ const errorObject: ErrorObject [] = []
8884 let validationList = props .validations [props .schemaName ]
8985 for (const key in validationList ) {
9086 errorObject .push ({
9187 message: validationList [key ],
9288 instancePath: ` /${key } ` ,
9389 keyword: ' type' ,
9490 params: {},
95- });
91+ })
9692 }
97- return errorObject ;
93+ return errorObject
9894})
9995
10096const mode = computed (() => {
101- return props .isNew ? ' create' : ' update' ;
102- });
97+ return props .isNew ? ' create' : ' update'
98+ })
10399
104- const { data : result, pending, error, refresh } = await useHttp <any >(` /management/identities/validation/${props .schemaName } ` , {
100+ const {
101+ data : result,
102+ pending,
103+ error,
104+ refresh,
105+ } = await useHttp <any >(` /management/identities/validation/${props .schemaName } ` , {
105106 method: ' GET' ,
106- });
107+ })
107108
108- const identityForm = inject (' identityForm' ) as Ref <any >;
109+ const identityForm = inject (' identityForm' ) as Ref <any >
109110const employeeType = computed (() => {
110111 // console.log('employeeType', identityForm.value?.inetOrgPerson?.employeeType);
111- return identityForm .value ?.inetOrgPerson ?.employeeType || ' LOCAL' ;
112- });
112+ return identityForm .value ?.inetOrgPerson ?.employeeType || ' LOCAL'
113+ })
113114
114- const { data : resultUi, pending : pendingUi, error : errorUi, refresh : refreshUi } = await useHttp <any >(` /management/identities/jsonforms/${props .schemaName } ` , {
115+ const {
116+ data : resultUi,
117+ pending : pendingUi,
118+ error : errorUi,
119+ refresh : refreshUi,
120+ } = await useHttp <any >(` /management/identities/jsonforms/${props .schemaName } ` , {
115121 method: ' POST' ,
116122 params: {
117123 mode ,
@@ -123,12 +129,12 @@ const { data: resultUi, pending: pendingUi, error: errorUi, refresh: refreshUi }
123129 body: {
124130 employeeType ,
125131 },
126- });
132+ })
127133
128134// const schema = ref({ ...result.value.data });
129135// const uischema = ref({ ...resultUi.value.data });
130- const schema = computed (() => result .value ?.data );
131- const uischema = computed (() => resultUi .value ?.data );
136+ const schema = computed (() => result .value ?.data )
137+ const uischema = computed (() => resultUi .value ?.data )
132138 </script >
133139
134140<style >
@@ -172,7 +178,9 @@ const uischema = computed(() => resultUi.value?.data);
172178 /* Supprime le contour par défaut lors de la sélection */
173179 box-shadow : 0 2px 5px rgba (0 , 0 , 0 , 0.1 );
174180 /* Légère ombre pour un effet en profondeur */
175- transition : border-color 0.2s , box-shadow 0.2s ;
181+ transition :
182+ border-color 0.2s ,
183+ box-shadow 0.2s ;
176184 /* Transition douce pour l'interaction */
177185}
178186
@@ -189,7 +197,6 @@ const uischema = computed(() => resultUi.value?.data);
189197 /* Set border color to red for error */
190198}
191199
192-
193200.description {
194201 display : none ;
195202}
0 commit comments