codevdesign 1.0.26 → 1.0.29
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.
- package/composants/csqcChaise/chaiseConteneur.vue +367 -363
- package/outils/rafraichisseurToken.ts +187 -186
- package/package.json +1 -1
|
@@ -1,363 +1,367 @@
|
|
|
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
|
-
width="375"
|
|
7
|
-
variant="outlined"
|
|
8
|
-
>
|
|
9
|
-
<v-card-text class="pt-0 mt-0">
|
|
10
|
-
<v-progress-linear
|
|
11
|
-
v-if="chargementEnCours"
|
|
12
|
-
indeterminate
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
<div
|
|
16
|
-
v-else
|
|
17
|
-
class="pt-2"
|
|
18
|
-
>
|
|
19
|
-
<div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
|
|
20
|
-
|
|
21
|
-
<div>
|
|
22
|
-
<v-list-item
|
|
23
|
-
v-for="uniteId in Object.keys(dictChaisesReleve)"
|
|
24
|
-
:key="uniteId"
|
|
25
|
-
class="mb-1"
|
|
26
|
-
>
|
|
27
|
-
<ChaisePreferenceItem
|
|
28
|
-
:uniteId="Number(uniteId)"
|
|
29
|
-
:preferences="preferences"
|
|
30
|
-
:dictChaisesReleve="dictChaisesReleve"
|
|
31
|
-
:unites="unites"
|
|
32
|
-
/>
|
|
33
|
-
</v-list-item>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</v-card-text>
|
|
37
|
-
|
|
38
|
-
<v-card-actions>
|
|
39
|
-
<div class="flex-grow-1" />
|
|
40
|
-
<v-btn
|
|
41
|
-
v-if="!chargementEnCours"
|
|
42
|
-
rounded
|
|
43
|
-
variant="outlined"
|
|
44
|
-
size="small"
|
|
45
|
-
@click.stop="modifier"
|
|
46
|
-
>
|
|
47
|
-
{{ texteBoutonModifier }}
|
|
48
|
-
</v-btn>
|
|
49
|
-
</v-card-actions>
|
|
50
|
-
</v-card>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<csqcDialogue
|
|
54
|
-
ref="modale"
|
|
55
|
-
:operation-en-cours="chargementEnCours"
|
|
56
|
-
:btn-ok-desactiver="chargementEnCours"
|
|
57
|
-
:titre="texteTitre"
|
|
58
|
-
:btn-annuler-texte="texteBoutonAnnuler"
|
|
59
|
-
@annuler="annuler"
|
|
60
|
-
@ok="ok"
|
|
61
|
-
><template #content>
|
|
62
|
-
<div class="pt-2"></div>
|
|
63
|
-
<hr class="pt-0 mt-0 pl-0" />
|
|
64
|
-
<div class="pt-4">
|
|
65
|
-
<i>{{ info }}</i>
|
|
66
|
-
|
|
67
|
-
<v-progress-linear
|
|
68
|
-
v-if="chargementEnCours"
|
|
69
|
-
indeterminate
|
|
70
|
-
/>
|
|
71
|
-
|
|
72
|
-
<div
|
|
73
|
-
v-else
|
|
74
|
-
class="pt-4"
|
|
75
|
-
>
|
|
76
|
-
<v-row v-if="!toutesUnitesPreferencesSelectionnees">
|
|
77
|
-
<v-col cols="12">
|
|
78
|
-
<v-alert
|
|
79
|
-
v-model="afficherErreur"
|
|
80
|
-
type="error"
|
|
81
|
-
variant="tonal"
|
|
82
|
-
dismissible
|
|
83
|
-
>
|
|
84
|
-
{{ texteMessageErreur }}
|
|
85
|
-
</v-alert>
|
|
86
|
-
</v-col>
|
|
87
|
-
</v-row>
|
|
88
|
-
|
|
89
|
-
<v-row>
|
|
90
|
-
<v-col
|
|
91
|
-
v-for="uniteId in Object.keys(dictChaisesReleve)"
|
|
92
|
-
:key="uniteId"
|
|
93
|
-
cols="12"
|
|
94
|
-
sm="6"
|
|
95
|
-
md="4"
|
|
96
|
-
>
|
|
97
|
-
<label>{{ getUnite(uniteId)?.nom ?? '' }}</label>
|
|
98
|
-
<br />
|
|
99
|
-
<v-radio-group v-model="selection[uniteId]">
|
|
100
|
-
<v-radio
|
|
101
|
-
v-for="chaise in dictChaisesReleve[uniteId]"
|
|
102
|
-
:key="chaise.id"
|
|
103
|
-
:label="chaise.nom"
|
|
104
|
-
:value="chaise.id"
|
|
105
|
-
/>
|
|
106
|
-
</v-radio-group>
|
|
107
|
-
</v-col>
|
|
108
|
-
</v-row>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
</template>
|
|
112
|
-
</csqcDialogue>
|
|
113
|
-
</div>
|
|
114
|
-
</template>
|
|
115
|
-
|
|
116
|
-
<script setup lang="ts">
|
|
117
|
-
import { ref, computed, onMounted, nextTick, watch, toRefs } from 'vue'
|
|
118
|
-
import { useDisplay } from 'vuetify'
|
|
119
|
-
import ChaisePreferenceItem from './chaiseItem.vue'
|
|
120
|
-
import csqcDialogue from '../csqcDialogue.vue'
|
|
121
|
-
import axios from '../../outils/appAxios'
|
|
122
|
-
import type { Unite } from '@/codev/modeles/unite'
|
|
123
|
-
import { useI18n } from 'vue-i18n'
|
|
124
|
-
const modale = ref<InstanceType<typeof csqcDialogue> | null>(null)
|
|
125
|
-
|
|
126
|
-
interface Chaise {
|
|
127
|
-
id: number
|
|
128
|
-
nom: string
|
|
129
|
-
}
|
|
130
|
-
interface Preference {
|
|
131
|
-
uniteId: number
|
|
132
|
-
chaiseId: number
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Props */
|
|
136
|
-
const props = defineProps<{
|
|
137
|
-
activerDivPreferences?: boolean
|
|
138
|
-
typeIntervenant: number
|
|
139
|
-
demandeId: number
|
|
140
|
-
formulaireId: number
|
|
141
|
-
urlBase: string
|
|
142
|
-
texteTitre?: string
|
|
143
|
-
texteInfo?: string
|
|
144
|
-
largeurModale?: number
|
|
145
|
-
}>()
|
|
146
|
-
const { typeIntervenant, demandeId, formulaireId, urlBase } = toRefs(props)
|
|
147
|
-
/** Emits */
|
|
148
|
-
const emit = defineEmits<{
|
|
149
|
-
(e: 'annuler'): void
|
|
150
|
-
(e: 'confirmer'): void
|
|
151
|
-
}>()
|
|
152
|
-
|
|
153
|
-
const { t } = useI18n({ useScope: 'global' })
|
|
154
|
-
const { xs } = useDisplay()
|
|
155
|
-
const isXs = computed(() => xs.value)
|
|
156
|
-
|
|
157
|
-
/** State */
|
|
158
|
-
const visible = ref(false)
|
|
159
|
-
const chargementEnCours = ref(false)
|
|
160
|
-
const afficherErreur = ref(false)
|
|
161
|
-
const unites = ref<Unite[]>([])
|
|
162
|
-
const preferences = ref<Preference[]>([])
|
|
163
|
-
const dictChaisesReleve = ref<Record<string, Chaise[]>>({})
|
|
164
|
-
const selection = ref<Record<string, number>>({})
|
|
165
|
-
const modeModifier = ref(false)
|
|
166
|
-
|
|
167
|
-
/** Textes */
|
|
168
|
-
const texteMessageErreur = computed(() => t('csqc.csqcChaise.erreur'))
|
|
169
|
-
const texteBoutonAnnuler = computed(() => t('csqc.bouton.annuler'))
|
|
170
|
-
const texteBoutonModifier = computed(() => t('csqc.bouton.modifier'))
|
|
171
|
-
const texteTitre = computed(() =>
|
|
172
|
-
props.texteTitre && props.texteTitre.length > 0 ? props.texteTitre : t('csqc.csqcChaise.titre'),
|
|
173
|
-
)
|
|
174
|
-
const info = computed(() =>
|
|
175
|
-
props.texteInfo && props.texteInfo.length > 0 ? props.texteInfo : t('csqc.csqcChaise.info'),
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
// Option A — ne recharger que si typeIntervenant change
|
|
179
|
-
|
|
180
|
-
const largeur = computed(() => props.largeurModale ?? 1200)
|
|
181
|
-
const activerDivPreferences = computed(() => props.activerDivPreferences ?? true)
|
|
182
|
-
|
|
183
|
-
function getUnite(uniteId: string) {
|
|
184
|
-
return unites.value.find((u: Unite) => String(u.id) === String(uniteId))
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/*
|
|
188
|
-
function estPrefere(uniteId: string | number, chaiseId: number) {
|
|
189
|
-
return preferences.value.some(p => String(p.uniteId) === String(uniteId) && p.chaiseId === chaiseId)
|
|
190
|
-
}*/
|
|
191
|
-
|
|
192
|
-
/** Sélection par défaut à partir des préférences existantes */
|
|
193
|
-
function definitionSelectionDepart() {
|
|
194
|
-
for (const uniteId in dictChaisesReleve.value) {
|
|
195
|
-
const chaises = dictChaisesReleve.value[uniteId] ?? []
|
|
196
|
-
const pref = preferences.value.find(
|
|
197
|
-
p => String(p.uniteId) === String(uniteId) && chaises.some(chaise => chaise.id === p.chaiseId),
|
|
198
|
-
)
|
|
199
|
-
const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? (chaises[0]?.id ?? -1) : -1)
|
|
200
|
-
selection.value[uniteId] = chaiseIdDefaut
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** Toutes les unités ont-elles une préférence sélectionnée ? */
|
|
205
|
-
const toutesUnitesPreferencesSelectionnees = computed(() => {
|
|
206
|
-
for (const uniteId in dictChaisesReleve.value) {
|
|
207
|
-
const chaises = dictChaisesReleve.value[uniteId] ?? []
|
|
208
|
-
const uniteOk = chaises.some(c => preferences.value.some(p => p.chaiseId === c.id))
|
|
209
|
-
if (!uniteOk) return false
|
|
210
|
-
}
|
|
211
|
-
return true
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
async function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
visible.value = true
|
|
263
|
-
return
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
modeModifier.value =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
async function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
+
width="375"
|
|
7
|
+
variant="outlined"
|
|
8
|
+
>
|
|
9
|
+
<v-card-text class="pt-0 mt-0">
|
|
10
|
+
<v-progress-linear
|
|
11
|
+
v-if="chargementEnCours"
|
|
12
|
+
indeterminate
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
v-else
|
|
17
|
+
class="pt-2"
|
|
18
|
+
>
|
|
19
|
+
<div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
|
|
20
|
+
|
|
21
|
+
<div>
|
|
22
|
+
<v-list-item
|
|
23
|
+
v-for="uniteId in Object.keys(dictChaisesReleve)"
|
|
24
|
+
:key="uniteId"
|
|
25
|
+
class="mb-1"
|
|
26
|
+
>
|
|
27
|
+
<ChaisePreferenceItem
|
|
28
|
+
:uniteId="Number(uniteId)"
|
|
29
|
+
:preferences="preferences"
|
|
30
|
+
:dictChaisesReleve="dictChaisesReleve"
|
|
31
|
+
:unites="unites"
|
|
32
|
+
/>
|
|
33
|
+
</v-list-item>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</v-card-text>
|
|
37
|
+
|
|
38
|
+
<v-card-actions>
|
|
39
|
+
<div class="flex-grow-1" />
|
|
40
|
+
<v-btn
|
|
41
|
+
v-if="!chargementEnCours"
|
|
42
|
+
rounded
|
|
43
|
+
variant="outlined"
|
|
44
|
+
size="small"
|
|
45
|
+
@click.stop="modifier"
|
|
46
|
+
>
|
|
47
|
+
{{ texteBoutonModifier }}
|
|
48
|
+
</v-btn>
|
|
49
|
+
</v-card-actions>
|
|
50
|
+
</v-card>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<csqcDialogue
|
|
54
|
+
ref="modale"
|
|
55
|
+
:operation-en-cours="chargementEnCours"
|
|
56
|
+
:btn-ok-desactiver="chargementEnCours"
|
|
57
|
+
:titre="texteTitre"
|
|
58
|
+
:btn-annuler-texte="texteBoutonAnnuler"
|
|
59
|
+
@annuler="annuler"
|
|
60
|
+
@ok="ok"
|
|
61
|
+
><template #content>
|
|
62
|
+
<div class="pt-2"></div>
|
|
63
|
+
<hr class="pt-0 mt-0 pl-0" />
|
|
64
|
+
<div class="pt-4">
|
|
65
|
+
<i>{{ info }}</i>
|
|
66
|
+
|
|
67
|
+
<v-progress-linear
|
|
68
|
+
v-if="chargementEnCours"
|
|
69
|
+
indeterminate
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
v-else
|
|
74
|
+
class="pt-4"
|
|
75
|
+
>
|
|
76
|
+
<v-row v-if="!toutesUnitesPreferencesSelectionnees">
|
|
77
|
+
<v-col cols="12">
|
|
78
|
+
<v-alert
|
|
79
|
+
v-model="afficherErreur"
|
|
80
|
+
type="error"
|
|
81
|
+
variant="tonal"
|
|
82
|
+
dismissible
|
|
83
|
+
>
|
|
84
|
+
{{ texteMessageErreur }}
|
|
85
|
+
</v-alert>
|
|
86
|
+
</v-col>
|
|
87
|
+
</v-row>
|
|
88
|
+
|
|
89
|
+
<v-row>
|
|
90
|
+
<v-col
|
|
91
|
+
v-for="uniteId in Object.keys(dictChaisesReleve)"
|
|
92
|
+
:key="uniteId"
|
|
93
|
+
cols="12"
|
|
94
|
+
sm="6"
|
|
95
|
+
md="4"
|
|
96
|
+
>
|
|
97
|
+
<label>{{ getUnite(uniteId)?.nom ?? '' }}</label>
|
|
98
|
+
<br />
|
|
99
|
+
<v-radio-group v-model="selection[uniteId]">
|
|
100
|
+
<v-radio
|
|
101
|
+
v-for="chaise in dictChaisesReleve[uniteId]"
|
|
102
|
+
:key="chaise.id"
|
|
103
|
+
:label="chaise.nom"
|
|
104
|
+
:value="chaise.id"
|
|
105
|
+
/>
|
|
106
|
+
</v-radio-group>
|
|
107
|
+
</v-col>
|
|
108
|
+
</v-row>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</template>
|
|
112
|
+
</csqcDialogue>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script setup lang="ts">
|
|
117
|
+
import { ref, computed, onMounted, nextTick, watch, toRefs } from 'vue'
|
|
118
|
+
import { useDisplay } from 'vuetify'
|
|
119
|
+
import ChaisePreferenceItem from './chaiseItem.vue'
|
|
120
|
+
import csqcDialogue from '../csqcDialogue.vue'
|
|
121
|
+
import axios from '../../outils/appAxios'
|
|
122
|
+
import type { Unite } from '@/codev/modeles/unite'
|
|
123
|
+
import { useI18n } from 'vue-i18n'
|
|
124
|
+
const modale = ref<InstanceType<typeof csqcDialogue> | null>(null)
|
|
125
|
+
|
|
126
|
+
interface Chaise {
|
|
127
|
+
id: number
|
|
128
|
+
nom: string
|
|
129
|
+
}
|
|
130
|
+
interface Preference {
|
|
131
|
+
uniteId: number
|
|
132
|
+
chaiseId: number
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Props */
|
|
136
|
+
const props = defineProps<{
|
|
137
|
+
activerDivPreferences?: boolean
|
|
138
|
+
typeIntervenant: number
|
|
139
|
+
demandeId: number
|
|
140
|
+
formulaireId: number
|
|
141
|
+
urlBase: string
|
|
142
|
+
texteTitre?: string
|
|
143
|
+
texteInfo?: string
|
|
144
|
+
largeurModale?: number
|
|
145
|
+
}>()
|
|
146
|
+
const { typeIntervenant, demandeId, formulaireId, urlBase } = toRefs(props)
|
|
147
|
+
/** Emits */
|
|
148
|
+
const emit = defineEmits<{
|
|
149
|
+
(e: 'annuler'): void
|
|
150
|
+
(e: 'confirmer'): void
|
|
151
|
+
}>()
|
|
152
|
+
|
|
153
|
+
const { t } = useI18n({ useScope: 'global' })
|
|
154
|
+
const { xs } = useDisplay()
|
|
155
|
+
const isXs = computed(() => xs.value)
|
|
156
|
+
|
|
157
|
+
/** State */
|
|
158
|
+
const visible = ref(false)
|
|
159
|
+
const chargementEnCours = ref(false)
|
|
160
|
+
const afficherErreur = ref(false)
|
|
161
|
+
const unites = ref<Unite[]>([])
|
|
162
|
+
const preferences = ref<Preference[]>([])
|
|
163
|
+
const dictChaisesReleve = ref<Record<string, Chaise[]>>({})
|
|
164
|
+
const selection = ref<Record<string, number>>({})
|
|
165
|
+
const modeModifier = ref(false)
|
|
166
|
+
|
|
167
|
+
/** Textes */
|
|
168
|
+
const texteMessageErreur = computed(() => t('csqc.csqcChaise.erreur'))
|
|
169
|
+
const texteBoutonAnnuler = computed(() => t('csqc.bouton.annuler'))
|
|
170
|
+
const texteBoutonModifier = computed(() => t('csqc.bouton.modifier'))
|
|
171
|
+
const texteTitre = computed(() =>
|
|
172
|
+
props.texteTitre && props.texteTitre.length > 0 ? props.texteTitre : t('csqc.csqcChaise.titre'),
|
|
173
|
+
)
|
|
174
|
+
const info = computed(() =>
|
|
175
|
+
props.texteInfo && props.texteInfo.length > 0 ? props.texteInfo : t('csqc.csqcChaise.info'),
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
// Option A — ne recharger que si typeIntervenant change
|
|
179
|
+
|
|
180
|
+
const largeur = computed(() => props.largeurModale ?? 1200)
|
|
181
|
+
const activerDivPreferences = computed(() => props.activerDivPreferences ?? true)
|
|
182
|
+
|
|
183
|
+
function getUnite(uniteId: string) {
|
|
184
|
+
return unites.value.find((u: Unite) => String(u.id) === String(uniteId))
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
function estPrefere(uniteId: string | number, chaiseId: number) {
|
|
189
|
+
return preferences.value.some(p => String(p.uniteId) === String(uniteId) && p.chaiseId === chaiseId)
|
|
190
|
+
}*/
|
|
191
|
+
|
|
192
|
+
/** Sélection par défaut à partir des préférences existantes */
|
|
193
|
+
function definitionSelectionDepart() {
|
|
194
|
+
for (const uniteId in dictChaisesReleve.value) {
|
|
195
|
+
const chaises = dictChaisesReleve.value[uniteId] ?? []
|
|
196
|
+
const pref = preferences.value.find(
|
|
197
|
+
p => String(p.uniteId) === String(uniteId) && chaises.some(chaise => chaise.id === p.chaiseId),
|
|
198
|
+
)
|
|
199
|
+
const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? (chaises[0]?.id ?? -1) : -1)
|
|
200
|
+
selection.value[uniteId] = chaiseIdDefaut
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Toutes les unités ont-elles une préférence sélectionnée ? */
|
|
205
|
+
const toutesUnitesPreferencesSelectionnees = computed(() => {
|
|
206
|
+
for (const uniteId in dictChaisesReleve.value) {
|
|
207
|
+
const chaises = dictChaisesReleve.value[uniteId] ?? []
|
|
208
|
+
const uniteOk = chaises.some(c => preferences.value.some(p => p.chaiseId === c.id))
|
|
209
|
+
if (!uniteOk) return false
|
|
210
|
+
}
|
|
211
|
+
return true
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
async function charger() {
|
|
215
|
+
await chargerUnites()
|
|
216
|
+
await chargementPreferences()
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function chargerUnites() {
|
|
220
|
+
const url = `${props.urlBase}/api/ComposantUI/Unites`
|
|
221
|
+
const unitesData = (await axios.getAxios().get<Unite[]>(url)) as unknown as Unite[]
|
|
222
|
+
unites.value = unitesData ?? []
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function chargementPreferences() {
|
|
226
|
+
chargementEnCours.value = true
|
|
227
|
+
|
|
228
|
+
// Chaises par unité
|
|
229
|
+
{
|
|
230
|
+
const data = (await axios
|
|
231
|
+
.getAxios()
|
|
232
|
+
.get<
|
|
233
|
+
Record<string, Chaise[]>
|
|
234
|
+
>(`${props.urlBase}/api/ComposantUI/ReleveDe/${props.typeIntervenant}/Demande/${props.demandeId}`)) as unknown as Record<
|
|
235
|
+
string,
|
|
236
|
+
Chaise[]
|
|
237
|
+
>
|
|
238
|
+
dictChaisesReleve.value = data ?? {}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Préférences de l'usager
|
|
242
|
+
{
|
|
243
|
+
const data = (await axios
|
|
244
|
+
.getAxios()
|
|
245
|
+
.get<
|
|
246
|
+
Preference[]
|
|
247
|
+
>(`${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}/TypeIntervenant/${props.typeIntervenant}`)) as unknown as Preference[]
|
|
248
|
+
preferences.value = (data ?? []).filter(Boolean)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
definitionSelectionDepart()
|
|
252
|
+
|
|
253
|
+
// Sauvegarde immédiate pour les choix uniques (si demandé par ton flux)
|
|
254
|
+
await sauvegarder()
|
|
255
|
+
|
|
256
|
+
chargementEnCours.value = false
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async function ouvrir() {
|
|
260
|
+
if (!activerDivPreferences.value) {
|
|
261
|
+
await chargementPreferences()
|
|
262
|
+
visible.value = true
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!toutesUnitesPreferencesSelectionnees.value) {
|
|
267
|
+
visible.value = true
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
await ok()
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function annuler() {
|
|
275
|
+
visible.value = false
|
|
276
|
+
modeModifier.value = false
|
|
277
|
+
emit('annuler')
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function modifier() {
|
|
281
|
+
modeModifier.value = true
|
|
282
|
+
visible.value = true
|
|
283
|
+
modale.value?.ouvrir()
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async function sauvegarder() {
|
|
287
|
+
for (const uniteId in dictChaisesReleve.value) {
|
|
288
|
+
const chaiseId = selection.value[uniteId]
|
|
289
|
+
if (!chaiseId || chaiseId <= 0) continue
|
|
290
|
+
|
|
291
|
+
const chaises = dictChaisesReleve.value[uniteId] ?? []
|
|
292
|
+
if (chaises.length === 0) continue
|
|
293
|
+
|
|
294
|
+
// Préférence existante pour CETTE unité ?
|
|
295
|
+
const prefIndexDeUnite = preferences.value.findIndex(p => chaises.some(c => c.id === p.chaiseId))
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
const data = (await axios
|
|
299
|
+
.getAxios()
|
|
300
|
+
.put<Preference>(
|
|
301
|
+
`${props.urlBase}/api/ComposantUI/Preferences/${props.formulaireId}` +
|
|
302
|
+
`/Unite/${encodeURIComponent(uniteId)}` +
|
|
303
|
+
`/Chaise/${chaiseId}` +
|
|
304
|
+
`/TypeIntervenant/${props.typeIntervenant}`,
|
|
305
|
+
)) as unknown as Preference
|
|
306
|
+
const itemRecu = data as Preference
|
|
307
|
+
|
|
308
|
+
if (prefIndexDeUnite >= 0) {
|
|
309
|
+
// remplace l'élément à l'index
|
|
310
|
+
preferences.value.splice(prefIndexDeUnite, 1, itemRecu)
|
|
311
|
+
} else {
|
|
312
|
+
// ajoute un nouvel élément
|
|
313
|
+
preferences.value.push(itemRecu)
|
|
314
|
+
}
|
|
315
|
+
} catch (e) {
|
|
316
|
+
console.error(e)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async function soumettre() {
|
|
321
|
+
modeModifier.value = false
|
|
322
|
+
await ouvrir()
|
|
323
|
+
}
|
|
324
|
+
/** Validation finale */
|
|
325
|
+
async function ok() {
|
|
326
|
+
await sauvegarder()
|
|
327
|
+
|
|
328
|
+
if (toutesUnitesPreferencesSelectionnees.value) {
|
|
329
|
+
if (!modeModifier.value) emit('confirmer')
|
|
330
|
+
visible.value = false
|
|
331
|
+
modeModifier.value = false
|
|
332
|
+
} else {
|
|
333
|
+
afficherErreur.value = true
|
|
334
|
+
await nextTick()
|
|
335
|
+
}
|
|
336
|
+
modale.value?.fermer()
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
onMounted(async () => {
|
|
340
|
+
chargementEnCours.value = true
|
|
341
|
+
await charger()
|
|
342
|
+
chargementEnCours.value = false
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// si le type d'intervenant change
|
|
346
|
+
watch(typeIntervenant, async (nv, ov) => {
|
|
347
|
+
if (nv === ov) return
|
|
348
|
+
await rechargerPourTypeIntervenant()
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
async function rechargerPourTypeIntervenant() {
|
|
352
|
+
try {
|
|
353
|
+
chargementEnCours.value = true
|
|
354
|
+
preferences.value = []
|
|
355
|
+
dictChaisesReleve.value = {}
|
|
356
|
+
selection.value = {}
|
|
357
|
+
afficherErreur.value = false
|
|
358
|
+
|
|
359
|
+
// recharge les données dépendantes
|
|
360
|
+
await chargementPreferences()
|
|
361
|
+
} finally {
|
|
362
|
+
chargementEnCours.value = false
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
defineExpose({ charger, soumettre })
|
|
367
|
+
</script>
|
|
@@ -1,186 +1,187 @@
|
|
|
1
|
-
class RafraichisseurToken {
|
|
2
|
-
private intervalleEnSecondes = 15
|
|
3
|
-
private secondesAvantExpirationTokenPourRafraichir = 20
|
|
4
|
-
private skewSeconds = 5 // marge anti-derives d’horloge
|
|
5
|
-
private popupAffiche = false
|
|
6
|
-
private timerId: number | null = null
|
|
7
|
-
|
|
8
|
-
// Lance une seule fois
|
|
9
|
-
public async demarrer(nomTemoin: string | null, urlPortail: string): Promise<void> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.timerId
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.timerId
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
iframe.
|
|
123
|
-
iframe.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
window.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
.
|
|
172
|
-
.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
1
|
+
class RafraichisseurToken {
|
|
2
|
+
private intervalleEnSecondes = 15
|
|
3
|
+
private secondesAvantExpirationTokenPourRafraichir = 20
|
|
4
|
+
private skewSeconds = 5 // marge anti-derives d’horloge
|
|
5
|
+
private popupAffiche = false
|
|
6
|
+
private timerId: number | null = null
|
|
7
|
+
|
|
8
|
+
// Lance une seule fois
|
|
9
|
+
public async demarrer(nomTemoin: string | null, urlPortail: string): Promise<void> {
|
|
10
|
+
urlPortail = urlPortail.replace(/\/+$/, '')
|
|
11
|
+
if (nomTemoin == null || nomTemoin === '') nomTemoin = 'csqc_jeton_secure_expiration'
|
|
12
|
+
await this.verifierJeton(nomTemoin, urlPortail)
|
|
13
|
+
if (this.timerId != null) return
|
|
14
|
+
this.timerId = window.setInterval(() => {
|
|
15
|
+
this.verifierJeton(nomTemoin, urlPortail)
|
|
16
|
+
}, this.intervalleEnSecondes * 1000)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Permet d’arrêter le timer (ex: au logout / destroy)
|
|
20
|
+
public arreter(): void {
|
|
21
|
+
if (this.timerId != null) {
|
|
22
|
+
clearInterval(this.timerId)
|
|
23
|
+
this.timerId = null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public existeJeton = (nomTemoin: string) => {
|
|
28
|
+
return this.estJetonValide(nomTemoin)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async verifierJeton(nomTemoin: string, urlPortail: string): Promise<void> {
|
|
32
|
+
if (this.popupAffiche) return
|
|
33
|
+
|
|
34
|
+
if (!this.estJetonValide(nomTemoin)) {
|
|
35
|
+
this.rafraichir(nomTemoin, urlPortail)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private estJetonValide(nomTemoin: string): boolean {
|
|
41
|
+
if (this.popupAffiche || !nomTemoin) return true //On fait semblant que c'est valide pour ne pas provoquer un autre affichage du popup.
|
|
42
|
+
|
|
43
|
+
const tokenEncode = this.lireCookie(nomTemoin)
|
|
44
|
+
if (!tokenEncode) {
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let token: any
|
|
49
|
+
try {
|
|
50
|
+
token = this.parseJwt(tokenEncode)
|
|
51
|
+
} catch {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const exp = Number(token?.exp)
|
|
56
|
+
if (!Number.isFinite(exp)) {
|
|
57
|
+
// exp manquant/invalide → tente refresh
|
|
58
|
+
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const now = Math.floor(Date.now() / 1000)
|
|
63
|
+
const refreshAt = exp - this.secondesAvantExpirationTokenPourRafraichir - this.skewSeconds
|
|
64
|
+
if (now >= refreshAt) {
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private async rafraichir(nomCookie: string, urlPortail: string): Promise<void> {
|
|
72
|
+
if (!nomCookie) return
|
|
73
|
+
const url = this.getRefreshUrl(urlPortail)
|
|
74
|
+
const controller = new AbortController()
|
|
75
|
+
const timeout = setTimeout(() => controller.abort(), 10_000)
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
//Première tentative sans iframe, pour la majorité des cas.
|
|
79
|
+
const resp = await fetch(url, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
credentials: 'include',
|
|
82
|
+
headers: { Accept: 'application/json' },
|
|
83
|
+
redirect: 'manual',
|
|
84
|
+
signal: controller.signal,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// redirection (souvent => login) → traiter comme non auth
|
|
88
|
+
|
|
89
|
+
if (resp.type === 'opaqueredirect' || resp.status === 302) {
|
|
90
|
+
this.rafraichirParIframe(nomCookie, urlPortail)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// OK ou No Content: le cookie devrait être réécrit
|
|
95
|
+
if (resp.status === 200 || resp.status === 204) {
|
|
96
|
+
const jeton = this.lireCookie(nomCookie)
|
|
97
|
+
if (!jeton) this.rafraichirParIframe(nomCookie, urlPortail)
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// non auth / expiré (401, 419) + IIS timeout (440)
|
|
102
|
+
if (resp.status === 401 || resp.status === 419 || resp.status === 440) {
|
|
103
|
+
this.rafraichirParIframe(nomCookie, urlPortail)
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.warn('Rafraichisseur token: statut inattendu', resp.status)
|
|
108
|
+
} catch (err: any) {
|
|
109
|
+
if (err?.name === 'AbortError') console.warn('RafraichisseurToken timeout')
|
|
110
|
+
else console.error('Erreur rafraichisseur de token', err)
|
|
111
|
+
// on réessaiera au prochain tick
|
|
112
|
+
} finally {
|
|
113
|
+
clearTimeout(timeout)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private rafraichirParIframe(nomCookie: string, urlPortail: string): void {
|
|
118
|
+
// Pour éviter les cross référence, on créé un iframe qui appel portail et force la MAJ du jeton ou l'invalidation du jeton, si jamais l'utilisateur n'est plus connecté
|
|
119
|
+
// ajax vers le refresh
|
|
120
|
+
let iframe = document.createElement('iframe')
|
|
121
|
+
const url = this.getRefreshUrl(urlPortail)
|
|
122
|
+
iframe.src = `${url}?urlRetour=${encodeURI(window.localStorage.href)}`
|
|
123
|
+
iframe.id = 'idRafrToken'
|
|
124
|
+
iframe.style.display = 'none'
|
|
125
|
+
document.body.appendChild(iframe)
|
|
126
|
+
iframe.onload = () => {
|
|
127
|
+
const jetonCSQC = this.lireCookie(nomCookie)
|
|
128
|
+
if (jetonCSQC == null || jetonCSQC === '') {
|
|
129
|
+
this.estDeconnecteAzure(urlPortail)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
iframe.remove()
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private estDeconnecteAzure(urlPortail: string): void {
|
|
137
|
+
//on envoie au portail, pas le choix
|
|
138
|
+
|
|
139
|
+
const retour = encodeURI(window.location.href)
|
|
140
|
+
window.open(`${urlPortail}/home/SeConnecter?urlRetour=${retour}`, '_self')
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public deconnecterPortail(urlPortail: string): void {
|
|
145
|
+
window.location.replace(`${urlPortail}/deconnecte?urlRetour=${encodeURIComponent(window.location.href)}`)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private lireCookie(nom: string): string | null {
|
|
149
|
+
if (!document.cookie) return null
|
|
150
|
+
const cookies = document.cookie.split(';').map(c => c.trim())
|
|
151
|
+
for (const cookie of cookies) {
|
|
152
|
+
if (cookie.startsWith(`${nom}=`)) {
|
|
153
|
+
try {
|
|
154
|
+
return decodeURIComponent(cookie.substring(nom.length + 1))
|
|
155
|
+
} catch {
|
|
156
|
+
return cookie.substring(nom.length + 1)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return null
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
164
|
+
private parseJwt(token: string): any {
|
|
165
|
+
const parts = token.split('.')
|
|
166
|
+
const base64Url = parts[1]
|
|
167
|
+
if (!base64Url) throw new Error('Invalid JWT format')
|
|
168
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
169
|
+
const jsonPayload = decodeURIComponent(
|
|
170
|
+
atob(base64)
|
|
171
|
+
.split('')
|
|
172
|
+
.map(c => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
173
|
+
.join(''),
|
|
174
|
+
)
|
|
175
|
+
return JSON.parse(jsonPayload)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// URL refresh selon env (dev = proxy Vite ; prod = portail)
|
|
179
|
+
private getRefreshUrl(urlPortail: string): string {
|
|
180
|
+
if (import.meta.env.MODE === 'development') return '/portail-refresh'
|
|
181
|
+
return urlPortail + '/home/Refresh'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Instance
|
|
186
|
+
const rafraichisseurToken = new RafraichisseurToken()
|
|
187
|
+
export default rafraichisseurToken
|