Skip to content

Commit cbccf24

Browse files
committed
Refactor identityForm component to improve tab management and enhance code readability
1 parent f17ec45 commit cbccf24

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/components/identityForm/index.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ const props = defineProps({
6767
},
6868
})
6969
70+
watch(
71+
() => props.identity._id,
72+
(id) => {
73+
if (!props.identity.additionalFields?.objectClasses.includes(tab.value)) {
74+
tab.value = 'inetOrgPerson'
75+
}
76+
},
77+
)
78+
7079
const emits = defineEmits(['refreshTarget'])
7180
7281
const $q = useQuasar()
@@ -113,6 +122,7 @@ async function addSchema(schema) {
113122
if (!identity.value.additionalFields.attributes) identity.value.additionalFields.attributes = {}
114123
identity.value.additionalFields.attributes[schema.name] = {}
115124
identity.value.additionalFields.objectClasses.push(schema.name)
125+
tab.value = schema.name
116126
}
117127
118128
async function submit() {
@@ -248,7 +258,7 @@ async function sync() {
248258
}
249259
}
250260
251-
function removeTab(tab) {
261+
function removeTab(t) {
252262
$q.dialog({
253263
title: 'Suppression',
254264
message: 'Voulez-vous supprimer ce schéma ?',
@@ -264,11 +274,12 @@ function removeTab(tab) {
264274
label: 'Annuler',
265275
},
266276
}).onOk(() => {
267-
const index = tabs.value.indexOf(tab)
277+
const index = tabs.value.indexOf(t)
268278
tabs.value.splice(index, 1)
269-
if (identity.value?.additionalFields?.attributes[tab]) {
270-
delete identity.value.additionalFields.attributes[tab]
279+
if (identity.value?.additionalFields?.attributes[t]) {
280+
delete identity.value.additionalFields.attributes[t]
271281
}
282+
tab.value = 'inetOrgPerson'
272283
})
273284
}
274285

0 commit comments

Comments
 (0)