Skip to content

Commit 954d9c6

Browse files
committed
chore: Update components to pass isNew prop to child components
1 parent cad8868 commit 954d9c6

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

src/components/2pan/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ q-splitter(
9393
q-tooltip.text-body2 Supprimer
9494
slot(name="right-panel-actions-content-after" :target="target" :isNew="isNew" :crud="crud")
9595
q-card-section.q-pa-none.fit.flex(style='flex-flow: column; overflow: hidden;')
96-
slot(name="right-panel-content" :payload="{ target }")
96+
slot(name="right-panel-content" :payload="{ target }" :isNew="isNew")
9797
slot(name="right-panel-content-before")
9898
slot(name="right-panel-content-after")
9999
q-expansion-item.bg-blue-grey-10(v-if='debug' label='Debug' icon='mdi-bug' dark dense)

src/components/identityForm/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ div
1616
schemaName="inetorgperson"
1717
v-model:data="identity.inetOrgPerson"
1818
v-model:validations="validations"
19+
:isNew="isNew"
1920
)
2021
q-tab-panel(v-for="tab in tabs" :key="tab" :name="tab")
2122
sesame-json-form-renderer-api(
2223
:schemaName="tab"
2324
v-model:data="identity.additionalFields.attributes[tab]"
2425
v-model:validations="validations"
26+
:isNew="isNew"
2527
)
2628
</template>
2729

@@ -53,7 +55,11 @@ const props = defineProps(
5355
attributes: {},
5456
},
5557
},
56-
}
58+
},
59+
isNew: {
60+
type: Boolean,
61+
default: false,
62+
},
5763
}
5864
)
5965

src/components/jsonFormRendererApi.vue

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<template lang="pug">
2-
json-forms(
3-
v-if="data"
4-
:data="data"
5-
:schema="schema"
6-
:uischema="uischema"
7-
:renderers="renderers"
8-
validationMode="ValidateAndShow"
9-
:additionalErrors="getSchemaValidations"
10-
@change="onChange"
11-
)
2+
div
3+
//- pre(v-html="JSON.stringify({ isNew }, null, 2)")
4+
json-forms(
5+
:data="data"
6+
:schema="schema"
7+
:uischema="uischema"
8+
:renderers="renderers"
9+
validationMode="ValidateAndShow"
10+
:additionalErrors="getSchemaValidations"
11+
@change="onChange"
12+
)
1213
</template>
1314

1415
<script setup lang="ts">
@@ -49,6 +50,10 @@ const props = defineProps({
4950
type: Object || null,
5051
default: {},
5152
},
53+
isNew: {
54+
type: Boolean,
55+
default: false,
56+
},
5257
});
5358
5459
const validations = defineModel('validations', {
@@ -62,7 +67,7 @@ const data = defineModel('data', {
6267
});
6368
6469
function onChange(event: JsonFormsChangeEvent) {
65-
data.value = event.data;
70+
data.value = event.data || {};
6671
}
6772
6873
const getSchemaValidations = computed(() => {
@@ -82,17 +87,25 @@ const getSchemaValidations = computed(() => {
8287
return errorObject;
8388
})
8489
90+
const mode = computed(() => {
91+
return props.isNew ? 'create' : 'update';
92+
});
8593
86-
const { data: result, pending, error, refresh } = await useHttp(`/management/identities/validation/${props.schemaName}`, {
94+
const { data: result, pending, error, refresh } = await useHttp<any>(`/management/identities/validation/${props.schemaName}`, {
8795
method: 'GET',
8896
});
8997
90-
const { data: resultUi, pending: pendingUi, error: errorUi, refresh: refreshUi } = await useHttp(`/management/identities/jsonforms/${props.schemaName}`, {
98+
const { data: resultUi, pending: pendingUi, error: errorUi, refresh: refreshUi } = await useHttp<any>(`/management/identities/jsonforms/${props.schemaName}`, {
9199
method: 'GET',
100+
params: {
101+
mode,
102+
},
92103
});
93104
94-
const schema = ref(result.value.data);
95-
const uischema = ref(resultUi.value.data);
105+
// const schema = ref({ ...result.value.data });
106+
// const uischema = ref({ ...resultUi.value.data });
107+
const schema = computed(() => result.value?.data);
108+
const uischema = computed(() => resultUi.value?.data);
96109
</script>
97110

98111
<style>

src/pages/identities/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ q-page.container
2929
sesame-table-state-col(:identity="props.row")
3030
template(#right-panel-actions-content-after="{target, crud, isNew}")
3131
sesame-identity-form-actions(:identity="target" @submit="submit($event)" @create="create($event)" @sync="sync" @logs="logs" :crud="crud" :isNew="isNew")
32-
template(#right-panel-content="{payload}")
32+
template(#right-panel-content="{payload, isNew}")
3333
sesame-identity-form(
3434
:identity="{...payload.target}"
35-
ref="form" @refresh="refresh"
35+
ref="form"
36+
:isNew="isNew"
37+
@refresh="refresh"
3638
@submit="submit($event)"
3739
@sync="sync" @logs="logs"
3840
@refreshTarget="refreshTarget"

0 commit comments

Comments
 (0)