codevdesign 0.0.80 → 0.0.81
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/csqcRechercheUtilisateur.vue +197 -125
- package/composants/gabarit/csqcMenu.vue +274 -274
- package/index.ts +2 -0
- package/locales/fr.json +3 -1
- package/modeles/composants/csqcMenuModele.ts +18 -18
- package/package.json +3 -3
|
@@ -1,125 +1,197 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<v-autocomplete
|
|
4
|
-
v-model="selection"
|
|
5
|
-
v-model:search="search"
|
|
6
|
-
:items="items"
|
|
7
|
-
:loading="
|
|
8
|
-
density="compact"
|
|
9
|
-
:hide-no-data="!doitAfficherAucunResultat"
|
|
10
|
-
:no-data-text="$t('csqcRechercheUtilisateur.aucunResultat')"
|
|
11
|
-
:item-title="formatterUtilisateur"
|
|
12
|
-
item-value="id"
|
|
13
|
-
:placeholder="$t('csqcRechercheUtilisateur.placeholderRechercheUtilisateur')"
|
|
14
|
-
return-object
|
|
15
|
-
autofocus
|
|
16
|
-
auto-select-first
|
|
17
|
-
variant="outlined"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}>()
|
|
33
|
-
|
|
34
|
-
const emit = defineEmits<{
|
|
35
|
-
(e: 'selection', value: string | null): void
|
|
36
|
-
(e: 'selectionPlus', utilisateur: EmployeMinsLsCodev | null): void
|
|
37
|
-
(e: 'erreur', message: string): void
|
|
38
|
-
}>()
|
|
39
|
-
|
|
40
|
-
const { t } = useI18n({ useScope: 'global' })
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const search = ref<string>('')
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-autocomplete
|
|
4
|
+
v-model="selection"
|
|
5
|
+
v-model:search="search"
|
|
6
|
+
:items="items"
|
|
7
|
+
:loading="chargementInterne"
|
|
8
|
+
density="compact"
|
|
9
|
+
:hide-no-data="!doitAfficherAucunResultat"
|
|
10
|
+
:no-data-text="$t('csqc.csqcRechercheUtilisateur.aucunResultat')"
|
|
11
|
+
:item-title="formatterUtilisateur"
|
|
12
|
+
item-value="id"
|
|
13
|
+
:placeholder="$t('csqc.csqcRechercheUtilisateur.placeholderRechercheUtilisateur')"
|
|
14
|
+
return-object
|
|
15
|
+
autofocus
|
|
16
|
+
auto-select-first
|
|
17
|
+
variant="outlined"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { ref, watch, computed } from 'vue'
|
|
24
|
+
import { useI18n } from 'vue-i18n'
|
|
25
|
+
import appAxios from '@/outils/appAxios'
|
|
26
|
+
import type { EmployeMinsLsCodev } from '../modeles/employeMinsLsCodev'
|
|
27
|
+
|
|
28
|
+
const props = defineProps<{
|
|
29
|
+
matriculeDefaut?: string | null
|
|
30
|
+
chargement?: boolean
|
|
31
|
+
urlBase: string
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
(e: 'selection', value: string | null): void
|
|
36
|
+
(e: 'selectionPlus', utilisateur: EmployeMinsLsCodev | null): void
|
|
37
|
+
(e: 'erreur', message: string): void
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const { t } = useI18n({ useScope: 'global' })
|
|
41
|
+
|
|
42
|
+
/** État interne */
|
|
43
|
+
const selection = ref<EmployeMinsLsCodev | null>(null)
|
|
44
|
+
const utilisateurs = ref<EmployeMinsLsCodev[]>([])
|
|
45
|
+
const search = ref<string>('')
|
|
46
|
+
const erreur = ref<string | null>(null)
|
|
47
|
+
|
|
48
|
+
/** Charge interne : on combine le chargement externe (prop) et l’interne */
|
|
49
|
+
const chargementInterne = ref(false)
|
|
50
|
+
const chargementEffectif = computed(() => props.chargement === true || chargementInterne.value)
|
|
51
|
+
|
|
52
|
+
/** Items sécurisés pour l’autocomplete */
|
|
53
|
+
const items = computed<EmployeMinsLsCodev[]>(() => (Array.isArray(utilisateurs.value) ? utilisateurs.value : []))
|
|
54
|
+
|
|
55
|
+
/** Cache clé→liste (toujours des arrays valides) */
|
|
56
|
+
const cache = ref<Record<string, EmployeMinsLsCodev[]>>({})
|
|
57
|
+
|
|
58
|
+
/** Détection d’un terme valide (limite les calls) */
|
|
59
|
+
const estTermeValide = (terme?: string): boolean => !!terme && terme.trim().length >= 4 && !terme.includes('(')
|
|
60
|
+
|
|
61
|
+
/** Affichage “aucun résultat” contrôlé */
|
|
62
|
+
const doitAfficherAucunResultat = computed(
|
|
63
|
+
() => estTermeValide(search.value) && !chargementEffectif.value && items.value.length === 0,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
/** Formattage d’un employé en ligne lisible */
|
|
67
|
+
const formatterUtilisateur = (item: EmployeMinsLsCodev): string => {
|
|
68
|
+
const lieu = [item.numeroLieuPrincipal, item.nomLieuPrincipal].filter(Boolean).join('-')
|
|
69
|
+
const corps = [item.corpsEmploiPrincipal, item.corpsEmploiPrincipalDescription].filter(Boolean).join('-')
|
|
70
|
+
return `${item.prenom} ${item.nom} (${item.matricule}), ${item.courrielProfessionnel}${lieu ? `, ${lieu}` : ''}${corps ? `, ${corps}` : ''}`
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Type guard: on s’assure qu’on a bien un tableau d’employés */
|
|
74
|
+
function isEmployeArray(x: unknown): x is EmployeMinsLsCodev[] {
|
|
75
|
+
return (
|
|
76
|
+
Array.isArray(x) && x.every(u => u && typeof u === 'object' && 'prenom' in u && 'nom' in u && 'matricule' in u)
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Réinitialise proprement la liste + émet une erreur optionnelle */
|
|
81
|
+
function safeClearUsers(msg?: string) {
|
|
82
|
+
utilisateurs.value = []
|
|
83
|
+
if (msg) {
|
|
84
|
+
erreur.value = msg
|
|
85
|
+
emit('erreur', msg)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Anti-race condition: on ne retient le résultat que si l’ID correspond */
|
|
90
|
+
let lastQueryId = 0
|
|
91
|
+
|
|
92
|
+
async function rechercherUtilisateurs(terme?: string) {
|
|
93
|
+
if (!estTermeValide(terme)) {
|
|
94
|
+
utilisateurs.value = []
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const queryId = ++lastQueryId
|
|
99
|
+
const termeLower = terme!.toLowerCase()
|
|
100
|
+
|
|
101
|
+
// Cache prefix-match: on prend la plus longue clé qui matche le début
|
|
102
|
+
const cachedKey = Object.keys(cache.value)
|
|
103
|
+
.filter(k => termeLower.startsWith(k))
|
|
104
|
+
.sort((a, b) => b.length - a.length)[0]
|
|
105
|
+
|
|
106
|
+
if (cachedKey) {
|
|
107
|
+
const cached = cache.value[cachedKey]
|
|
108
|
+
if (isEmployeArray(cached)) {
|
|
109
|
+
// Filtre côté client pour les affiner
|
|
110
|
+
const tl = termeLower
|
|
111
|
+
utilisateurs.value = cached.filter(user => formatterUtilisateur(user).toLowerCase().includes(tl))
|
|
112
|
+
return
|
|
113
|
+
} else {
|
|
114
|
+
// Cache corrompu (théorique)
|
|
115
|
+
delete cache.value[cachedKey]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
chargementInterne.value = true
|
|
121
|
+
const url = `${props.urlBase}/api/ComposantUI/Utilisateurs/${encodeURIComponent(terme as string)}`
|
|
122
|
+
const reponse = await appAxios.getAxios().get<unknown>(url)
|
|
123
|
+
const data = (reponse as any)?.data ?? reponse
|
|
124
|
+
|
|
125
|
+
if (queryId !== lastQueryId) {
|
|
126
|
+
// Une requête plus récente est arrivée, on ignore
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!isEmployeArray(data)) {
|
|
131
|
+
// Probable HTML/redirect login/erreur
|
|
132
|
+
safeClearUsers(t('csqc.csqcRechercheUtilisateur.erreur'))
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
utilisateurs.value = data
|
|
137
|
+
cache.value[termeLower] = data
|
|
138
|
+
} catch (e: unknown) {
|
|
139
|
+
let message = t('csqc.csqcRechercheUtilisateur.erreur')
|
|
140
|
+
if (e instanceof Error) message = e.message
|
|
141
|
+
else if (typeof e === 'string') message = e
|
|
142
|
+
safeClearUsers(message)
|
|
143
|
+
} finally {
|
|
144
|
+
chargementInterne.value = false
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Debounce recherche */
|
|
149
|
+
let timer: number | undefined
|
|
150
|
+
watch(
|
|
151
|
+
search,
|
|
152
|
+
terme => {
|
|
153
|
+
if (chargementEffectif.value) return
|
|
154
|
+
window.clearTimeout(timer)
|
|
155
|
+
timer = window.setTimeout(() => rechercherUtilisateurs(terme), 250)
|
|
156
|
+
},
|
|
157
|
+
{ flush: 'post' },
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
/** Émettre la sélection (email & objet complet) */
|
|
161
|
+
watch(selection, utilisateur => {
|
|
162
|
+
emit('selection', utilisateur?.courrielProfessionnel ?? null)
|
|
163
|
+
emit('selectionPlus', utilisateur ?? null)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
/** Préchargement par matricule par défaut */
|
|
167
|
+
watch(
|
|
168
|
+
() => props.matriculeDefaut,
|
|
169
|
+
async (nv, ov) => {
|
|
170
|
+
// Si vide / nul → on nettoie
|
|
171
|
+
if (!nv || nv.trim() === '') {
|
|
172
|
+
selection.value = null
|
|
173
|
+
search.value = ''
|
|
174
|
+
utilisateurs.value = []
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Si la même valeur est déjà sélectionnée → rien à faire
|
|
179
|
+
if (selection.value?.matricule === nv) return
|
|
180
|
+
|
|
181
|
+
// Recherche par matricule par défaut
|
|
182
|
+
await rechercherUtilisateurs(nv)
|
|
183
|
+
if (utilisateurs.value.length > 0) {
|
|
184
|
+
const utilisateur = utilisateurs.value.find(u => u.matricule === nv) ?? null
|
|
185
|
+
if (utilisateur) {
|
|
186
|
+
search.value = formatterUtilisateur(utilisateur)
|
|
187
|
+
selection.value = utilisateur
|
|
188
|
+
} else {
|
|
189
|
+
// Pas trouvé → reset “propre”
|
|
190
|
+
selection.value = null
|
|
191
|
+
search.value = nv // ou ''
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{ immediate: true },
|
|
196
|
+
)
|
|
197
|
+
</script>
|
|
@@ -1,274 +1,274 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- desktop -->
|
|
3
|
-
<div v-if="!estMobile">
|
|
4
|
-
<v-toolbar
|
|
5
|
-
class="pa-0 ajouterPointeur barreMenu"
|
|
6
|
-
:border="false"
|
|
7
|
-
elevation="2"
|
|
8
|
-
>
|
|
9
|
-
<div
|
|
10
|
-
v-for="item in filtrerMenuItems"
|
|
11
|
-
:key="item.
|
|
12
|
-
class="pt-1"
|
|
13
|
-
>
|
|
14
|
-
<v-btn
|
|
15
|
-
v-if="doitAfficherItemMenu(item)"
|
|
16
|
-
variant="text"
|
|
17
|
-
:to="item.path"
|
|
18
|
-
:active="item.path === route"
|
|
19
|
-
:active-color="'white'"
|
|
20
|
-
:style="'min-width: 100px;'"
|
|
21
|
-
>{{ item.
|
|
22
|
-
>
|
|
23
|
-
</div>
|
|
24
|
-
<v-spacer></v-spacer>
|
|
25
|
-
<!-- Sous Liste -->
|
|
26
|
-
<v-menu
|
|
27
|
-
v-for="(item, index) in filtrerSousListe"
|
|
28
|
-
:key="index"
|
|
29
|
-
open-on-hover
|
|
30
|
-
>
|
|
31
|
-
<template #activator="{ props }">
|
|
32
|
-
<v-btn
|
|
33
|
-
color="white"
|
|
34
|
-
v-bind="props"
|
|
35
|
-
:active="estActifSousliste(item)"
|
|
36
|
-
>
|
|
37
|
-
{{ item.nom }}
|
|
38
|
-
</v-btn>
|
|
39
|
-
</template>
|
|
40
|
-
|
|
41
|
-
<v-list
|
|
42
|
-
style="background-color: #223654 !important"
|
|
43
|
-
min-width="230px"
|
|
44
|
-
>
|
|
45
|
-
<v-list-item
|
|
46
|
-
v-for="(sousitem, sousindex) in obtenirItemsSousListeSelonDroits(item.id)"
|
|
47
|
-
:key="sousindex"
|
|
48
|
-
>
|
|
49
|
-
<v-btn
|
|
50
|
-
:max-height="35"
|
|
51
|
-
width="100%"
|
|
52
|
-
class="params_item"
|
|
53
|
-
:to="sousitem.path"
|
|
54
|
-
variant="text"
|
|
55
|
-
:active="sousitem.path === route"
|
|
56
|
-
>{{ sousitem.
|
|
57
|
-
>
|
|
58
|
-
</v-list-item>
|
|
59
|
-
</v-list>
|
|
60
|
-
</v-menu>
|
|
61
|
-
<v-btn
|
|
62
|
-
v-if="btnDeconnexion"
|
|
63
|
-
variant="text"
|
|
64
|
-
:style="'min-width: 100px;'"
|
|
65
|
-
@click="deconnexion"
|
|
66
|
-
>{{ $t('csqc.csqcMenu.deconnexion') }}</v-btn
|
|
67
|
-
>
|
|
68
|
-
</v-toolbar>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<!-- mobile -->
|
|
72
|
-
<div v-else>
|
|
73
|
-
<v-toolbar class="pa-0 ajouterPointeur barreMenuMobile">
|
|
74
|
-
<v-app-bar-nav-icon
|
|
75
|
-
variant="text"
|
|
76
|
-
@click.stop="menu = !menu"
|
|
77
|
-
></v-app-bar-nav-icon>
|
|
78
|
-
<v-toolbar-title
|
|
79
|
-
><label
|
|
80
|
-
class="ajouterPointeur"
|
|
81
|
-
style="color: white !important"
|
|
82
|
-
>{{ $t('menu.menu') }}</label
|
|
83
|
-
>
|
|
84
|
-
</v-toolbar-title>
|
|
85
|
-
</v-toolbar>
|
|
86
|
-
|
|
87
|
-
<v-navigation-drawer
|
|
88
|
-
v-model="menu"
|
|
89
|
-
nav
|
|
90
|
-
>
|
|
91
|
-
<v-list>
|
|
92
|
-
<div
|
|
93
|
-
v-for="item in filtrerMenuItems"
|
|
94
|
-
:key="item.
|
|
95
|
-
>
|
|
96
|
-
<v-list-item
|
|
97
|
-
:to="item.path"
|
|
98
|
-
:active="item.path === route"
|
|
99
|
-
:title="item.
|
|
100
|
-
/>
|
|
101
|
-
</div>
|
|
102
|
-
<div
|
|
103
|
-
v-for="item in filtrerSousListe"
|
|
104
|
-
:key="item.id"
|
|
105
|
-
>
|
|
106
|
-
<v-list-group :value="item.nom">
|
|
107
|
-
<template #activator="{ props }">
|
|
108
|
-
<v-list-item
|
|
109
|
-
v-bind="props"
|
|
110
|
-
:title="item.nom"
|
|
111
|
-
/>
|
|
112
|
-
</template>
|
|
113
|
-
<div
|
|
114
|
-
v-for="(sousitem, index) in obtenirItemsSousListeSelonDroits(item.id)"
|
|
115
|
-
:key="index"
|
|
116
|
-
>
|
|
117
|
-
<v-list-item
|
|
118
|
-
:title="sousitem.
|
|
119
|
-
:value="sousitem.
|
|
120
|
-
:to="sousitem.path"
|
|
121
|
-
/>
|
|
122
|
-
</div>
|
|
123
|
-
</v-list-group>
|
|
124
|
-
<v-list-item
|
|
125
|
-
v-if="btnDeconnexion"
|
|
126
|
-
:title="$t('csqc.csqcMenu.deconnexion')"
|
|
127
|
-
@click="deconnexion"
|
|
128
|
-
/>
|
|
129
|
-
</div>
|
|
130
|
-
</v-list>
|
|
131
|
-
</v-navigation-drawer>
|
|
132
|
-
</div>
|
|
133
|
-
</template>
|
|
134
|
-
|
|
135
|
-
<script setup lang="ts">
|
|
136
|
-
import type { MenuItem, SousListe, SousListeItems } from '../../modeles/composants/csqcMenuModele'
|
|
137
|
-
import { ref, computed } from 'vue'
|
|
138
|
-
|
|
139
|
-
const props = defineProps({
|
|
140
|
-
estMobile: {
|
|
141
|
-
type: Boolean,
|
|
142
|
-
required: true,
|
|
143
|
-
},
|
|
144
|
-
btnDeconnexion: {
|
|
145
|
-
type: Boolean,
|
|
146
|
-
required: false,
|
|
147
|
-
},
|
|
148
|
-
route: {
|
|
149
|
-
type: String,
|
|
150
|
-
required: true,
|
|
151
|
-
},
|
|
152
|
-
menuItems: {
|
|
153
|
-
type: Array as () => MenuItem[],
|
|
154
|
-
required: true,
|
|
155
|
-
},
|
|
156
|
-
sousliste: {
|
|
157
|
-
type: Array as () => SousListe[],
|
|
158
|
-
required: false,
|
|
159
|
-
default: () => [],
|
|
160
|
-
},
|
|
161
|
-
souslisteItems: {
|
|
162
|
-
type: Array as () => SousListeItems[],
|
|
163
|
-
required: false,
|
|
164
|
-
default: () => [],
|
|
165
|
-
},
|
|
166
|
-
droitsMap: {
|
|
167
|
-
type: Object as () => Record<string, boolean>,
|
|
168
|
-
required: true,
|
|
169
|
-
default: () => ({}),
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
const menu = ref<boolean>(false)
|
|
174
|
-
const emit = defineEmits(['deconnexion'])
|
|
175
|
-
|
|
176
|
-
/*const verifierDroits = (monelement: string) => {
|
|
177
|
-
return props.droitsMap[monelement] || false
|
|
178
|
-
}*/
|
|
179
|
-
|
|
180
|
-
const deconnexion = () => {
|
|
181
|
-
emit('deconnexion')
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const doitAfficherItemMenu = (item: MenuItem) => {
|
|
185
|
-
return props.droitsMap[item.droit] || false
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const filtrerMenuItems = computed(() => {
|
|
189
|
-
return props.menuItems.filter(item => props.droitsMap[item.droit])
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
const filtrerSousListe = computed(() => {
|
|
193
|
-
return props.sousliste.filter(item => props.droitsMap[item.droit])
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
const obtenirItemsSousListeSelonDroits = (monitemId: number) => {
|
|
197
|
-
return props.souslisteItems.filter(item => item.parentId === monitemId && props.droitsMap[item.droit])
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Vérifie si un item de la sous-liste est actif (route correspond à un item)
|
|
201
|
-
const estActifSousliste = (item: SousListe) => {
|
|
202
|
-
// Vérifie si un des sous-items correspond à la route
|
|
203
|
-
return obtenirItemsSousListeSelonDroits(item.id).some(sousitem => sousitem.path === props.route)
|
|
204
|
-
}
|
|
205
|
-
</script>
|
|
206
|
-
<style lang="css" scoped>
|
|
207
|
-
/* desktop background de la barre de menu et hauteur */
|
|
208
|
-
.v-toolbar {
|
|
209
|
-
background-color: #223654;
|
|
210
|
-
height: 64px;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/* desktop couleur du texte de la barre, marge du haut, padding */
|
|
214
|
-
.barreMenu {
|
|
215
|
-
color: white !important;
|
|
216
|
-
padding: 0 10px 0 10px !important;
|
|
217
|
-
}
|
|
218
|
-
/* desktop */
|
|
219
|
-
.v-btn {
|
|
220
|
-
font-weight: 400;
|
|
221
|
-
height: 72px !important;
|
|
222
|
-
}
|
|
223
|
-
/* desktop */
|
|
224
|
-
.v-btn--active {
|
|
225
|
-
font-weight: 600 !important;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/* desktop empeche le texte parametre detre trop bas */
|
|
229
|
-
.params {
|
|
230
|
-
padding-top: 5px !important;
|
|
231
|
-
}
|
|
232
|
-
/* desktop */
|
|
233
|
-
.params_item {
|
|
234
|
-
font-weight: 400;
|
|
235
|
-
color: white !important;
|
|
236
|
-
background-color: #223654 !important;
|
|
237
|
-
}
|
|
238
|
-
/* desktop */
|
|
239
|
-
.params_item.v-btn--active {
|
|
240
|
-
color: white !important;
|
|
241
|
-
font-weight: 600 !important;
|
|
242
|
-
}
|
|
243
|
-
/* desktop */
|
|
244
|
-
.params_item.v-btn--active:hover {
|
|
245
|
-
color: white !important;
|
|
246
|
-
background-color: #223654 !important;
|
|
247
|
-
}
|
|
248
|
-
/* desktop */
|
|
249
|
-
.params_item.v-btn--active:hover::before {
|
|
250
|
-
color: #ffffff80 !important;
|
|
251
|
-
}
|
|
252
|
-
/* desktop */
|
|
253
|
-
.params_item.v-btn--active::before {
|
|
254
|
-
opacity: 0.24;
|
|
255
|
-
border-radius: 0;
|
|
256
|
-
color: #ffffff80 !important;
|
|
257
|
-
margin-top: 1px !important;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/* mobile couleur du texte de la barre, marge du haut, padding */
|
|
261
|
-
.barreMenuMobile {
|
|
262
|
-
color: white !important;
|
|
263
|
-
padding: 0 10px 0 10px !important;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/* mobile drawer apparait sous les app bar */
|
|
267
|
-
.v-navigation-drawer {
|
|
268
|
-
top: 132px !important;
|
|
269
|
-
}
|
|
270
|
-
/* mobile drawer, Calcule la hauteur comme étant 100% moins 132px pour afficher le scroll */
|
|
271
|
-
:deep(.v-navigation-drawer__content) {
|
|
272
|
-
height: calc(100% - 132px);
|
|
273
|
-
}
|
|
274
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<!-- desktop -->
|
|
3
|
+
<div v-if="!estMobile">
|
|
4
|
+
<v-toolbar
|
|
5
|
+
class="pa-0 ajouterPointeur barreMenu"
|
|
6
|
+
:border="false"
|
|
7
|
+
elevation="2"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
v-for="item in filtrerMenuItems"
|
|
11
|
+
:key="item.nom"
|
|
12
|
+
class="pt-1"
|
|
13
|
+
>
|
|
14
|
+
<v-btn
|
|
15
|
+
v-if="doitAfficherItemMenu(item)"
|
|
16
|
+
variant="text"
|
|
17
|
+
:to="item.path"
|
|
18
|
+
:active="item.path === route"
|
|
19
|
+
:active-color="'white'"
|
|
20
|
+
:style="'min-width: 100px;'"
|
|
21
|
+
>{{ item.nom }}</v-btn
|
|
22
|
+
>
|
|
23
|
+
</div>
|
|
24
|
+
<v-spacer></v-spacer>
|
|
25
|
+
<!-- Sous Liste -->
|
|
26
|
+
<v-menu
|
|
27
|
+
v-for="(item, index) in filtrerSousListe"
|
|
28
|
+
:key="index"
|
|
29
|
+
open-on-hover
|
|
30
|
+
>
|
|
31
|
+
<template #activator="{ props }">
|
|
32
|
+
<v-btn
|
|
33
|
+
color="white"
|
|
34
|
+
v-bind="props"
|
|
35
|
+
:active="estActifSousliste(item)"
|
|
36
|
+
>
|
|
37
|
+
{{ item.nom }}
|
|
38
|
+
</v-btn>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<v-list
|
|
42
|
+
style="background-color: #223654 !important"
|
|
43
|
+
min-width="230px"
|
|
44
|
+
>
|
|
45
|
+
<v-list-item
|
|
46
|
+
v-for="(sousitem, sousindex) in obtenirItemsSousListeSelonDroits(item.id)"
|
|
47
|
+
:key="sousindex"
|
|
48
|
+
>
|
|
49
|
+
<v-btn
|
|
50
|
+
:max-height="35"
|
|
51
|
+
width="100%"
|
|
52
|
+
class="params_item"
|
|
53
|
+
:to="sousitem.path"
|
|
54
|
+
variant="text"
|
|
55
|
+
:active="sousitem.path === route"
|
|
56
|
+
>{{ sousitem.nom }}</v-btn
|
|
57
|
+
>
|
|
58
|
+
</v-list-item>
|
|
59
|
+
</v-list>
|
|
60
|
+
</v-menu>
|
|
61
|
+
<v-btn
|
|
62
|
+
v-if="btnDeconnexion"
|
|
63
|
+
variant="text"
|
|
64
|
+
:style="'min-width: 100px;'"
|
|
65
|
+
@click="deconnexion"
|
|
66
|
+
>{{ $t('csqc.csqcMenu.deconnexion') }}</v-btn
|
|
67
|
+
>
|
|
68
|
+
</v-toolbar>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<!-- mobile -->
|
|
72
|
+
<div v-else>
|
|
73
|
+
<v-toolbar class="pa-0 ajouterPointeur barreMenuMobile">
|
|
74
|
+
<v-app-bar-nav-icon
|
|
75
|
+
variant="text"
|
|
76
|
+
@click.stop="menu = !menu"
|
|
77
|
+
></v-app-bar-nav-icon>
|
|
78
|
+
<v-toolbar-title
|
|
79
|
+
><label
|
|
80
|
+
class="ajouterPointeur"
|
|
81
|
+
style="color: white !important"
|
|
82
|
+
>{{ $t('menu.menu') }}</label
|
|
83
|
+
>
|
|
84
|
+
</v-toolbar-title>
|
|
85
|
+
</v-toolbar>
|
|
86
|
+
|
|
87
|
+
<v-navigation-drawer
|
|
88
|
+
v-model="menu"
|
|
89
|
+
nav
|
|
90
|
+
>
|
|
91
|
+
<v-list>
|
|
92
|
+
<div
|
|
93
|
+
v-for="item in filtrerMenuItems"
|
|
94
|
+
:key="item.nom"
|
|
95
|
+
>
|
|
96
|
+
<v-list-item
|
|
97
|
+
:to="item.path"
|
|
98
|
+
:active="item.path === route"
|
|
99
|
+
:title="item.nom"
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
<div
|
|
103
|
+
v-for="item in filtrerSousListe"
|
|
104
|
+
:key="item.id"
|
|
105
|
+
>
|
|
106
|
+
<v-list-group :value="item.nom">
|
|
107
|
+
<template #activator="{ props }">
|
|
108
|
+
<v-list-item
|
|
109
|
+
v-bind="props"
|
|
110
|
+
:title="item.nom"
|
|
111
|
+
/>
|
|
112
|
+
</template>
|
|
113
|
+
<div
|
|
114
|
+
v-for="(sousitem, index) in obtenirItemsSousListeSelonDroits(item.id)"
|
|
115
|
+
:key="index"
|
|
116
|
+
>
|
|
117
|
+
<v-list-item
|
|
118
|
+
:title="sousitem.nom"
|
|
119
|
+
:value="sousitem.nom"
|
|
120
|
+
:to="sousitem.path"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</v-list-group>
|
|
124
|
+
<v-list-item
|
|
125
|
+
v-if="btnDeconnexion"
|
|
126
|
+
:title="$t('csqc.csqcMenu.deconnexion')"
|
|
127
|
+
@click="deconnexion"
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
</v-list>
|
|
131
|
+
</v-navigation-drawer>
|
|
132
|
+
</div>
|
|
133
|
+
</template>
|
|
134
|
+
|
|
135
|
+
<script setup lang="ts">
|
|
136
|
+
import type { MenuItem, SousListe, SousListeItems } from '../../modeles/composants/csqcMenuModele'
|
|
137
|
+
import { ref, computed } from 'vue'
|
|
138
|
+
|
|
139
|
+
const props = defineProps({
|
|
140
|
+
estMobile: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
required: true,
|
|
143
|
+
},
|
|
144
|
+
btnDeconnexion: {
|
|
145
|
+
type: Boolean,
|
|
146
|
+
required: false,
|
|
147
|
+
},
|
|
148
|
+
route: {
|
|
149
|
+
type: String,
|
|
150
|
+
required: true,
|
|
151
|
+
},
|
|
152
|
+
menuItems: {
|
|
153
|
+
type: Array as () => MenuItem[],
|
|
154
|
+
required: true,
|
|
155
|
+
},
|
|
156
|
+
sousliste: {
|
|
157
|
+
type: Array as () => SousListe[],
|
|
158
|
+
required: false,
|
|
159
|
+
default: () => [],
|
|
160
|
+
},
|
|
161
|
+
souslisteItems: {
|
|
162
|
+
type: Array as () => SousListeItems[],
|
|
163
|
+
required: false,
|
|
164
|
+
default: () => [],
|
|
165
|
+
},
|
|
166
|
+
droitsMap: {
|
|
167
|
+
type: Object as () => Record<string, boolean>,
|
|
168
|
+
required: true,
|
|
169
|
+
default: () => ({}),
|
|
170
|
+
},
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const menu = ref<boolean>(false)
|
|
174
|
+
const emit = defineEmits(['deconnexion'])
|
|
175
|
+
|
|
176
|
+
/*const verifierDroits = (monelement: string) => {
|
|
177
|
+
return props.droitsMap[monelement] || false
|
|
178
|
+
}*/
|
|
179
|
+
|
|
180
|
+
const deconnexion = () => {
|
|
181
|
+
emit('deconnexion')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const doitAfficherItemMenu = (item: MenuItem) => {
|
|
185
|
+
return props.droitsMap[item.droit] || false
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const filtrerMenuItems = computed(() => {
|
|
189
|
+
return props.menuItems.filter(item => props.droitsMap[item.droit])
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
const filtrerSousListe = computed(() => {
|
|
193
|
+
return props.sousliste.filter(item => props.droitsMap[item.droit])
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
const obtenirItemsSousListeSelonDroits = (monitemId: number) => {
|
|
197
|
+
return props.souslisteItems.filter(item => item.parentId === monitemId && props.droitsMap[item.droit])
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Vérifie si un item de la sous-liste est actif (route correspond à un item)
|
|
201
|
+
const estActifSousliste = (item: SousListe) => {
|
|
202
|
+
// Vérifie si un des sous-items correspond à la route
|
|
203
|
+
return obtenirItemsSousListeSelonDroits(item.id).some(sousitem => sousitem.path === props.route)
|
|
204
|
+
}
|
|
205
|
+
</script>
|
|
206
|
+
<style lang="css" scoped>
|
|
207
|
+
/* desktop background de la barre de menu et hauteur */
|
|
208
|
+
.v-toolbar {
|
|
209
|
+
background-color: #223654;
|
|
210
|
+
height: 64px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* desktop couleur du texte de la barre, marge du haut, padding */
|
|
214
|
+
.barreMenu {
|
|
215
|
+
color: white !important;
|
|
216
|
+
padding: 0 10px 0 10px !important;
|
|
217
|
+
}
|
|
218
|
+
/* desktop */
|
|
219
|
+
.v-btn {
|
|
220
|
+
font-weight: 400;
|
|
221
|
+
height: 72px !important;
|
|
222
|
+
}
|
|
223
|
+
/* desktop */
|
|
224
|
+
.v-btn--active {
|
|
225
|
+
font-weight: 600 !important;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* desktop empeche le texte parametre detre trop bas */
|
|
229
|
+
.params {
|
|
230
|
+
padding-top: 5px !important;
|
|
231
|
+
}
|
|
232
|
+
/* desktop */
|
|
233
|
+
.params_item {
|
|
234
|
+
font-weight: 400;
|
|
235
|
+
color: white !important;
|
|
236
|
+
background-color: #223654 !important;
|
|
237
|
+
}
|
|
238
|
+
/* desktop */
|
|
239
|
+
.params_item.v-btn--active {
|
|
240
|
+
color: white !important;
|
|
241
|
+
font-weight: 600 !important;
|
|
242
|
+
}
|
|
243
|
+
/* desktop */
|
|
244
|
+
.params_item.v-btn--active:hover {
|
|
245
|
+
color: white !important;
|
|
246
|
+
background-color: #223654 !important;
|
|
247
|
+
}
|
|
248
|
+
/* desktop */
|
|
249
|
+
.params_item.v-btn--active:hover::before {
|
|
250
|
+
color: #ffffff80 !important;
|
|
251
|
+
}
|
|
252
|
+
/* desktop */
|
|
253
|
+
.params_item.v-btn--active::before {
|
|
254
|
+
opacity: 0.24;
|
|
255
|
+
border-radius: 0;
|
|
256
|
+
color: #ffffff80 !important;
|
|
257
|
+
margin-top: 1px !important;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* mobile couleur du texte de la barre, marge du haut, padding */
|
|
261
|
+
.barreMenuMobile {
|
|
262
|
+
color: white !important;
|
|
263
|
+
padding: 0 10px 0 10px !important;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* mobile drawer apparait sous les app bar */
|
|
267
|
+
.v-navigation-drawer {
|
|
268
|
+
top: 132px !important;
|
|
269
|
+
}
|
|
270
|
+
/* mobile drawer, Calcule la hauteur comme étant 100% moins 132px pour afficher le scroll */
|
|
271
|
+
:deep(.v-navigation-drawer__content) {
|
|
272
|
+
height: calc(100% - 132px);
|
|
273
|
+
}
|
|
274
|
+
</style>
|
package/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import csqcTexteBilingue from './composants/csqcTexteBilingue.vue'
|
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
import csqcEditeurTexteRiche from './composants/csqcEditeurTexteRiche.vue'
|
|
19
19
|
import csqcImportCSV from './composants/csqcImportCSV.vue'
|
|
20
|
+
import csqcRechercheUtilisateur from './composants/csqcRechercheUtilisateur.vue'
|
|
20
21
|
import validateurs from './composants/validateurs'
|
|
21
22
|
|
|
22
23
|
// modèles
|
|
@@ -53,6 +54,7 @@ export {
|
|
|
53
54
|
csqcEditeurTexteRiche,
|
|
54
55
|
validateurs,
|
|
55
56
|
csqcImportCSV,
|
|
57
|
+
csqcRechercheUtilisateur,
|
|
56
58
|
|
|
57
59
|
modeleSnackbar,
|
|
58
60
|
modeleDatatableColonne,
|
package/locales/fr.json
CHANGED
|
@@ -62,7 +62,9 @@
|
|
|
62
62
|
"placeholderRechercheUtilisateur": "Rechercher un utilisateur",
|
|
63
63
|
"revenirRecherche": "Retour à la recherche",
|
|
64
64
|
"utilisateurIntrouvable": "Employé introuvable",
|
|
65
|
-
"utilisateurs": "Employé"
|
|
65
|
+
"utilisateurs": "Employé",
|
|
66
|
+
"aucunResultat": "Aucun résultat trouvé",
|
|
67
|
+
"erreur": "Une erreur est survenue lors de la recherche de l'utilisateur."
|
|
66
68
|
},
|
|
67
69
|
"label": {
|
|
68
70
|
"actif": "Actif",
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export interface MenuItem {
|
|
2
|
-
|
|
3
|
-
path: string
|
|
4
|
-
droit: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface SousListe {
|
|
8
|
-
droit: string
|
|
9
|
-
id: number
|
|
10
|
-
nom: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface SousListeItems {
|
|
14
|
-
parentId: number
|
|
15
|
-
|
|
16
|
-
path: string
|
|
17
|
-
droit: string
|
|
18
|
-
}
|
|
1
|
+
export interface MenuItem {
|
|
2
|
+
nom: string
|
|
3
|
+
path: string
|
|
4
|
+
droit: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface SousListe {
|
|
8
|
+
droit: string
|
|
9
|
+
id: number
|
|
10
|
+
nom: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SousListeItems {
|
|
14
|
+
parentId: number
|
|
15
|
+
nom: string
|
|
16
|
+
path: string
|
|
17
|
+
droit: string
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codevdesign",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.81",
|
|
4
4
|
"description": "Composants Vuetify 3 pour les projets Codev",
|
|
5
5
|
"files": [
|
|
6
6
|
"./**/*.vue",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "vite build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"vuetify": "^3.
|
|
16
|
+
"vuetify": "^3.9.0",
|
|
17
17
|
"vue-i18n": "^11.0.0",
|
|
18
18
|
"@e965/xlsx": "^0.20.3",
|
|
19
19
|
"tinymce": "^8.0.2",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.13.5",
|
|
25
25
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
26
|
-
"typescript": "^5.
|
|
26
|
+
"typescript": "^5.8.3",
|
|
27
27
|
"vite": "^7.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|