33 //- pre(v-html="JSON.stringify(identity, null, 2)")
44 q-tabs( v-model ="tab" align ="justify" )
55 q-tab( name ="inetOrgPerson" label ="inetOrgPerson" : alert= "getTabValidations('inetOrgPerson')" alert-icon ="mdi-alert" : class = "`q-mr-xs`" )
6- q-tab( v-for ="tab in tabs" : key= "tab" : name= "tab" : label= "tab" : alert= "getTabValidations(tab)" alert-icon ="mdi-alert" : class = "`q-mr-xs`" )
6+ q-tab.q-pr-none ( v-for ="tab in tabs" : key= "tab" : name= "tab" : alert= "getTabValidations(tab)" alert-icon ="mdi-alert" : class = "`q-mr-xs`" )
7+ div.flex.row.full-height.items-center ( style ='flex-wrap: nowrap;' )
8+ .q-tab__label ( v-text ='tab' )
9+ q-btn.q-ml-sm ( icon ='mdi-close' flat @click.native.stop ="removeTab(tab)" size ="sm" dense stretch )
710 q-btn-dropdown.full-height ( icon ="mdi-newspaper-plus" flat )
811 q-tooltip.text-body2 ( anchor ="top middle" self ="center middle" ) Ajouter un schéma
912 q-list
@@ -47,24 +50,22 @@ defineOptions({
4750type IdentityResponse = operations [' IdentitiesController_search' ][' responses' ][' 200' ][' content' ][' application/json' ]
4851type Identity = components [' schemas' ][' IdentitiesDto' ] & { _id: string }
4952
50- const props = defineProps (
51- {
52- identity: {
53- type: Object as PropType <Identity >,
54- required: true ,
55- default: {
56- additionalFields: {
57- objectClasses: [],
58- attributes: {},
59- },
53+ const props = defineProps ({
54+ identity: {
55+ type: Object as PropType <Identity >,
56+ required: true ,
57+ default: {
58+ additionalFields: {
59+ objectClasses: [],
60+ attributes: {},
6061 },
6162 },
62- isNew: {
63- type: Boolean ,
64- default: false ,
65- } ,
66- }
67- )
63+ },
64+ isNew: {
65+ type: Boolean ,
66+ default: false ,
67+ },
68+ } )
6869
6970const emits = defineEmits ([' refreshTarget' ])
7071
@@ -79,18 +80,25 @@ const validations = ref<Record<string, unknown> | null>(props.identity?.addition
7980
8081provide (' identityForm' , identity )
8182
82- watch (() => props .identity , () => {
83- identity .value = props .identity
84- tabs .value = props .identity ?.additionalFields ?.objectClasses ?? []
85- validations .value = props .identity ?.additionalFields ?.validations ?? null
86- })
83+ watch (
84+ () => props .identity ,
85+ () => {
86+ identity .value = props .identity
87+ tabs .value = props .identity ?.additionalFields ?.objectClasses ?? []
88+ validations .value = props .identity ?.additionalFields ?.validations ?? null
89+ },
90+ )
8791
8892const tab = ref (' inetOrgPerson' )
8993const error = ref (null )
9094
91- const { data : schemasResult, pending, refresh } = await useHttp <any >(` /management/identities/validation ` , {
95+ const {
96+ data : schemasResult,
97+ pending,
98+ refresh,
99+ } = await useHttp <any >(` /management/identities/validation ` , {
92100 method: ' GET' ,
93- });
101+ })
94102
95103const schemas = computed (() => {
96104 return schemasResult .value .data .filter ((schema : any ) => {
@@ -112,17 +120,22 @@ async function submit() {
112120 delete sanitizedIdentity .metadata
113121 if (sanitizedIdentity ?.additionalFields ?.validations ) delete sanitizedIdentity .additionalFields .validations
114122
115- const { data : result, pending, error, refresh } = await useHttp <any >(` /management/identities/${props .identity ._id } ` , {
123+ const {
124+ data : result,
125+ pending,
126+ error,
127+ refresh,
128+ } = await useHttp <any >(` /management/identities/${props .identity ._id } ` , {
116129 method: ' PATCH' ,
117130 body: sanitizedIdentity ,
118- });
131+ })
119132 if (error .value ) {
120133 console .log (' error' , error .value .data .validations )
121134 validations .value = { ... error .value .data .validations }
122135 // error.value = error.value.cause.response._data
123136 handleError ({
124137 error: error .value ,
125- message: ' Erreur lors de la sauvegarde'
138+ message: ' Erreur lors de la sauvegarde' ,
126139 })
127140 } else {
128141 validations .value = null
@@ -141,14 +154,19 @@ async function create() {
141154 const sanitizedIdentity = { ... props .identity }
142155 delete sanitizedIdentity .metadata
143156
144- const { data : result, pending, error, refresh } = await useHttp (` /management/identities ` , {
157+ const {
158+ data : result,
159+ pending,
160+ error,
161+ refresh,
162+ } = await useHttp (` /management/identities ` , {
145163 method: ' POST' ,
146164 body: { ... sanitizedIdentity },
147- });
165+ })
148166 if (error .value ) {
149167 handleError ({
150168 error: error .value ,
151- message: ' Erreur lors de la création'
169+ message: ' Erreur lors de la création' ,
152170 })
153171 console .log (' error' , error .value .data .validations )
154172 validations .value = { ... error .value .data .validations }
@@ -178,19 +196,22 @@ function getTabValidations(tab: string) {
178196}
179197
180198async function deleteIdentity() {
181- const { data : result, pending, error, refresh } = await useHttp (' /core/backends/delete' , {
199+ const {
200+ data : result,
201+ pending,
202+ error,
203+ refresh,
204+ } = await useHttp (' /core/backends/delete' , {
182205 method: ' POST' ,
183206 body: {
184- payload: [
185- props .identity ._id ,
186- ],
207+ payload: [props .identity ._id ],
187208 },
188209 })
189210 if (error .value ) {
190211 // Handle error during sync
191212 } else {
192213 $q .notify ({
193- message: " Identité supprimée" ,
214+ message: ' Identité supprimée' ,
194215 color: ' positive' ,
195216 position: ' top-right' ,
196217 icon: ' mdi-check-circle-outline' ,
@@ -201,18 +222,23 @@ async function deleteIdentity() {
201222}
202223
203224async function sync() {
204- const { data : result, pending, error, refresh } = await useHttp <any >(` /management/identities/${props .identity ._id }/state ` , {
225+ const {
226+ data : result,
227+ pending,
228+ error,
229+ refresh,
230+ } = await useHttp <any >(` /management/identities/${props .identity ._id }/state ` , {
205231 method: ' PATCH' ,
206232 body: {
207233 state: IdentityState .TO_SYNC ,
208234 },
209- });
235+ })
210236
211237 if (error .value ) {
212238 // Handle error during sync
213239 } else {
214240 $q .notify ({
215- message: " Mise en état, à synchroniser" ,
241+ message: ' Mise en état, à synchroniser' ,
216242 color: ' positive' ,
217243 position: ' top-right' ,
218244 icon: ' mdi-check-circle-outline' ,
@@ -222,6 +248,30 @@ async function sync() {
222248 }
223249}
224250
251+ function removeTab(tab ) {
252+ $q .dialog ({
253+ title: ' Suppression' ,
254+ message: ' Voulez-vous supprimer ce schéma ?' ,
255+ persistent: true ,
256+ ok: {
257+ push: true ,
258+ color: ' negative' ,
259+ label: ' Supprimer' ,
260+ },
261+ cancel: {
262+ push: true ,
263+ color: ' primary' ,
264+ label: ' Annuler' ,
265+ },
266+ }).onOk (() => {
267+ const index = tabs .value .indexOf (tab )
268+ tabs .value .splice (index , 1 )
269+ if (identity .value ?.additionalFields ?.attributes [tab ]) {
270+ delete identity .value .additionalFields .attributes [tab ]
271+ }
272+ })
273+ }
274+
225275function logs() {
226276 console .log (' logs' )
227277}
@@ -240,7 +290,6 @@ defineExpose({
240290})
241291 </script >
242292
243-
244293<style scoped>
245294/* Your styles here */
246295 </style >
0 commit comments