refacto(tables) : composant DataTable global + migration de toutes les tables

- Nouveau composant DataTable réutilisable avec tri par en-têtes, pagination, filtres colonnes
- Nouveau composable useDataTable (sort/page/search/perPage/columnFilters + persistance URL)
- Migration des 9 tables : constructeurs, comments, admin, pieces-catalog, component-catalog, product-catalog, documents, activity-log, ManagementView (catégories)
- Filtres "Type de" server-side (ipartial) pour pièces, composants, produits

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-04 16:05:00 +01:00
parent 89dc2e93b8
commit 6f1bac381d
16 changed files with 1945 additions and 1943 deletions

View File

@@ -0,0 +1,46 @@
export type SortDirection = 'asc' | 'desc'
export interface DataTableColumn {
/** Unique key — used as slot name prefix (`#cell-{key}`) and default data accessor (`row[key]`) */
key: string
/** Display label for the column header */
label: string
/** Whether clicking this column header triggers sorting. Default: false */
sortable?: boolean
/** Sort key sent to the API (may differ from `key`). Falls back to `key` if omitted. */
sortKey?: string
/** CSS class applied to both <th> and <td> */
class?: string
/** CSS class applied only to <th> */
headerClass?: string
/** Width hint (e.g. 'w-24', 'min-w-[10rem]') */
width?: string
/** Text alignment: 'left' (default), 'center', 'right' */
align?: 'left' | 'center' | 'right'
/** Hide on mobile (adds 'hidden sm:table-cell') */
hiddenMobile?: boolean
/** Whether this column has a filter input under the header */
filterable?: boolean
/** Placeholder for the filter input */
filterPlaceholder?: string
}
export type DataTableColumnFilters = Record<string, string>
export interface DataTableSort {
field: string
direction: SortDirection
}
export interface DataTablePagination {
currentPage: number
totalPages: number
/** Total items matching current filters */
totalItems: number
/** Items displayed on current page */
pageItems: number
/** Available per-page options. If omitted, per-page selector is hidden. */
perPageOptions?: number[]
/** Currently selected items per page */
perPage?: number
}