codevdesign 1.0.9 → 1.0.11
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 +363 -363
- package/composants/csqcRechercheUtilisateur.vue +197 -197
- package/composants/csqcTable/csqcTableModaleChoixColonnes.vue +586 -586
- package/index.ts +73 -74
- package/outils/appAxios.ts +116 -116
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1,74 +1,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
|
-
//
|
|
34
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
import
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
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
|
+
}
|
package/outils/appAxios.ts
CHANGED
|
@@ -1,116 +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
|
-
}
|
|
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
|
+
}
|