Compare commits
2 Commits
635b8f0461
...
v1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79d2df8bc6 | ||
|
|
23da4ba4c7 |
@@ -6,26 +6,31 @@
|
|||||||
prefersdark: false; /* set as default dark mode (prefers-color-scheme:dark) */
|
prefersdark: false; /* set as default dark mode (prefers-color-scheme:dark) */
|
||||||
color-scheme: light; /* color of browser-provided UI */
|
color-scheme: light; /* color of browser-provided UI */
|
||||||
|
|
||||||
--color-base-100: oklch(98% 0.02 240);
|
/* #FBFAFA — gris clair */
|
||||||
--color-base-200: oklch(95% 0.03 240);
|
--color-base-100: oklch(98% 0.003 0);
|
||||||
--color-base-300: oklch(92% 0.04 240);
|
--color-base-200: oklch(94% 0.01 262);
|
||||||
--color-base-content: oklch(20% 0.05 240);
|
--color-base-300: oklch(90% 0.02 262);
|
||||||
--color-primary: oklch(55% 0.3 240);
|
--color-base-content: oklch(20% 0.03 262);
|
||||||
--color-primary-content: oklch(98% 0.01 240);
|
/* #304998 — bleu Malio */
|
||||||
--color-secondary: oklch(70% 0.25 200);
|
--color-primary: oklch(37% 0.15 262);
|
||||||
--color-secondary-content: oklch(98% 0.01 200);
|
--color-primary-content: oklch(98% 0.005 262);
|
||||||
--color-accent: oklch(65% 0.25 160);
|
/* #A5ACD0 — lavande */
|
||||||
--color-accent-content: oklch(98% 0.01 160);
|
--color-secondary: oklch(75% 0.055 270);
|
||||||
--color-neutral: oklch(50% 0.05 240);
|
--color-secondary-content: oklch(20% 0.03 270);
|
||||||
--color-neutral-content: oklch(98% 0.01 240);
|
/* #ED8521 — orange */
|
||||||
--color-info: oklch(70% 0.2 220);
|
--color-accent: oklch(71% 0.17 58);
|
||||||
--color-info-content: oklch(98% 0.01 220);
|
--color-accent-content: oklch(98% 0.005 58);
|
||||||
--color-success: oklch(65% 0.25 140);
|
/* neutral dérivé du bleu Malio */
|
||||||
--color-success-content: oklch(98% 0.01 140);
|
--color-neutral: oklch(37% 0.08 262);
|
||||||
--color-warning: oklch(80% 0.25 80);
|
--color-neutral-content: oklch(98% 0.005 262);
|
||||||
--color-warning-content: oklch(20% 0.05 80);
|
--color-info: oklch(55% 0.12 262);
|
||||||
--color-error: oklch(65% 0.3 30);
|
--color-info-content: oklch(98% 0.005 262);
|
||||||
--color-error-content: oklch(98% 0.01 30);
|
--color-success: oklch(65% 0.2 145);
|
||||||
|
--color-success-content: oklch(98% 0.005 145);
|
||||||
|
--color-warning: oklch(78% 0.15 70);
|
||||||
|
--color-warning-content: oklch(20% 0.05 70);
|
||||||
|
--color-error: oklch(60% 0.25 25);
|
||||||
|
--color-error-content: oklch(98% 0.005 25);
|
||||||
|
|
||||||
/* border radius */
|
/* border radius */
|
||||||
--radius-selector: 1rem;
|
--radius-selector: 1rem;
|
||||||
@@ -114,7 +119,7 @@
|
|||||||
|
|
||||||
/* Focus visible pour l'accessibilité */
|
/* Focus visible pour l'accessibilité */
|
||||||
*:focus-visible {
|
*:focus-visible {
|
||||||
outline: 2px solid #3b82f6;
|
outline: 2px solid #304998;
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ interface LoadComposantsOptions {
|
|||||||
itemsPerPage?: number
|
itemsPerPage?: number
|
||||||
orderBy?: string
|
orderBy?: string
|
||||||
orderDir?: 'asc' | 'desc'
|
orderDir?: 'asc' | 'desc'
|
||||||
|
force?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const composants = ref<Composant[]>([])
|
const composants = ref<Composant[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const loaded = ref(false)
|
||||||
|
|
||||||
const extractTotal = (payload: unknown, fallbackLength: number): number => {
|
const extractTotal = (payload: unknown, fallbackLength: number): number => {
|
||||||
const p = payload as Record<string, unknown> | null
|
const p = payload as Record<string, unknown> | null
|
||||||
@@ -98,16 +100,32 @@ export function useComposants() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loadComposants = async (options: LoadComposantsOptions = {}): Promise<ComposantListResult> => {
|
const loadComposants = async (options: LoadComposantsOptions = {}): Promise<ComposantListResult> => {
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const {
|
const {
|
||||||
search = '',
|
search = '',
|
||||||
page = 1,
|
page = 1,
|
||||||
itemsPerPage = 30,
|
itemsPerPage = 30,
|
||||||
orderBy = 'name',
|
orderBy = 'name',
|
||||||
orderDir = 'asc',
|
orderDir = 'asc',
|
||||||
|
force = false,
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
|
if (!force && loaded.value && !search && page === 1) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: { items: composants.value, total: total.value, page, itemsPerPage },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading.value) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: { items: composants.value, total: total.value, page, itemsPerPage },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
params.set('itemsPerPage', String(itemsPerPage))
|
params.set('itemsPerPage', String(itemsPerPage))
|
||||||
params.set('page', String(page))
|
params.set('page', String(page))
|
||||||
@@ -124,6 +142,7 @@ export function useComposants() {
|
|||||||
const enrichedItems = await Promise.all(items.map((item) => withResolvedConstructeurs(item)))
|
const enrichedItems = await Promise.all(items.map((item) => withResolvedConstructeurs(item)))
|
||||||
composants.value = enrichedItems
|
composants.value = enrichedItems
|
||||||
total.value = extractTotal(result.data, items.length)
|
total.value = extractTotal(result.data, items.length)
|
||||||
|
loaded.value = true
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
@@ -216,15 +235,23 @@ export function useComposants() {
|
|||||||
const getComposants = () => composants.value
|
const getComposants = () => composants.value
|
||||||
const isLoading = () => loading.value
|
const isLoading = () => loading.value
|
||||||
|
|
||||||
|
const clearComposantsCache = () => {
|
||||||
|
composants.value = []
|
||||||
|
total.value = 0
|
||||||
|
loaded.value = false
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
composants,
|
composants,
|
||||||
total,
|
total,
|
||||||
loading,
|
loading,
|
||||||
|
loaded,
|
||||||
loadComposants,
|
loadComposants,
|
||||||
createComposant,
|
createComposant,
|
||||||
updateComposant: updateComposantData,
|
updateComposant: updateComposantData,
|
||||||
deleteComposant,
|
deleteComposant,
|
||||||
getComposants,
|
getComposants,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
clearComposantsCache,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ interface LoadPiecesOptions {
|
|||||||
itemsPerPage?: number
|
itemsPerPage?: number
|
||||||
orderBy?: string
|
orderBy?: string
|
||||||
orderDir?: 'asc' | 'desc'
|
orderDir?: 'asc' | 'desc'
|
||||||
|
force?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const pieces = ref<Piece[]>([])
|
const pieces = ref<Piece[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const loaded = ref(false)
|
||||||
|
|
||||||
const extractTotal = (payload: unknown, fallbackLength: number): number => {
|
const extractTotal = (payload: unknown, fallbackLength: number): number => {
|
||||||
const p = payload as Record<string, unknown> | null
|
const p = payload as Record<string, unknown> | null
|
||||||
@@ -108,16 +110,32 @@ export function usePieces() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loadPieces = async (options: LoadPiecesOptions = {}): Promise<PieceListResult> => {
|
const loadPieces = async (options: LoadPiecesOptions = {}): Promise<PieceListResult> => {
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const {
|
const {
|
||||||
search = '',
|
search = '',
|
||||||
page = 1,
|
page = 1,
|
||||||
itemsPerPage = 30,
|
itemsPerPage = 30,
|
||||||
orderBy = 'name',
|
orderBy = 'name',
|
||||||
orderDir = 'asc',
|
orderDir = 'asc',
|
||||||
|
force = false,
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
|
if (!force && loaded.value && !search && page === 1) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: { items: pieces.value, total: total.value, page, itemsPerPage },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading.value) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: { items: pieces.value, total: total.value, page, itemsPerPage },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
params.set('itemsPerPage', String(itemsPerPage))
|
params.set('itemsPerPage', String(itemsPerPage))
|
||||||
params.set('page', String(page))
|
params.set('page', String(page))
|
||||||
@@ -134,6 +152,7 @@ export function usePieces() {
|
|||||||
const enrichedItems = await Promise.all(items.map((item) => withResolvedConstructeurs(item)))
|
const enrichedItems = await Promise.all(items.map((item) => withResolvedConstructeurs(item)))
|
||||||
pieces.value = enrichedItems
|
pieces.value = enrichedItems
|
||||||
total.value = extractTotal(result.data, items.length)
|
total.value = extractTotal(result.data, items.length)
|
||||||
|
loaded.value = true
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
@@ -226,15 +245,23 @@ export function usePieces() {
|
|||||||
const getPieces = () => pieces.value
|
const getPieces = () => pieces.value
|
||||||
const isLoading = () => loading.value
|
const isLoading = () => loading.value
|
||||||
|
|
||||||
|
const clearPiecesCache = () => {
|
||||||
|
pieces.value = []
|
||||||
|
total.value = 0
|
||||||
|
loaded.value = false
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pieces,
|
pieces,
|
||||||
total,
|
total,
|
||||||
loading,
|
loading,
|
||||||
|
loaded,
|
||||||
loadPieces,
|
loadPieces,
|
||||||
createPiece,
|
createPiece,
|
||||||
updatePiece: updatePieceData,
|
updatePiece: updatePieceData,
|
||||||
deletePiece,
|
deletePiece,
|
||||||
getPieces,
|
getPieces,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
clearPiecesCache,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user