codevdesign 1.0.10 → 1.0.12

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.
@@ -13,8 +13,8 @@
13
13
  <v-col cols="auto">
14
14
  <a
15
15
  :href="href"
16
- :target="cssUrlValide ? '_blank' : null"
17
- :rel="cssUrlValide ? 'noopener noreferrer' : null"
16
+ :target="cssUrlValide ? '_blank' : undefined"
17
+ :rel="cssUrlValide ? 'noopener noreferrer' : undefined"
18
18
  >
19
19
  <!-- Placeholder (même taille) pendant la décision -->
20
20
  <div
package/index.ts CHANGED
@@ -1,73 +1,75 @@
1
- import csqcAlerteErreur from './composants/csqcAlerteErreur.vue'
2
- import csqcDialogue from './composants/csqcDialogue.vue'
3
- import csqcOptionSwitch from './composants/csqcOptionSwitch.vue'
4
- import csqcRecherche from './composants/csqcRecherche.vue'
5
- import csqcSnackbar from './composants/csqcSnackbar.vue'
6
- import csqcTiroir from './composants/csqcTiroir.vue'
7
- import pivEntete from './composants/gabarit/pivEntete.vue'
8
- import pivFooter from './composants/gabarit/pivPiedPage.vue'
9
- import csqcMenu from './composants/gabarit/csqcMenu.vue'
10
- import csqcConfirmation from './composants/csqcConfirmation.vue'
11
- import csqcSaisie from './composants/csqcModaleSaisie.vue'
12
- import csqcDate from './composants/csqcDate.vue'
13
- import csqcTable from './composants/csqcTable/csqcTable.vue'
14
- import csqcCodeBudgetaire from './composants/csqcCodeBudgetaireGenerique.vue'
15
- import csqcChaise from './composants/csqcChaise/chaiseConteneur.vue'
16
- import csqcAide from './composants/csqcAide.vue'
17
- import csqcEntete from './composants/csqcEntete.vue'
18
- import csqcTexteBilingue from './composants/csqcTexteBilingue.vue'
19
- // @ts-expect-error TS7016
20
- import csqcEditeurTexteRiche from './composants/csqcEditeurTexteRiche.vue'
21
- import csqcImportCSV from './composants/csqcImportCSV.vue'
22
- import csqcRechercheUtilisateur from './composants/csqcRechercheUtilisateur.vue'
23
- import validateurs from './composants/validateurs'
24
-
25
- // modèles
26
- import NotificationGabaritDefaut from './modeles/notificationGabaritDefaut'
27
- import modeleSnackbar from './modeles/composants/snackbar'
28
- import modeleDatatableColonne from './modeles/composants/datatableColonne'
29
- import apiReponse from './modeles/apiReponse'
30
- import data from './modeles/data'
31
- import response from './modeles/response'
32
-
33
- // outils
34
- import csqcRafraichisseurToken from './outils/rafraichisseurToken'
35
-
36
- // i18n
37
- import csqcEn from './locales/en.json'
38
- import csqcFr from './locales/fr.json'
39
-
40
-
41
- export {
42
- csqcFr,
43
- csqcEn,
44
- csqcAlerteErreur,
45
- csqcDialogue,
46
- csqcConfirmation,
47
- csqcSaisie,
48
- csqcDate,
49
- csqcOptionSwitch,
50
- csqcRecherche,
51
- csqcSnackbar,
52
- csqcTable,
53
- csqcTiroir,
54
- csqcMenu,
55
- csqcCodeBudgetaire,
56
- csqcChaise,
57
- pivFooter,
58
- pivEntete,
59
- csqcAide,
60
- csqcEntete,
61
- csqcTexteBilingue,
62
- csqcEditeurTexteRiche,
63
- validateurs,
64
- csqcImportCSV,
65
- csqcRechercheUtilisateur,
66
- csqcRafraichisseurToken,
67
- modeleSnackbar,
68
- modeleDatatableColonne as colonne,
69
- apiReponse,
70
- data,
71
- response,
72
- NotificationGabaritDefaut,
73
- }
1
+ import csqcAlerteErreur from './composants/csqcAlerteErreur.vue'
2
+ import csqcDialogue from './composants/csqcDialogue.vue'
3
+ import csqcOptionSwitch from './composants/csqcOptionSwitch.vue'
4
+ import csqcRecherche from './composants/csqcRecherche.vue'
5
+ import csqcSnackbar from './composants/csqcSnackbar.vue'
6
+ import csqcTiroir from './composants/csqcTiroir.vue'
7
+ import pivEntete from './composants/gabarit/pivEntete.vue'
8
+ import pivFooter from './composants/gabarit/pivPiedPage.vue'
9
+ import csqcMenu from './composants/gabarit/csqcMenu.vue'
10
+ import csqcConfirmation from './composants/csqcConfirmation.vue'
11
+ import csqcSaisie from './composants/csqcModaleSaisie.vue'
12
+ import csqcDate from './composants/csqcDate.vue'
13
+ import csqcTable from './composants/csqcTable/csqcTable.vue'
14
+ import csqcCodeBudgetaire from './composants/csqcCodeBudgetaireGenerique.vue'
15
+ import csqcChaise from './composants/csqcChaise/chaiseConteneur.vue'
16
+ import csqcAide from './composants/csqcAide.vue'
17
+ import csqcEntete from './composants/csqcEntete.vue'
18
+ import csqcTexteBilingue from './composants/csqcTexteBilingue.vue'
19
+ // @ts-expect-error TS7016
20
+ import csqcEditeurTexteRiche from './composants/csqcEditeurTexteRiche.vue'
21
+ import csqcImportCSV from './composants/csqcImportCSV.vue'
22
+ import csqcRechercheUtilisateur from './composants/csqcRechercheUtilisateur.vue'
23
+ import validateurs from './composants/validateurs'
24
+
25
+ // modèles
26
+ import NotificationGabaritDefaut from './modeles/notificationGabaritDefaut'
27
+ import modeleSnackbar from './modeles/composants/snackbar'
28
+ import modeleDatatableColonne from './modeles/composants/datatableColonne'
29
+ import apiReponse from './modeles/apiReponse'
30
+ import data from './modeles/data'
31
+ import response from './modeles/response'
32
+
33
+ // outils
34
+ import csqcRafraichisseurToken from './outils/rafraichisseurToken'
35
+ import csqcOutils from './outils/csqcOutils'
36
+
37
+ // i18n
38
+ import csqcEn from './locales/en.json'
39
+ import csqcFr from './locales/fr.json'
40
+
41
+
42
+ export {
43
+ csqcFr,
44
+ csqcEn,
45
+ csqcAlerteErreur,
46
+ csqcDialogue,
47
+ csqcConfirmation,
48
+ csqcSaisie,
49
+ csqcDate,
50
+ csqcOptionSwitch,
51
+ csqcRecherche,
52
+ csqcSnackbar,
53
+ csqcTable,
54
+ csqcTiroir,
55
+ csqcMenu,
56
+ csqcCodeBudgetaire,
57
+ csqcChaise,
58
+ pivFooter,
59
+ pivEntete,
60
+ csqcAide,
61
+ csqcEntete,
62
+ csqcTexteBilingue,
63
+ csqcEditeurTexteRiche,
64
+ validateurs,
65
+ csqcImportCSV,
66
+ csqcRechercheUtilisateur,
67
+ csqcRafraichisseurToken,
68
+ csqcOutils,
69
+ modeleSnackbar,
70
+ modeleDatatableColonne as colonne,
71
+ apiReponse,
72
+ data,
73
+ response,
74
+ NotificationGabaritDefaut,
75
+ }
@@ -0,0 +1,116 @@
1
+ import axios, { type AxiosInstance, type AxiosError, type AxiosResponse } from 'axios'
2
+ import { useAppStore } from '@/store/appStore'
3
+ import router from '@/router'
4
+
5
+ type ApiReponse<T = unknown> =
6
+ // Succès
7
+ | {
8
+ succes: true
9
+ resultat: T
10
+ status?: number
11
+ message?: string
12
+ location?: string
13
+ parametres?: unknown
14
+ [k: string]: unknown
15
+ }
16
+ // Échec (le backend peut quand même renvoyer resultat null/absent)
17
+ | {
18
+ succes: false
19
+ resultat?: unknown
20
+ status?: number
21
+ message?: string
22
+ location?: string
23
+ parametres?: unknown
24
+ [k: string]: unknown
25
+ }
26
+
27
+ let client: AxiosInstance | null = null
28
+ let cachedBaseUrl = '' // pour éviter de régénérer une instance axios si rien n’a changé
29
+
30
+ export default {
31
+ clearCache: false,
32
+
33
+ getAxios(): AxiosInstance {
34
+ // Singleton + clearCache
35
+ if (client && !this.clearCache) return client
36
+
37
+ const appStore = useAppStore()
38
+
39
+ const rawUrl = appStore.modeleCharger
40
+ ? appStore.appModele!.urlBase
41
+ : window.location.origin + import.meta.env.BASE_URL
42
+
43
+ const urlBase = rawUrl.endsWith('/') ? rawUrl.slice(0, -1) : rawUrl
44
+
45
+ // Si la base URL n'a pas changé et qu'on a déjà un client, on le renvoie
46
+ if (client && cachedBaseUrl === urlBase && !this.clearCache) return client
47
+ cachedBaseUrl = urlBase
48
+
49
+ client = axios.create({
50
+ baseURL: `${urlBase}/api`,
51
+ withCredentials: true,
52
+ timeout: 30_000,
53
+ headers: {
54
+ Accept: 'application/json',
55
+ 'Content-Type': 'application/json',
56
+ 'X-Requested-With': 'XMLHttpRequest',
57
+ },
58
+ // validateStatus: (s) => s >= 200 && s < 300, // défaut axios
59
+ })
60
+
61
+ client.interceptors.response.use(
62
+ (response: AxiosResponse<any>) => {
63
+ const data = response.data
64
+
65
+ // Détection de la réponse { succes, resultat }
66
+ if (data && typeof data === 'object' && 'succes' in data) {
67
+ const env = data as ApiReponse
68
+ return env.succes === true ? env.resultat : Promise.reject(env)
69
+ }
70
+
71
+ // Sinon, renvoyer data si présent, sinon la réponse complète
72
+ return data ?? response
73
+ },
74
+
75
+ (error: AxiosError<any>) => {
76
+ const status = error.response?.status
77
+ const payload = error.response?.data?.resultat ?? { message: error.message }
78
+
79
+ // 403 / 404
80
+ if (status === 403 || status === 404) {
81
+ try {
82
+ appStore.lancerErreur(payload)
83
+ if (router.currentRoute.value.name !== '403') {
84
+ router.push({ name: '403' })
85
+ }
86
+ } catch {
87
+ // no-op
88
+ }
89
+ return Promise.reject(payload)
90
+ }
91
+
92
+ // gérer les autres 4XX ici
93
+
94
+ // Log minimal
95
+ console.error('HTTP error', {
96
+ status,
97
+ url: error.config?.url,
98
+ payload,
99
+ })
100
+
101
+ // Remonter l’erreur normalisée dans appstore
102
+ try {
103
+ if (payload?.resultat) appStore.lancerErreur(payload)
104
+ else if (payload) appStore.lancerErreur(payload)
105
+ } catch {
106
+ // no-op
107
+ }
108
+ return Promise.reject(payload)
109
+ },
110
+ )
111
+
112
+ // reset le flag si on l’avait utilisé pour forcer la recréation de l'instance
113
+ this.clearCache = false
114
+ return client
115
+ },
116
+ }
@@ -0,0 +1,366 @@
1
+ /** ATTENTION
2
+ * Ne pas ajouter ou modifier de fonctions ici. Créer son propre fichier d'outils pour votre app.
3
+ * Ces outils sont des outils communs.
4
+ * */
5
+
6
+ class CSQCOutils {
7
+ racineLocalStorage = 'csqc_CodevDesign'
8
+
9
+ /**
10
+ * Concatène une string avec le marqueur de séparation demandée.
11
+ * @param texteOrigine Le texte d'origine
12
+ * @param texteAjoute Le texte a concaténer
13
+ * @param separateur (Default: ', ') Le séparateur à ajouter entre les deux textes.
14
+ * */
15
+ ConcateneTexte(texteOrigine: string, texteAjoute: string, separateur: string = ', ') {
16
+ let retour = texteOrigine
17
+ if (this.TexteVide(texteOrigine) === false) {
18
+ retour += separateur
19
+ }
20
+
21
+ return retour + texteAjoute
22
+ }
23
+
24
+ /**
25
+ * Retourne true si le texte n'est pas défini ou s'il est null ou vide. Tous les espaces sont retirés par défaut.
26
+ * @param texte Le texte a inspecter.
27
+ * @param retirerEspace (Default: true) Si true, les espaces seront enlevés du texte
28
+ */
29
+ TexteVide(texte?: string | null, retirerEspace = true) {
30
+ let retour = texte === undefined || texte == null || texte === ''
31
+ if (retour === false && retirerEspace === true) {
32
+ const temp = texte
33
+ retour = temp?.replace(' ', '') === ''
34
+ }
35
+
36
+ return retour
37
+ }
38
+
39
+ /**
40
+ * Pad un texte avec des caractères à gauche
41
+ * @param texte Texte à padder
42
+ * @param caractere Caractère à utiliser
43
+ * @param longueurFinale Longueur finale à atteindre
44
+ */
45
+ PadGauche(texte: string, caractere: string, longueurFinale: number) {
46
+ while (texte.length < longueurFinale) {
47
+ texte = caractere + texte
48
+ }
49
+ return texte
50
+ }
51
+
52
+ /**
53
+ * Pad un texte avec des caractères à droite
54
+ * @param texte Texte à padder
55
+ * @param caractere Caractère à utiliser
56
+ * @param longueurFinale Longueur finale à atteindre
57
+ */
58
+ PadDroit(texte: string, caractere: string, longueurFinale: number) {
59
+ while (texte.length < longueurFinale) {
60
+ texte += caractere
61
+ }
62
+ return texte
63
+ }
64
+
65
+ /**
66
+ * Transforme un nombre en string en arrondissant au nombre maximal de décimales.
67
+ * Ex : 14,57582 avec un affichage sur 2 décimales sera 15,58
68
+ * Si le nombre est 14,6 avec 2 décimales, le retour sera 14,6
69
+ * @param nombre Nombre à transformer en string
70
+ * @param nbDecimale Nombre maximal de décimales à afficher
71
+ */
72
+ DecimaleVariable(nombre: number, nbDecimale: number) {
73
+ let valeurRetour = 0
74
+ while (valeurRetour === 0 && nbDecimale > 0) {
75
+ const multiplicateur = 10 ** (nbDecimale - 1)
76
+ valeurRetour = (nombre * multiplicateur) % 1
77
+ if (valeurRetour === 0) {
78
+ nbDecimale -= 1
79
+ }
80
+ }
81
+ let retour = nombre.toFixed(nbDecimale)
82
+ // Retirer les derniers 0 ayant pu s'inscruster dû aux arrondissements.
83
+ while (retour.length > 1 && retour.lastIndexOf('0') === retour.length - 1) {
84
+ retour = retour.substring(0, retour.length - 1)
85
+ }
86
+ if (retour.lastIndexOf('.') === retour.length - 1) {
87
+ retour = retour.substring(0, retour.length - 1) // Retirer le point s'il termine le nombre
88
+ }
89
+ return retour.replace('.', ',')
90
+ }
91
+
92
+ /**
93
+ * Transforme un nombre en string en y mettant le nombre de décimale à afficher.
94
+ * @param nombre Nombre à transformer en string
95
+ * @param nbDecimale Nombre de décimales à afficher
96
+ */
97
+ DecimaleNonVariable(nombre: number, nbDecimale: number) {
98
+ return this.DecimaleVersString(nombre, nbDecimale, false).replace('.', ',')
99
+ }
100
+
101
+ /**
102
+ * Transforme un boolean en string avec la première lettre minuscule.
103
+ * @param bool Bool à mettre en string
104
+ */
105
+ BoolVersString(bool: boolean) {
106
+ if (bool === true) {
107
+ return 'true'
108
+ }
109
+ return 'false'
110
+ }
111
+
112
+ /**
113
+ * Transforme une string en nombre.
114
+ * @param texte string à mettre en number. Peut-être un entier ou une décimale avec virgule ou point
115
+ */
116
+ StringVersNombre(texte: string) {
117
+ texte = texte.replace(',', '.') // On remplace les virgules par des points.
118
+ return Number(texte)
119
+ }
120
+
121
+ /**
122
+ * Transforme une string en number avec des options pour le nombre de décimales.
123
+ * @param nombre Nombre à transformer
124
+ * @param nbDecimale Nombre de décimales à afficher au maximum
125
+ * @param afficherDecimaleVariable Si true, alors on affiche que les décimales nécessaires,
126
+ * jusqu'à nbDecimale. Ex : 4,2 et 4,25 Si False, nous auront 4,20 et 4,25
127
+ * @param separateur Séparateur à utiliser pour la décimale.
128
+ * La virgule ou le point. La virgule est utilisée par défaut.
129
+ */
130
+ DecimaleVersString(nombre: number, nbDecimale: number, afficherDecimaleVariable: boolean, separateur: string = ',') {
131
+ let retour = ''
132
+ if (afficherDecimaleVariable === true) {
133
+ retour = this.DecimaleVariable(nombre, nbDecimale)
134
+ } else {
135
+ retour = nombre.toFixed(nbDecimale)
136
+ }
137
+ retour.replace('.', separateur)
138
+ return retour
139
+ }
140
+
141
+ /**
142
+ * Transforme une décimale en formateur heure:minute. Ex : 2,5 => 2:30
143
+ * @param heures Nombre à mettre en string de type heure.
144
+ * @param separateur Séparateur heure, minute. Le : est utilisé par défaut.
145
+ */
146
+ DecimaleVersHeure(heures: number, separateur: string = ':') {
147
+ if (Math.round((heures % 1) * 60) < 10) {
148
+ return `${Math.floor(heures) + separateur}0${Math.round((heures % 1) * 60)}`
149
+ }
150
+ return Math.floor(heures) + separateur + Math.round((heures % 1) * 60)
151
+ }
152
+
153
+ /**
154
+ * Transforme différent type de fin de ligne comme des \n en <br />
155
+ * @param texte Texte à modifier et retourner
156
+ */
157
+ FinLigneVersBR(texte: string) {
158
+ return texte.replace(/(?:\r\n|\r|\n)/g, '<br />')
159
+ }
160
+
161
+ /**
162
+ * Transforme une date en string.
163
+ * Le principe est de séparer la string selon le séparateur et de créer une nouvelle date avec les 3 nombres que ça donne.
164
+ * @param dateStr Date en string
165
+ */
166
+ StringVersDate(dateStr: string, separateur = '-') {
167
+ const parties = dateStr.split(separateur)
168
+ if (parties.length < 3) {
169
+ throw new Error(`Conversion de date invalide. Format incorrect, attendu (yyyy-mm-dd), reçu : ${dateStr}`)
170
+ }
171
+ const retourDateTemp = new Date(
172
+ this.StringVersNombre(parties[0]),
173
+ this.StringVersNombre(parties[1]) - 1,
174
+ this.StringVersNombre(parties[2]),
175
+ 0,
176
+ 0,
177
+ 0,
178
+ 0,
179
+ ) // Les mois débutent le compte à 0.
180
+ return retourDateTemp
181
+ }
182
+
183
+ /**
184
+ * Transforme une date en string sous la forme YYYY-mm-dd
185
+ * @param date Date à mettre en string
186
+ */
187
+ DateVersString(date: Date) {
188
+ let month = `${date.getMonth() + 1}`
189
+ let day = `${date.getDate()}`
190
+ const year = date.getFullYear()
191
+ if (month.length < 2) {
192
+ month = `0${month}`
193
+ }
194
+ if (day.length < 2) {
195
+ day = `0${day}`
196
+ }
197
+ return [year, month, day].join('-')
198
+ }
199
+
200
+ /**
201
+ * Retourne la valeur numérique d'un nombre sous forme de string. Si le texte n'est pas un nombre NAN sera retourné.
202
+ * @param texte Texte à transformer en nombre
203
+ */
204
+ ValeurNumeriqueDepuisTexte(texte: string) {
205
+ return parseFloat(texte)
206
+ }
207
+
208
+ /**
209
+ * Fabriquer une nouvelle instance de l'objet à retournet et y assigne tous les attributs publiques de la source.
210
+ * Si un attribut n'existe pas dans la définition de la classe du type de retour, il sera quand même créé dynamiquement et aucune erreur ne sera soulevée
211
+ * Si le constructeur
212
+ * @param donneeBrut Objet de donnée brut source
213
+ */
214
+ FabriquerUnObjetAnonyme(source: object) {
215
+ return JSON.parse(JSON.stringify(source))
216
+ }
217
+
218
+ Cloner(objetAnonyme: object) {
219
+ return this.FabriquerUnObjetAnonyme(objetAnonyme)
220
+ }
221
+
222
+ /**
223
+ * Fabriquer une nouvelle instance de l'objet à retourner et lui assigne tous les attributs publiques de la source.
224
+ * Si un attribut n'existe pas dans la définition de la classe du type de retour, il sera quand même créé dynamiquement et aucune erreur ne sera soulevée
225
+ * @param source L'objet source
226
+ * @param destination L'objet destinataire
227
+ */
228
+ CopierObjetUnNiveau(source: any, destination: any) {
229
+ Object.keys(source).forEach(k => {
230
+ if (!Array.isArray(source[k])) {
231
+ destination[k] = source[k]
232
+ }
233
+ })
234
+
235
+ return destination
236
+ }
237
+
238
+ /**
239
+ * Bind les attributs d'un objet vers un autre. Les attributs de la source qui n'existe pas dans la destination seront créés automatiquement
240
+ * @param source Objet de donnée brut source
241
+ * @param destination Objet de donnée brut source
242
+ */
243
+ BinderDonnee(source: any, destination: any) {
244
+ if (destination == null) {
245
+ destination = {}
246
+ }
247
+
248
+ Object.keys(source).forEach(k => {
249
+ destination[k] = source[k]
250
+ })
251
+ return destination
252
+ }
253
+
254
+
255
+ SetThemeDark(valeur: any) {
256
+ localStorage.setItem(`${this.racineLocalStorage}ThemeDark`, valeur)
257
+ }
258
+
259
+ GetThemeDark() {
260
+ const valeur = localStorage.getItem(`${this.racineLocalStorage}ThemeDark`)
261
+
262
+ if (typeof valeur === 'string') {
263
+ if (valeur === 'true') {
264
+ return true
265
+ }
266
+
267
+ return false
268
+ }
269
+
270
+ return valeur
271
+ }
272
+
273
+ GetUrlBaseAPI() {
274
+ let baseUrl = window.location.origin
275
+ if (this.TexteVide(window.Location.prototype.pathname) === false) {
276
+ baseUrl += window.Location.prototype.pathname
277
+ }
278
+ baseUrl += '/api/'
279
+
280
+ return baseUrl
281
+ }
282
+
283
+ estDateAvantOuEgaleAujourdhui(date: string, comparerHeure: boolean) {
284
+ const now = new Date()
285
+ const dateDebut = new Date(this.StringVersDate(date))
286
+
287
+ if (comparerHeure === false) {
288
+ now.setHours(0, 0, 0, 0)
289
+ dateDebut.setHours(0, 0, 0, 0)
290
+ }
291
+
292
+ if (dateDebut <= now) {
293
+ return false
294
+ }
295
+
296
+ return true
297
+ }
298
+
299
+ estDateAvantAujourdhui(date: string, comparerHeure: boolean) {
300
+ const now = new Date()
301
+ const dateDebut = new Date(this.StringVersDate(date))
302
+
303
+ if (comparerHeure === false) {
304
+ now.setHours(0, 0, 0, 0)
305
+ dateDebut.setHours(0, 0, 0, 0)
306
+ }
307
+
308
+ if (dateDebut < now) {
309
+ return false
310
+ }
311
+
312
+ return true
313
+ }
314
+
315
+ estDateApresOuEgaleAujourdhui(date: string, comparerHeure: boolean) {
316
+ const now = new Date()
317
+ const dateDebut = new Date(this.StringVersDate(date))
318
+
319
+ if (comparerHeure === false) {
320
+ now.setHours(0, 0, 0, 0)
321
+ dateDebut.setHours(0, 0, 0, 0)
322
+ }
323
+
324
+ if (dateDebut >= now) {
325
+ return false
326
+ }
327
+
328
+ return true
329
+ }
330
+
331
+ estDateApresAujourdhui(date: string, comparerHeure: boolean) {
332
+ const now = new Date()
333
+ const dateDebut = new Date(this.StringVersDate(date))
334
+
335
+ if (comparerHeure === false) {
336
+ now.setHours(0, 0, 0, 0)
337
+ dateDebut.setHours(0, 0, 0, 0)
338
+ }
339
+
340
+ if (dateDebut > now) {
341
+ return false
342
+ }
343
+
344
+ return true
345
+ }
346
+
347
+ /**
348
+ * Converti un enum en objet clé-valeur pour usage dans la prop :items d'un v-select.
349
+ * @param _obj L'enum pour générer les clés-valeurs
350
+ * @returns Une liste d'objets du format { title: string, value: number }
351
+ */
352
+ genererItemsAPartirDeEnum<T extends object>(_enum: T) {
353
+ const enumKeys = Object.keys(_enum).filter(e => isNaN(Number(e)))
354
+ const enumValues = Object.keys(_enum).filter(e => !isNaN(Number(e))).map(e => Number(e))
355
+
356
+ const ret: { title?: string, value: number}[] = []
357
+
358
+ enumValues.forEach(v => ret.push({ title: enumKeys[v], value: v}))
359
+
360
+ return ret;
361
+ }
362
+ }
363
+
364
+ const csqcOutils = new CSQCOutils()
365
+
366
+ export default csqcOutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codevdesign",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Composants Vuetify 3 pour les projets Codev",
5
5
  "files": [
6
6
  "./**/*.vue",