codevdesign 1.0.70 → 1.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,372 +1,372 @@
1
- <template>
2
- <div class="pa-2 mt-2 mb-1 mr-1">
3
- <!-- Affiche la carte récap si activée et qu'il y a des unités -->
4
- <div v-if="activerDivPreferences && unites && unites.length > 0">
5
- <v-card
6
- max-width="375"
7
- width="100%"
8
- variant="outlined"
9
- >
10
- <v-card-text class="pt-0 mt-0">
11
- <v-progress-linear
12
- v-if="chargementEnCours"
13
- indeterminate
14
- />
15
-
16
- <div
17
- v-else
18
- class="pt-2"
19
- >
20
- <div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
21
-
22
- <div>
23
- <v-list-item
24
- v-for="uniteId in Object.keys(dictChaisesReleve)"
25
- :key="uniteId"
26
- class="mb-1"
27
- >
28
- <ChaisePreferenceItem
29
- :uniteId="Number(uniteId)"
30
- :preferences="preferences"
31
- :dictChaisesReleve="dictChaisesReleve"
32
- :unites="unites"
33
- />
34
- </v-list-item>
35
- </div>
36
- </div>
37
- </v-card-text>
38
-
39
- <v-card-actions>
40
- <div class="flex-grow-1" />
41
- <v-btn
42
- v-if="!chargementEnCours"
43
- rounded
44
- variant="outlined"
45
- size="small"
46
- @click.stop="modifier"
47
- >
48
- {{ texteBoutonModifier }}
49
- </v-btn>
50
- </v-card-actions>
51
- </v-card>
52
- </div>
53
-
54
- <csqcDialogue
55
- ref="modale"
56
- :operation-en-cours="chargementEnCours"
57
- :btn-ok-desactiver="chargementEnCours"
58
- :titre="texteTitre"
59
- :btn-annuler-texte="texteBoutonAnnuler"
60
- @annuler="annuler"
61
- @ok="ok"
62
- ><template #content>
63
- <div class="pt-2"></div>
64
- <hr class="pt-0 mt-0 pl-0" />
65
- <div class="pt-4">
66
- <i>{{ info }}</i>
67
-
68
- <v-progress-linear
69
- v-if="chargementEnCours"
70
- indeterminate
71
- />
72
-
73
- <div
74
- v-else
75
- class="pt-4"
76
- >
77
- <v-row v-if="!toutesUnitesPreferencesSelectionnees">
78
- <v-col cols="12">
79
- <v-alert
80
- v-model="afficherErreur"
81
- type="error"
82
- variant="tonal"
83
- dismissible
84
- >
85
- {{ texteMessageErreur }}
86
- </v-alert>
87
- </v-col>
88
- </v-row>
89
-
90
- <v-row>
91
- <v-col
92
- v-for="uniteId in Object.keys(dictChaisesReleve)"
93
- :key="uniteId"
94
- cols="12"
95
- sm="6"
96
- md="4"
97
- >
98
- <label>{{ getUnite(uniteId)?.nom ?? '' }}</label>
99
- <br />
100
- <v-radio-group v-model="selection[uniteId]">
101
- <v-radio
102
- v-for="chaise in dictChaisesReleve[uniteId]"
103
- :key="chaise.id"
104
- :label="chaise.nom"
105
- :value="chaise.id"
106
- />
107
- </v-radio-group>
108
- </v-col>
109
- </v-row>
110
- </div>
111
- </div>
112
- </template>
113
- </csqcDialogue>
114
- </div>
115
- </template>
116
-
117
- <script setup lang="ts">
118
- import { ref, computed, onMounted, nextTick, watch, toRefs } from 'vue'
119
- import { useDisplay } from 'vuetify'
120
- import ChaisePreferenceItem from './chaiseItem.vue'
121
- import csqcDialogue from '../csqcDialogue.vue'
122
- import axios from '../../outils/appAxios'
123
- import type { Unite } from '@/codev/modeles/unite'
124
- import { useI18n } from 'vue-i18n'
125
- const modale = ref<InstanceType<typeof csqcDialogue> | null>(null)
126
-
127
- interface Chaise {
128
- id: number
129
- nom: string
130
- }
131
- interface Preference {
132
- uniteId: number
133
- chaiseId: number
134
- }
135
-
136
- /** Props */
137
- const props = defineProps<{
138
- activerDivPreferences?: boolean
139
- typeIntervenant: number
140
- demandeId: number
141
- formulaireId: number
142
- urlBase: string
143
- texteTitre?: string
144
- texteInfo?: string
145
- largeurModale?: number
146
- }>()
147
- const { typeIntervenant, demandeId, formulaireId, urlBase } = toRefs(props)
148
- /** Emits */
149
- const emit = defineEmits<{
150
- (e: 'annuler'): void
151
- (e: 'confirmer'): void
152
- }>()
153
-
154
- const { t } = useI18n({ useScope: 'global' })
155
- const { xs } = useDisplay()
156
- const isXs = computed(() => xs.value)
157
-
158
- /** State */
159
- const visible = ref(false)
160
- const chargementEnCours = ref(false)
161
- const afficherErreur = ref(false)
162
- const unites = ref<Unite[]>([])
163
- const preferences = ref<Preference[]>([])
164
- const dictChaisesReleve = ref<Record<string, Chaise[]>>({})
165
- const selection = ref<Record<string, number>>({})
166
- const modeModifier = ref(false)
167
-
168
- /** Textes */
169
- const texteMessageErreur = computed(() => t('csqc.csqcChaise.erreur'))
170
- const texteBoutonAnnuler = computed(() => t('csqc.bouton.annuler'))
171
- const texteBoutonModifier = computed(() => t('csqc.bouton.modifier'))
172
- const texteTitre = computed(() =>
173
- props.texteTitre && props.texteTitre.length > 0 ? props.texteTitre : t('csqc.csqcChaise.titre'),
174
- )
175
- const info = computed(() =>
176
- props.texteInfo && props.texteInfo.length > 0 ? props.texteInfo : t('csqc.csqcChaise.info'),
177
- )
178
-
179
- // Option A — ne recharger que si typeIntervenant change
180
-
181
- const largeur = computed(() => props.largeurModale ?? 1200)
182
- const activerDivPreferences = computed(() => props.activerDivPreferences ?? true)
183
-
184
- function getUnite(uniteId: string) {
185
- return unites.value.find((u: Unite) => String(u.id) === String(uniteId))
186
- }
187
-
188
- /*
189
- function estPrefere(uniteId: string | number, chaiseId: number) {
190
- return preferences.value.some(p => String(p.uniteId) === String(uniteId) && p.chaiseId === chaiseId)
191
- }*/
192
-
193
- /** Sélection par défaut à partir des préférences existantes */
194
- function definitionSelectionDepart() {
195
- for (const uniteId in dictChaisesReleve.value) {
196
- const chaises = dictChaisesReleve.value[uniteId] ?? []
197
- const pref = preferences.value.find(
198
- p => String(p.uniteId) === String(uniteId) && chaises.some(chaise => chaise.id === p.chaiseId),
199
- )
200
- const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? (chaises[0]?.id ?? -1) : -1)
201
- selection.value[uniteId] = chaiseIdDefaut
202
- }
203
- }
204
-
205
- /** Toutes les unités ont-elles une préférence sélectionnée ? */
206
- const toutesUnitesPreferencesSelectionnees = computed(() => {
207
- for (const uniteId in dictChaisesReleve.value) {
208
- const chaises = dictChaisesReleve.value[uniteId] ?? []
209
- const uniteOk = chaises.some(c => preferences.value.some(p => p.chaiseId === c.id))
210
- if (!uniteOk) return false
211
- }
212
- return true
213
- })
214
-
215
- async function charger() {
216
- await chargerUnites()
217
- await chargementPreferences()
218
- }
219
-
220
- async function chargerUnites() {
221
- const url = `${props.urlBase}/api/ComposantUI/Unites`
222
- const unitesData = (await axios.getAxios().get<Unite[]>(url)) as unknown as Unite[]
223
- unites.value = unitesData ?? []
224
- }
225
-
226
- async function chargementPreferences() {
227
- chargementEnCours.value = true
228
-
229
- // Chaises par unité
230
- {
231
- const data = (await axios
232
- .getAxios()
233
- .get<
234
- Record<string, Chaise[]>
235
- >(`${props.urlBase}/api/ComposantUI/ReleveDe/${props.typeIntervenant}/Demande/${props.demandeId}`)) as unknown as Record<
236
- string,
237
- Chaise[]
238
- >
239
- dictChaisesReleve.value = data ?? {}
240
- }
241
-
242
- // Préférences de l'usager
243
- {
244
- const data = (await axios
245
- .getAxios()
246
- .get<
247
- Preference[]
248
- >(`${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}/TypeIntervenant/${props.typeIntervenant}`)) as unknown as Preference[]
249
- preferences.value = (data ?? []).filter(Boolean)
250
- }
251
-
252
- definitionSelectionDepart()
253
-
254
- // Sauvegarde immédiate pour les choix uniques (si demandé par ton flux)
255
- await sauvegarder()
256
-
257
- chargementEnCours.value = false
258
- }
259
-
260
- async function ouvrir() {
261
- if (!activerDivPreferences.value) {
262
- await chargementPreferences()
263
- visible.value = true
264
- await nextTick()
265
- modale.value?.ouvrir()
266
- return
267
- }
268
-
269
- if (!toutesUnitesPreferencesSelectionnees.value) {
270
- visible.value = true
271
- await nextTick()
272
- modale.value?.ouvrir()
273
- return
274
- }
275
-
276
- await ok()
277
- }
278
-
279
- function annuler() {
280
- visible.value = false
281
- modeModifier.value = false
282
- emit('annuler')
283
- }
284
-
285
- function modifier() {
286
- modeModifier.value = true
287
- visible.value = true
288
- modale.value?.ouvrir()
289
- }
290
-
291
- async function sauvegarder() {
292
- for (const uniteId in dictChaisesReleve.value) {
293
- const chaiseId = selection.value[uniteId]
294
- if (!chaiseId || chaiseId <= 0) continue
295
-
296
- const chaises = dictChaisesReleve.value[uniteId] ?? []
297
- if (chaises.length === 0) continue
298
-
299
- // Préférence existante pour CETTE unité ?
300
- const prefIndexDeUnite = preferences.value.findIndex(p => chaises.some(c => c.id === p.chaiseId))
301
-
302
- try {
303
- const data = (await axios
304
- .getAxios()
305
- .put<Preference>(
306
- `${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}` +
307
- `/Unite/${encodeURIComponent(uniteId)}` +
308
- `/Chaise/${chaiseId}` +
309
- `/TypeIntervenant/${props.typeIntervenant}`,
310
- )) as unknown as Preference
311
- const itemRecu = data as Preference
312
-
313
- if (prefIndexDeUnite >= 0) {
314
- // remplace l'élément à l'index
315
- preferences.value.splice(prefIndexDeUnite, 1, itemRecu)
316
- } else {
317
- // ajoute un nouvel élément
318
- preferences.value.push(itemRecu)
319
- }
320
- } catch (e) {
321
- console.error(e)
322
- }
323
- }
324
- }
325
- async function soumettre() {
326
- modeModifier.value = false
327
- await ouvrir()
328
- }
329
- /** Validation finale */
330
- async function ok() {
331
- await sauvegarder()
332
-
333
- if (toutesUnitesPreferencesSelectionnees.value) {
334
- if (!modeModifier.value) emit('confirmer')
335
- visible.value = false
336
- modeModifier.value = false
337
- } else {
338
- afficherErreur.value = true
339
- await nextTick()
340
- }
341
- modale.value?.fermer()
342
- }
343
-
344
- onMounted(async () => {
345
- chargementEnCours.value = true
346
- await charger()
347
- chargementEnCours.value = false
348
- })
349
-
350
- // si le type d'intervenant change
351
- watch(typeIntervenant, async (nv, ov) => {
352
- if (nv === ov) return
353
- await rechargerPourTypeIntervenant()
354
- })
355
-
356
- async function rechargerPourTypeIntervenant() {
357
- try {
358
- chargementEnCours.value = true
359
- preferences.value = []
360
- dictChaisesReleve.value = {}
361
- selection.value = {}
362
- afficherErreur.value = false
363
-
364
- // recharge les données dépendantes
365
- await chargementPreferences()
366
- } finally {
367
- chargementEnCours.value = false
368
- }
369
- }
370
-
371
- defineExpose({ charger, soumettre })
372
- </script>
1
+ <template>
2
+ <div class="pa-2 mt-2 mb-1 mr-1">
3
+ <!-- Affiche la carte récap si activée et qu'il y a des unités -->
4
+ <div v-if="activerDivPreferences && unites && unites.length > 0">
5
+ <v-card
6
+ max-width="375"
7
+ width="100%"
8
+ variant="outlined"
9
+ >
10
+ <v-card-text class="pt-0 mt-0">
11
+ <v-progress-linear
12
+ v-if="chargementEnCours"
13
+ indeterminate
14
+ />
15
+
16
+ <div
17
+ v-else
18
+ class="pt-2"
19
+ >
20
+ <div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
21
+
22
+ <div>
23
+ <v-list-item
24
+ v-for="uniteId in Object.keys(dictChaisesReleve)"
25
+ :key="uniteId"
26
+ class="mb-1"
27
+ >
28
+ <ChaisePreferenceItem
29
+ :uniteId="Number(uniteId)"
30
+ :preferences="preferences"
31
+ :dictChaisesReleve="dictChaisesReleve"
32
+ :unites="unites"
33
+ />
34
+ </v-list-item>
35
+ </div>
36
+ </div>
37
+ </v-card-text>
38
+
39
+ <v-card-actions>
40
+ <div class="flex-grow-1" />
41
+ <v-btn
42
+ v-if="!chargementEnCours"
43
+ rounded
44
+ variant="outlined"
45
+ size="small"
46
+ @click.stop="modifier"
47
+ >
48
+ {{ texteBoutonModifier }}
49
+ </v-btn>
50
+ </v-card-actions>
51
+ </v-card>
52
+ </div>
53
+
54
+ <csqcDialogue
55
+ ref="modale"
56
+ :operation-en-cours="chargementEnCours"
57
+ :btn-ok-desactiver="chargementEnCours"
58
+ :titre="texteTitre"
59
+ :btn-annuler-texte="texteBoutonAnnuler"
60
+ @annuler="annuler"
61
+ @ok="ok"
62
+ ><template #content>
63
+ <div class="pt-2"></div>
64
+ <hr class="pt-0 mt-0 pl-0" />
65
+ <div class="pt-4">
66
+ <i>{{ info }}</i>
67
+
68
+ <v-progress-linear
69
+ v-if="chargementEnCours"
70
+ indeterminate
71
+ />
72
+
73
+ <div
74
+ v-else
75
+ class="pt-4"
76
+ >
77
+ <v-row v-if="!toutesUnitesPreferencesSelectionnees">
78
+ <v-col cols="12">
79
+ <v-alert
80
+ v-model="afficherErreur"
81
+ type="error"
82
+ variant="tonal"
83
+ dismissible
84
+ >
85
+ {{ texteMessageErreur }}
86
+ </v-alert>
87
+ </v-col>
88
+ </v-row>
89
+
90
+ <v-row>
91
+ <v-col
92
+ v-for="uniteId in Object.keys(dictChaisesReleve)"
93
+ :key="uniteId"
94
+ cols="12"
95
+ sm="6"
96
+ md="4"
97
+ >
98
+ <label>{{ getUnite(uniteId)?.nom ?? '' }}</label>
99
+ <br />
100
+ <v-radio-group v-model="selection[uniteId]">
101
+ <v-radio
102
+ v-for="chaise in dictChaisesReleve[uniteId]"
103
+ :key="chaise.id"
104
+ :label="chaise.nom"
105
+ :value="chaise.id"
106
+ />
107
+ </v-radio-group>
108
+ </v-col>
109
+ </v-row>
110
+ </div>
111
+ </div>
112
+ </template>
113
+ </csqcDialogue>
114
+ </div>
115
+ </template>
116
+
117
+ <script setup lang="ts">
118
+ import { ref, computed, onMounted, nextTick, watch, toRefs } from 'vue'
119
+ import { useDisplay } from 'vuetify'
120
+ import ChaisePreferenceItem from './chaiseItem.vue'
121
+ import csqcDialogue from '../csqcDialogue.vue'
122
+ import axios from '../../outils/appAxios'
123
+ import type { Unite } from '@/codev/modeles/unite'
124
+ import { useI18n } from 'vue-i18n'
125
+ const modale = ref<InstanceType<typeof csqcDialogue> | null>(null)
126
+
127
+ interface Chaise {
128
+ id: number
129
+ nom: string
130
+ }
131
+ interface Preference {
132
+ uniteId: number
133
+ chaiseId: number
134
+ }
135
+
136
+ /** Props */
137
+ const props = defineProps<{
138
+ activerDivPreferences?: boolean
139
+ typeIntervenant: number
140
+ demandeId: number
141
+ formulaireId: number
142
+ urlBase: string
143
+ texteTitre?: string
144
+ texteInfo?: string
145
+ largeurModale?: number
146
+ }>()
147
+ const { typeIntervenant, demandeId, formulaireId, urlBase } = toRefs(props)
148
+ /** Emits */
149
+ const emit = defineEmits<{
150
+ (e: 'annuler'): void
151
+ (e: 'confirmer'): void
152
+ }>()
153
+
154
+ const { t } = useI18n({ useScope: 'global' })
155
+ const { xs } = useDisplay()
156
+ const isXs = computed(() => xs.value)
157
+
158
+ /** State */
159
+ const visible = ref(false)
160
+ const chargementEnCours = ref(false)
161
+ const afficherErreur = ref(false)
162
+ const unites = ref<Unite[]>([])
163
+ const preferences = ref<Preference[]>([])
164
+ const dictChaisesReleve = ref<Record<string, Chaise[]>>({})
165
+ const selection = ref<Record<string, number>>({})
166
+ const modeModifier = ref(false)
167
+
168
+ /** Textes */
169
+ const texteMessageErreur = computed(() => t('csqc.csqcChaise.erreur'))
170
+ const texteBoutonAnnuler = computed(() => t('csqc.bouton.annuler'))
171
+ const texteBoutonModifier = computed(() => t('csqc.bouton.modifier'))
172
+ const texteTitre = computed(() =>
173
+ props.texteTitre && props.texteTitre.length > 0 ? props.texteTitre : t('csqc.csqcChaise.titre'),
174
+ )
175
+ const info = computed(() =>
176
+ props.texteInfo && props.texteInfo.length > 0 ? props.texteInfo : t('csqc.csqcChaise.info'),
177
+ )
178
+
179
+ // Option A — ne recharger que si typeIntervenant change
180
+
181
+ const largeur = computed(() => props.largeurModale ?? 1200)
182
+ const activerDivPreferences = computed(() => props.activerDivPreferences ?? true)
183
+
184
+ function getUnite(uniteId: string) {
185
+ return unites.value.find((u: Unite) => String(u.id) === String(uniteId))
186
+ }
187
+
188
+ /*
189
+ function estPrefere(uniteId: string | number, chaiseId: number) {
190
+ return preferences.value.some(p => String(p.uniteId) === String(uniteId) && p.chaiseId === chaiseId)
191
+ }*/
192
+
193
+ /** Sélection par défaut à partir des préférences existantes */
194
+ function definitionSelectionDepart() {
195
+ for (const uniteId in dictChaisesReleve.value) {
196
+ const chaises = dictChaisesReleve.value[uniteId] ?? []
197
+ const pref = preferences.value.find(
198
+ p => String(p.uniteId) === String(uniteId) && chaises.some(chaise => chaise.id === p.chaiseId),
199
+ )
200
+ const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? (chaises[0]?.id ?? -1) : -1)
201
+ selection.value[uniteId] = chaiseIdDefaut
202
+ }
203
+ }
204
+
205
+ /** Toutes les unités ont-elles une préférence sélectionnée ? */
206
+ const toutesUnitesPreferencesSelectionnees = computed(() => {
207
+ for (const uniteId in dictChaisesReleve.value) {
208
+ const chaises = dictChaisesReleve.value[uniteId] ?? []
209
+ const uniteOk = chaises.some(c => preferences.value.some(p => p.chaiseId === c.id))
210
+ if (!uniteOk) return false
211
+ }
212
+ return true
213
+ })
214
+
215
+ async function charger() {
216
+ await chargerUnites()
217
+ await chargementPreferences()
218
+ }
219
+
220
+ async function chargerUnites() {
221
+ const url = `${props.urlBase}/api/ComposantUI/Unites`
222
+ const unitesData = (await axios.getAxios().get<Unite[]>(url)) as unknown as Unite[]
223
+ unites.value = unitesData ?? []
224
+ }
225
+
226
+ async function chargementPreferences() {
227
+ chargementEnCours.value = true
228
+
229
+ // Chaises par unité
230
+ {
231
+ const data = (await axios
232
+ .getAxios()
233
+ .get<
234
+ Record<string, Chaise[]>
235
+ >(`${props.urlBase}/api/ComposantUI/ReleveDe/${props.typeIntervenant}/Demande/${props.demandeId}`)) as unknown as Record<
236
+ string,
237
+ Chaise[]
238
+ >
239
+ dictChaisesReleve.value = data ?? {}
240
+ }
241
+
242
+ // Préférences de l'usager
243
+ {
244
+ const data = (await axios
245
+ .getAxios()
246
+ .get<
247
+ Preference[]
248
+ >(`${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}/TypeIntervenant/${props.typeIntervenant}`)) as unknown as Preference[]
249
+ preferences.value = (data ?? []).filter(Boolean)
250
+ }
251
+
252
+ definitionSelectionDepart()
253
+
254
+ // Sauvegarde immédiate pour les choix uniques (si demandé par ton flux)
255
+ await sauvegarder()
256
+
257
+ chargementEnCours.value = false
258
+ }
259
+
260
+ async function ouvrir() {
261
+ if (!activerDivPreferences.value) {
262
+ await chargementPreferences()
263
+ visible.value = true
264
+ await nextTick()
265
+ modale.value?.ouvrir()
266
+ return
267
+ }
268
+
269
+ if (!toutesUnitesPreferencesSelectionnees.value) {
270
+ visible.value = true
271
+ await nextTick()
272
+ modale.value?.ouvrir()
273
+ return
274
+ }
275
+
276
+ await ok()
277
+ }
278
+
279
+ function annuler() {
280
+ visible.value = false
281
+ modeModifier.value = false
282
+ emit('annuler')
283
+ }
284
+
285
+ function modifier() {
286
+ modeModifier.value = true
287
+ visible.value = true
288
+ modale.value?.ouvrir()
289
+ }
290
+
291
+ async function sauvegarder() {
292
+ for (const uniteId in dictChaisesReleve.value) {
293
+ const chaiseId = selection.value[uniteId]
294
+ if (!chaiseId || chaiseId <= 0) continue
295
+
296
+ const chaises = dictChaisesReleve.value[uniteId] ?? []
297
+ if (chaises.length === 0) continue
298
+
299
+ // Préférence existante pour CETTE unité ?
300
+ const prefIndexDeUnite = preferences.value.findIndex(p => chaises.some(c => c.id === p.chaiseId))
301
+
302
+ try {
303
+ const data = (await axios
304
+ .getAxios()
305
+ .put<Preference>(
306
+ `${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}` +
307
+ `/Unite/${encodeURIComponent(uniteId)}` +
308
+ `/Chaise/${chaiseId}` +
309
+ `/TypeIntervenant/${props.typeIntervenant}`,
310
+ )) as unknown as Preference
311
+ const itemRecu = data as Preference
312
+
313
+ if (prefIndexDeUnite >= 0) {
314
+ // remplace l'élément à l'index
315
+ preferences.value.splice(prefIndexDeUnite, 1, itemRecu)
316
+ } else {
317
+ // ajoute un nouvel élément
318
+ preferences.value.push(itemRecu)
319
+ }
320
+ } catch (e) {
321
+ console.error(e)
322
+ }
323
+ }
324
+ }
325
+ async function soumettre() {
326
+ modeModifier.value = false
327
+ await ouvrir()
328
+ }
329
+ /** Validation finale */
330
+ async function ok() {
331
+ await sauvegarder()
332
+
333
+ if (toutesUnitesPreferencesSelectionnees.value) {
334
+ if (!modeModifier.value) emit('confirmer')
335
+ visible.value = false
336
+ modeModifier.value = false
337
+ } else {
338
+ afficherErreur.value = true
339
+ await nextTick()
340
+ }
341
+ modale.value?.fermer()
342
+ }
343
+
344
+ onMounted(async () => {
345
+ chargementEnCours.value = true
346
+ await charger()
347
+ chargementEnCours.value = false
348
+ })
349
+
350
+ // si le type d'intervenant change
351
+ watch(typeIntervenant, async (nv, ov) => {
352
+ if (nv === ov) return
353
+ await rechargerPourTypeIntervenant()
354
+ })
355
+
356
+ async function rechargerPourTypeIntervenant() {
357
+ try {
358
+ chargementEnCours.value = true
359
+ preferences.value = []
360
+ dictChaisesReleve.value = {}
361
+ selection.value = {}
362
+ afficherErreur.value = false
363
+
364
+ // recharge les données dépendantes
365
+ await chargementPreferences()
366
+ } finally {
367
+ chargementEnCours.value = false
368
+ }
369
+ }
370
+
371
+ defineExpose({ charger, soumettre })
372
+ </script>