codevdesign 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,131 +1,131 @@
1
- <template>
2
- <v-toolbar
3
- color="primary"
4
- height="72px"
5
- elevation="1"
6
- >
7
- <v-row
8
- class="pl-6 pr-6"
9
- align="center"
10
- no-gutters
11
- >
12
- <!-- Première colonne : Logo -->
13
- <v-col cols="auto">
14
- <a href="/">
15
- <img
16
- v-if="texteVide(logoUrl)"
17
- id="pivImage"
18
- src="/images/QUEBEC_blanc.svg"
19
- height="72"
20
- :alt="$t('csqc.pivFooter.logoAlt')"
21
- />
22
- <img
23
- v-else
24
- id="pivImage"
25
- :src="logoUrl"
26
- height="72"
27
- :alt="$t('csqc.pivFooter.logoAlt')"
28
- />
29
- </a>
30
- </v-col>
31
-
32
- <!-- Colonne pour le nom de l'application (Pour le mode desktop) -->
33
- <v-col
34
- v-if="!estMobile"
35
- class="d-flex justify-center"
36
- >
37
- <v-app-bar-title
38
- class="pl-12 ml-12"
39
- style="font-size: 16px !important"
40
- >
41
- {{ $t('nom_application') }}
42
- </v-app-bar-title>
43
- </v-col>
44
-
45
- <!-- Colonne pour le bouton de langue et icône d'aide -->
46
- <v-col class="d-none d-flex justify-end">
47
- <!-- langue -->
48
- <v-btn
49
- variant="text"
50
- @click="enregistrerLangue()"
51
- >{{ $t('csqc.pivEntete.langue') }}
52
- </v-btn>
53
-
54
- <!-- icône d'aide si dispo -->
55
- <v-btn
56
- v-if="aideUrl"
57
- icon="mdi-help-circle-outline"
58
- :href="aideUrl"
59
- target="_blank"
60
- rel="noopener noreferrer"
61
- style="margin-top: -6px"
62
- >
63
- </v-btn>
64
- </v-col>
65
-
66
- <!-- Colonne pour le nom de l'application (Pour le mode mobile) -->
67
- <v-col
68
- v-if="props.estMobile"
69
- cols="12"
70
- >
71
- <v-app-bar-title style="font-size: 16px !important">
72
- {{ $t('nom_application') }}
73
- </v-app-bar-title>
74
- </v-col>
75
- </v-row>
76
- </v-toolbar>
77
- </template>
78
-
79
- <script setup lang="ts">
80
- import { useLocale } from 'vuetify'
81
-
82
- const { current } = useLocale()
83
- const texteVide = (texte: string | undefined, retirerEspace: boolean = true): boolean => {
84
- let retour = texte === undefined || texte === null || texte === ''
85
-
86
- if (!retour && retirerEspace) {
87
- const temp = texte
88
- retour = temp!.replace(' ', '') === ''
89
- }
90
-
91
- return retour
92
- }
93
- const props = defineProps({
94
- estMobile: {
95
- type: Boolean,
96
- required: true,
97
- },
98
- urlBase: {
99
- type: String,
100
- required: true,
101
- },
102
- aideUrl: { type: String, default: '' },
103
- logoUrl: {
104
- type: String,
105
- default: '',
106
- },
107
- })
108
- const emit = defineEmits(['changementLangue'])
109
- // Fonction pour enregistrer la langue
110
-
111
- const enregistrerLangue = (): void => {
112
- const langueDispo: string = current.value === 'fr' ? 'en' : 'fr'
113
- let returnUrl = window.location.pathname + window.location.search
114
- if (import.meta.env.MODE === 'development') {
115
- returnUrl = '/'
116
- }
117
- window.location.href =
118
- props.urlBase + `/Traducteur/SetLanguage?culture=${langueDispo}&returnUrl=${encodeURIComponent(returnUrl)}`
119
- emit('changementLangue')
120
- }
121
- </script>
122
-
123
- <style scoped>
124
- .container {
125
- max-width: none !important;
126
- }
127
- .theme--light.v-app-bar.v-toolbar.v-sheet {
128
- background: #095797;
129
- color: #fff;
130
- }
131
- </style>
1
+ <template>
2
+ <v-toolbar
3
+ color="primary"
4
+ height="72px"
5
+ elevation="1"
6
+ >
7
+ <v-row
8
+ class="pl-6 pr-6"
9
+ align="center"
10
+ no-gutters
11
+ >
12
+ <!-- Première colonne : Logo -->
13
+ <v-col cols="auto">
14
+ <a href="/">
15
+ <img
16
+ v-if="texteVide(logoUrl)"
17
+ id="pivImage"
18
+ src="/images/QUEBEC_blanc.svg"
19
+ height="72"
20
+ :alt="$t('csqc.pivFooter.logoAlt')"
21
+ />
22
+ <img
23
+ v-else
24
+ id="pivImage"
25
+ :src="logoUrl"
26
+ height="72"
27
+ :alt="$t('csqc.pivFooter.logoAlt')"
28
+ />
29
+ </a>
30
+ </v-col>
31
+
32
+ <!-- Colonne pour le nom de l'application (Pour le mode desktop) -->
33
+ <v-col
34
+ v-if="!estMobile"
35
+ class="d-flex justify-center"
36
+ >
37
+ <v-app-bar-title
38
+ class="pl-12 ml-12"
39
+ style="font-size: 16px !important"
40
+ >
41
+ {{ $t('nom_application') }}
42
+ </v-app-bar-title>
43
+ </v-col>
44
+
45
+ <!-- Colonne pour le bouton de langue et icône d'aide -->
46
+ <v-col class="d-none d-flex justify-end">
47
+ <!-- langue -->
48
+ <v-btn
49
+ variant="text"
50
+ @click="enregistrerLangue()"
51
+ >{{ $t('csqc.pivEntete.langue') }}
52
+ </v-btn>
53
+
54
+ <!-- icône d'aide si dispo -->
55
+ <v-btn
56
+ v-if="aideUrl"
57
+ icon="mdi-help-circle-outline"
58
+ :href="aideUrl"
59
+ target="_blank"
60
+ rel="noopener noreferrer"
61
+ style="margin-top: -6px"
62
+ >
63
+ </v-btn>
64
+ </v-col>
65
+
66
+ <!-- Colonne pour le nom de l'application (Pour le mode mobile) -->
67
+ <v-col
68
+ v-if="props.estMobile"
69
+ cols="12"
70
+ >
71
+ <v-app-bar-title style="font-size: 16px !important">
72
+ {{ $t('nom_application') }}
73
+ </v-app-bar-title>
74
+ </v-col>
75
+ </v-row>
76
+ </v-toolbar>
77
+ </template>
78
+
79
+ <script setup lang="ts">
80
+ import { useLocale } from 'vuetify'
81
+
82
+ const { current } = useLocale()
83
+ const texteVide = (texte: string | undefined, retirerEspace: boolean = true): boolean => {
84
+ let retour = texte === undefined || texte === null || texte === ''
85
+
86
+ if (!retour && retirerEspace) {
87
+ const temp = texte
88
+ retour = temp!.replace(' ', '') === ''
89
+ }
90
+
91
+ return retour
92
+ }
93
+ const props = defineProps({
94
+ estMobile: {
95
+ type: Boolean,
96
+ required: true,
97
+ },
98
+ urlBase: {
99
+ type: String,
100
+ required: true,
101
+ },
102
+ aideUrl: { type: String, default: '' },
103
+ logoUrl: {
104
+ type: String,
105
+ default: '',
106
+ },
107
+ })
108
+ const emit = defineEmits(['changementLangue'])
109
+ // Fonction pour enregistrer la langue
110
+
111
+ const enregistrerLangue = (): void => {
112
+ const langueDispo: string = current.value === 'fr' ? 'en' : 'fr'
113
+ let returnUrl = window.location.pathname + window.location.search
114
+ if (import.meta.env.MODE === 'development') {
115
+ returnUrl = '/'
116
+ }
117
+ window.location.href =
118
+ props.urlBase + `/Traducteur/SetLanguage?culture=${langueDispo}&returnUrl=${encodeURIComponent(returnUrl)}`
119
+ emit('changementLangue')
120
+ }
121
+ </script>
122
+
123
+ <style scoped>
124
+ .container {
125
+ max-width: none !important;
126
+ }
127
+ .theme--light.v-app-bar.v-toolbar.v-sheet {
128
+ background: #095797;
129
+ color: #fff;
130
+ }
131
+ </style>
package/index.ts CHANGED
@@ -8,6 +8,7 @@ import pivEntete from './composants/gabarit/pivEntete.vue'
8
8
  import pivFooter from './composants/gabarit/pivPiedPage.vue'
