Skip to content

Commit 2809a6d

Browse files
committed
Amélioration de la gestion des données et des validations dans les formulaires JSON, ajout de vérifications d'erreurs et nettoyage du code
1 parent a70199e commit 2809a6d

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

src/components/identityForm/index.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ div
1010
q-item(clickable v-close-popup v-for="schema in schemas" @click="addSchema(schema)")
1111
q-item-section
1212
q-item-label(v-text="schema.name")
13-
q-tab-panels(v-model="tab")
13+
q-tab-panels(v-model="tab" keep-alive)
1414
q-tab-panel(name="inetOrgPerson")
1515
sesame-json-form-renderer-api(
16+
v-if='identity.inetOrgPerson'
1617
schemaName="inetorgperson"
1718
v-model:data="identity.inetOrgPerson"
1819
v-model:validations="validations"
1920
:isNew="isNew"
2021
)
21-
q-tab-panel(v-for="tab in tabs" :key="tab" :name="tab")
22+
q-tab-panel(v-for="t in tabs" :key="t" :name="t")
23+
//- pre(v-html="JSON.stringify(identity.additionalFields.attributes[t], null, 2)")
2224
sesame-json-form-renderer-api(
23-
:schemaName="tab"
24-
v-model:data="identity.additionalFields.attributes[tab]"
25+
v-if='identity.additionalFields.attributes[t]'
26+
:schemaName="t"
27+
v-model:data="identity.additionalFields.attributes[t]"
2528
v-model:validations="validations"
2629
:isNew="isNew"
2730
)

src/components/jsonFormRendererApi.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template lang="pug">
22
div
3-
//- pre(v-html="JSON.stringify({ isNew }, null, 2)")
3+
//- pre(v-html="JSON.stringify({ data }, null, 2)")
44
json-forms(
55
:data="data"
66
:schema="schema"
@@ -65,11 +65,19 @@ const validations = defineModel('validations', {
6565
6666
const data = defineModel('data', {
6767
type: Object,
68-
default: {},
68+
required: true,
6969
});
7070
7171
function onChange(event: JsonFormsChangeEvent) {
72-
data.value = event.data || {};
72+
data.value = event.data;
73+
74+
if (!event.data) {
75+
console.error('error', event.errors);
76+
throw createError({
77+
message: 'Data is empty',
78+
status: 500,
79+
})
80+
}
7381
}
7482
7583
const getSchemaValidations = computed(() => {
@@ -99,7 +107,7 @@ const { data: result, pending, error, refresh } = await useHttp<any>(`/managemen
99107
100108
const identityForm = inject('identityForm') as Ref<any>;
101109
const employeeType = computed(() => {
102-
console.log('employeeType', identityForm.value?.inetOrgPerson?.employeeType);
110+
//console.log('employeeType', identityForm.value?.inetOrgPerson?.employeeType);
103111
return identityForm.value?.inetOrgPerson?.employeeType || 'LOCAL';
104112
});
105113

src/components/quasar-jsonform/controls/QArrayControlRenderer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const QStringControlRenderer = defineComponent({
8181
createValue(val, done) {
8282
if (!this.control.data) {
8383
this.control.data = []
84-
this.handleChange('', null)
84+
//this.handleChange('', null)
8585
}
8686
done(val, 'add-unique')
8787
},
@@ -125,7 +125,7 @@ const QStringControlRenderer = defineComponent({
125125
mounted() {
126126
if (!this.control.data) {
127127
this.control.data = []
128-
this.handleChange('', null)
128+
//this.handleChange('', null)
129129
}
130130
}
131131
});

src/components/quasar-jsonform/util/composition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const useQuasarControl = <
8484
: input.handleChange;
8585

8686
const onChange = (value: any) => {
87+
// console.debug('onChange', input.control.value.path, adaptValue(value))
8788
changeEmitter(input.control.value.path, adaptValue(value));
8889
};
8990

src/composables/useErrorHandling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type handleErrorPayload = {
1313
message?: string;
1414
};
1515

16-
const $q = useQuasar();
16+
//const $q = useQuasar();
1717

1818
export function useErrorHandling(): useErrorHandlingReturnType {
1919
function handleError(payload: handleErrorPayload) {

0 commit comments

Comments
 (0)