9
9
  import csqcMenu from './composants/gabarit/csqcMenu.vue'
10
10
  import csqcConfirmation from './composants/csqcConfirmation.vue'
11
+ import csqcSaisie from './composants/csqcModaleSaisie.vue'
11
12
  import csqcDate from './composants/csqcDate.vue'
12
13
  import csqcTable from './composants/csqcTable/csqcTable.vue'
13
14
  import csqcCodeBudgetaire from './composants/csqcCodeBudgetaireGenerique.vue'
@@ -43,6 +44,7 @@ export {
43
44
  csqcAlerteErreur,
44
45
  csqcDialogue,
45
46
  csqcConfirmation,
47
+ csqcSaisie,
46
48
  csqcDate,
47
49
  csqcOptionSwitch,
48
50
  csqcRecherche,
@@ -68,5 +70,5 @@ export {
68
70
  response,
69
71
  NotificationGabaritDefaut,
70
72
  csqcAppAxios,
71
- csqcRafraichisseurToken
73
+ csqcRafraichisseurToken,
72
74
  }
@@ -1,18 +1,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
- }
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
+ }
@@ -1,31 +1,31 @@
1
- import type { DataTableCompareFunction, DataTableHeader, FilterFunction } from 'vuetify'
2
- import { HeaderCellProps } from 'vuetify/lib/components/VDataTable/types.mjs';
3
- import { SelectItemKey } from 'vuetify/lib/util/helpers.mjs';
4
-
5
- class datatableColonne<T = any> implements DataTableHeader<T> {
6
- key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {});
7
- value?: SelectItemKey<T>;
8
- title?: string;
9
- fixed?: boolean | 'start' | 'end';
10
- align?: 'start' | 'end' | 'center';
11
- width?: number | string;
12
- minWidth?: number | string;
13
- maxWidth?: number | string;
14
- nowrap?: boolean;
15
- intent?: number;
16
- headerProps?: Record<string, any>;
17
- cellProps?: HeaderCellProps;
18
- sortable?: boolean;
19
- sort?: DataTableCompareFunction;
20
- sortRaw?: DataTableCompareFunction;
21
- filter?: FilterFunction;
22
- children?: DataTableHeader<T>[];
23
-
24
- constructor(title: string, key: string) {
25
- this.title = title
26
- this.key = key
27
- this.align = key === 'action' ? 'end' : key === 'estActif' ? 'center' : 'start'
28
- this.sortable = key !== 'action'
29
- }
30
- }
31
- export default datatableColonne
1
+ import type { DataTableCompareFunction, DataTableHeader, FilterFunction } from 'vuetify'
2
+ import { HeaderCellProps } from 'vuetify/lib/components/VDataTable/types.mjs';
3
+ import { SelectItemKey } from 'vuetify/lib/util/helpers.mjs';
4
+
5
+ class datatableColonne<T = any> implements DataTableHeader<T> {
6
+ key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {});
7
+ value?: SelectItemKey<T>;
8
+ title?: string;
9
+ fixed?: boolean | 'start' | 'end';
10
+ align?: 'start' | 'end' | 'center';
11
+ width?: number | string;
12
+ minWidth?: number | string;
13
+ maxWidth?: number | string;
14
+ nowrap?: boolean;
15
+ intent?: number;
16
+ headerProps?: Record<string, any>;
17
+ cellProps?: HeaderCellProps;
18
+ sortable?: boolean;
19
+ sort?: DataTableCompareFunction;
20
+ sortRaw?: DataTableCompareFunction;
21
+ filter?: FilterFunction;
22
+ children?: DataTableHeader<T>[];
23
+
24
+ constructor(title: string, key: string) {
25
+ this.title = title
26
+ this.key = key
27
+ this.align = key === 'action' ? 'end' : key === 'estActif' ? 'center' : 'start'
28
+ this.sortable = key !== 'action'
29
+ }
30
+ }
31
+ export default datatableColonne
@@ -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
+ }