From 201485552af376493ba2817780b0f92f7e793325 Mon Sep 17 00:00:00 2001 From: r-dev Date: Mon, 6 Apr 2026 11:19:50 +0200 Subject: [PATCH] fix(ui) : remove legacy edit pages and history composables, unify create/edit forms Consolidate create and edit pages into single create pages with edit mode support. Remove obsolete catalog pages, history composables, and fix remaining code review issues. Include migration to relink orphaned custom fields. Co-Authored-By: Claude Opus 4.6 (1M context) --- fixtures/data.sql | 52 +- .../app/components/layout/AppBreadcrumb.vue | 6 +- frontend/app/components/layout/AppNavbar.vue | 4 +- frontend/app/composables/useComponentEdit.ts | 4 +- .../app/composables/useComponentHistory.ts | 12 - frontend/app/composables/useComposants.ts | 13 +- frontend/app/composables/useDocuments.ts | 9 +- frontend/app/composables/usePieceEdit.ts | 4 +- frontend/app/composables/usePieceHistory.ts | 12 - frontend/app/composables/usePieces.ts | 13 +- frontend/app/composables/useProductHistory.ts | 12 - frontend/app/composables/useProducts.ts | 13 +- frontend/app/pages/catalogues/composants.vue | 16 +- frontend/app/pages/catalogues/pieces.vue | 11 +- frontend/app/pages/catalogues/produits.vue | 11 +- frontend/app/pages/component-catalog.vue | 212 ------- frontend/app/pages/component/[id]/edit.vue | 452 -------------- frontend/app/pages/component/create.vue | 432 ++++++++------ frontend/app/pages/machine/[id].vue | 16 +- frontend/app/pages/pieces-catalog.vue | 245 -------- frontend/app/pages/pieces/[id]/edit.vue | 357 ----------- frontend/app/pages/pieces/create.vue | 416 +++++++------ frontend/app/pages/product-catalog.vue | 257 -------- frontend/app/pages/product/[id]/edit.vue | 563 ------------------ frontend/app/pages/product/[id]/index.vue | 4 +- frontend/app/pages/product/create.vue | 312 +++++----- frontend/app/shared/utils/apiHelpers.ts | 7 + frontend/app/shared/utils/customFields.ts | 2 + ...ion20260404_RelinkOrphanedCustomFields.php | 156 +++++ 29 files changed, 875 insertions(+), 2748 deletions(-) delete mode 100644 frontend/app/composables/useComponentHistory.ts delete mode 100644 frontend/app/composables/usePieceHistory.ts delete mode 100644 frontend/app/composables/useProductHistory.ts delete mode 100644 frontend/app/pages/component-catalog.vue delete mode 100644 frontend/app/pages/component/[id]/edit.vue delete mode 100644 frontend/app/pages/pieces-catalog.vue delete mode 100644 frontend/app/pages/pieces/[id]/edit.vue delete mode 100644 frontend/app/pages/product-catalog.vue delete mode 100644 frontend/app/pages/product/[id]/edit.vue create mode 100644 migrations/Version20260404_RelinkOrphanedCustomFields.php diff --git a/fixtures/data.sql b/fixtures/data.sql index 004aab2..b9633e6 100644 --- a/fixtures/data.sql +++ b/fixtures/data.sql @@ -422,16 +422,16 @@ INSERT INTO public.constructeurs (id, name, email, phone, createdat, updatedat) -- --- Data for Name: _composantconstructeurs; Type: TABLE DATA; Schema: public; Owner: - +-- Data for Name: composant_constructeur_links; Type: TABLE DATA; Schema: public; Owner: - -- -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmgz7fd3l009y47fff1l4g0p0', 'cmgqp5dvp00014705qpkci8qc'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmh3jvqoa002y47zbctflkydc', 'cmhnaaoam000847s85wfwi2wm'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmh0d59v5000347s561ahbept', 'cmhnaaoam000847s85wfwi2wm'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmh0d59v5000347s561ahbept', 'cmg93n9sk000047uuwm6u20mj'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmkqps2h8001q1eq6k2uxopfo', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cmkqyn2jm002m1eq6ws83lgwx', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._composantconstructeurs (a, b) VALUES ('cl9b1583768c7c9fe6cfe93a11', 'cmkqpnznr001p1eq6hdh2ept8'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000001', 'cmgz7fd3l009y47fff1l4g0p0', 'cmgqp5dvp00014705qpkci8qc', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000002', 'cmh3jvqoa002y47zbctflkydc', 'cmhnaaoam000847s85wfwi2wm', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000003', 'cmh0d59v5000347s561ahbept', 'cmhnaaoam000847s85wfwi2wm', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000004', 'cmh0d59v5000347s561ahbept', 'cmg93n9sk000047uuwm6u20mj', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000005', 'cmkqps2h8001q1eq6k2uxopfo', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000006', 'cmkqyn2jm002m1eq6ws83lgwx', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.composant_constructeur_links (id, composantid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixcc0000000000000000007', 'cl9b1583768c7c9fe6cfe93a11', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); -- @@ -461,7 +461,7 @@ INSERT INTO public.machines (id, name, reference, prix, createdat, updatedat, si -- --- Data for Name: _machineconstructeurs; Type: TABLE DATA; Schema: public; Owner: - +-- Data for Name: machine_constructeur_links; Type: TABLE DATA; Schema: public; Owner: - -- @@ -588,25 +588,25 @@ INSERT INTO public.pieces (id, name, reference, prix, createdat, updatedat, type -- --- Data for Name: _piececonstructeurs; Type: TABLE DATA; Schema: public; Owner: - +-- Data for Name: piece_constructeur_links; Type: TABLE DATA; Schema: public; Owner: - -- -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmizudzfy00021e2w2mtd9zv8', 'cmizu5ugx00011e2wjpr6nb3k'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmizv8nzu00081e2wen6ur31b', 'cmizv4lm500071e2w6xymi2p6'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmjcixqq300141e2wqkvz0cx6', 'cmjcirqnh00101e2w0ht25qic'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmjcixqq300141e2wqkvz0cx6', 'cmjcismo400111e2whfxnsnd3'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmjcixqq300141e2wqkvz0cx6', 'cmjciuk3t00121e2wxtz9o5fh'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmjcixqq300141e2wqkvz0cx6', 'cmjcivgex00131e2wf04n31ql'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmjcpdwqs00161e2wu4juy4u2', 'cmjcirqnh00101e2w0ht25qic'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmkqzl1oa002v1eq6erkt5544', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmkr0nq1a004e1eq6v6ubxlfl', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmkr20cpy005a1eq6nn5kmtys', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cmkr25xz1005v1eq6i0fib4er', 'cmkqpnznr001p1eq6hdh2ept8'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cl89d9641d47f52c5385f83d5c', 'cmg93n9sk000047uuwm6u20mj'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cl89d9641d47f52c5385f83d5c', 'cmg93n9te000547uuond39s1c'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cl89d9641d47f52c5385f83d5c', 'cmg93n9tb000447uuuddgakar'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cl89d9641d47f52c5385f83d5c', 'cmhaac3vo003547v7s1wv6jhv'); -INSERT INTO public._piececonstructeurs (a, b) VALUES ('cl89d9641d47f52c5385f83d5c', 'cmg93n9tm000647uu6em8thyq'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000001', 'cmizudzfy00021e2w2mtd9zv8', 'cmizu5ugx00011e2wjpr6nb3k', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000002', 'cmizv8nzu00081e2wen6ur31b', 'cmizv4lm500071e2w6xymi2p6', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000003', 'cmjcixqq300141e2wqkvz0cx6', 'cmjcirqnh00101e2w0ht25qic', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000004', 'cmjcixqq300141e2wqkvz0cx6', 'cmjcismo400111e2whfxnsnd3', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000005', 'cmjcixqq300141e2wqkvz0cx6', 'cmjciuk3t00121e2wxtz9o5fh', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000006', 'cmjcixqq300141e2wqkvz0cx6', 'cmjcivgex00131e2wf04n31ql', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000007', 'cmjcpdwqs00161e2wu4juy4u2', 'cmjcirqnh00101e2w0ht25qic', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000008', 'cmkqzl1oa002v1eq6erkt5544', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000009', 'cmkr0nq1a004e1eq6v6ubxlfl', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000010', 'cmkr20cpy005a1eq6nn5kmtys', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000011', 'cmkr25xz1005v1eq6i0fib4er', 'cmkqpnznr001p1eq6hdh2ept8', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000012', 'cl89d9641d47f52c5385f83d5c', 'cmg93n9sk000047uuwm6u20mj', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000013', 'cl89d9641d47f52c5385f83d5c', 'cmg93n9te000547uuond39s1c', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000014', 'cl89d9641d47f52c5385f83d5c', 'cmg93n9tb000447uuuddgakar', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000015', 'cl89d9641d47f52c5385f83d5c', 'cmhaac3vo003547v7s1wv6jhv', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); +INSERT INTO public.piece_constructeur_links (id, pieceid, constructeurid, supplierreference, createdat, updatedat) VALUES ('clfixpc0000000000000000016', 'cl89d9641d47f52c5385f83d5c', 'cmg93n9tm000647uu6em8thyq', NULL, '2026-01-01 00:00:00', '2026-01-01 00:00:00'); -- diff --git a/frontend/app/components/layout/AppBreadcrumb.vue b/frontend/app/components/layout/AppBreadcrumb.vue index 255182d..bc31c72 100644 --- a/frontend/app/components/layout/AppBreadcrumb.vue +++ b/frontend/app/components/layout/AppBreadcrumb.vue @@ -61,11 +61,11 @@ const crumbs = computed(() => { } // Catalogs - else if (path.startsWith('/catalogues/composants') || path === '/component-catalog') { + else if (path.startsWith('/catalogues/composants')) { result.push({ label: 'Composants', path: '/catalogues/composants' }) - } else if (path.startsWith('/catalogues/pieces') || path === '/pieces-catalog') { + } else if (path.startsWith('/catalogues/pieces')) { result.push({ label: 'Pièces', path: '/catalogues/pieces' }) - } else if (path.startsWith('/catalogues/produits') || path === '/product-catalog') { + } else if (path.startsWith('/catalogues/produits')) { result.push({ label: 'Produits', path: '/catalogues/produits' }) } diff --git a/frontend/app/components/layout/AppNavbar.vue b/frontend/app/components/layout/AppNavbar.vue index 2221072..42d03da 100644 --- a/frontend/app/components/layout/AppNavbar.vue +++ b/frontend/app/components/layout/AppNavbar.vue @@ -270,6 +270,7 @@ import IconLucideChevronDown from '~icons/lucide/chevron-down' import IconLucideLogOut from '~icons/lucide/log-out' import IconLucideLayoutDashboard from '~icons/lucide/layout-dashboard' import IconLucideFactory from '~icons/lucide/factory' +import IconLucideBookOpen from '~icons/lucide/book-open' import IconLucidePackage from '~icons/lucide/package' import IconLucideSun from '~icons/lucide/sun' @@ -299,6 +300,7 @@ interface NavGroup { const simpleLinks: NavLink[] = [ { to: '/', label: 'Vue d\'ensemble', icon: IconLucideLayoutDashboard }, { to: '/machines', label: 'Parc Machines', icon: IconLucideFactory }, + { to: '/doc', label: 'Documentation', icon: IconLucideBookOpen }, ] const navGroups: NavGroup[] = [ @@ -306,7 +308,7 @@ const navGroups: NavGroup[] = [ id: 'catalogues', label: 'Catalogues', icon: IconLucidePackage, - activePaths: ['/catalogues', '/component', '/piece', '/product', '/component-catalog', '/pieces-catalog', '/product-catalog'], + activePaths: ['/catalogues', '/component', '/piece', '/product'], children: [ { to: '/catalogues/composants', label: 'Composants' }, { to: '/catalogues/pieces', label: 'Pièces' }, diff --git a/frontend/app/composables/useComponentEdit.ts b/frontend/app/composables/useComponentEdit.ts index e8e23c3..f24db16 100644 --- a/frontend/app/composables/useComponentEdit.ts +++ b/frontend/app/composables/useComponentEdit.ts @@ -12,7 +12,7 @@ import { extractRelationId } from '~/shared/apiRelations' import { useDocuments } from '~/composables/useDocuments' import { useConstructeurs } from '~/composables/useConstructeurs' import { useConstructeurLinks } from '~/composables/useConstructeurLinks' -import { useComponentHistory } from '~/composables/useComponentHistory' +import { useEntityHistory } from '~/composables/useEntityHistory' import { formatStructurePreview, normalizeStructureForEditor } from '~/shared/modelUtils' import { uniqueConstructeurIds, constructeurIdsFromLinks } from '~/shared/constructeurUtils' import type { ConstructeurLinkEntry } from '~/shared/constructeurUtils' @@ -65,7 +65,7 @@ export function useComponentEdit(componentId: string) { loading: historyLoading, error: historyError, loadHistory, - } = useComponentHistory() + } = useEntityHistory('composant') const component = ref(null) const loading = ref(true) diff --git a/frontend/app/composables/useComponentHistory.ts b/frontend/app/composables/useComponentHistory.ts deleted file mode 100644 index 620eb36..0000000 --- a/frontend/app/composables/useComponentHistory.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Backward-compatible wrapper around useEntityHistory. - * Real logic lives in useEntityHistory.ts. - */ -import { useEntityHistory, type EntityHistoryActor, type EntityHistoryEntry } from './useEntityHistory' - -export type ComponentHistoryActor = EntityHistoryActor -export type ComponentHistoryEntry = EntityHistoryEntry - -export function useComponentHistory() { - return useEntityHistory('composant') -} diff --git a/frontend/app/composables/useComposants.ts b/frontend/app/composables/useComposants.ts index 61d6809..74b7b3c 100644 --- a/frontend/app/composables/useComposants.ts +++ b/frontend/app/composables/useComposants.ts @@ -4,7 +4,7 @@ import { useApi } from './useApi' import { uniqueConstructeurIds } from '~/shared/constructeurUtils' import { useConstructeurs, type Constructeur } from './useConstructeurs' import { extractRelationId, normalizeRelationIds } from '~/shared/apiRelations' -import { extractCollection } from '~/shared/utils/apiHelpers' +import { extractCollection, extractTotal } from '~/shared/utils/apiHelpers' export interface Composant { id: string @@ -51,17 +51,6 @@ const total = ref(0) const loading = ref(false) const loaded = ref(false) -const extractTotal = (payload: unknown, fallbackLength: number): number => { - const p = payload as Record | null - if (typeof p?.totalItems === 'number') { - return p.totalItems - } - if (typeof p?.['hydra:totalItems'] === 'number') { - return p['hydra:totalItems'] - } - return fallbackLength -} - export function useComposants() { const { showSuccess } = useToast() const { get, post, patch, delete: del } = useApi() diff --git a/frontend/app/composables/useDocuments.ts b/frontend/app/composables/useDocuments.ts index 5078c5a..475e5be 100644 --- a/frontend/app/composables/useDocuments.ts +++ b/frontend/app/composables/useDocuments.ts @@ -1,7 +1,7 @@ import { ref } from 'vue' import { useApi } from './useApi' import { useToast } from './useToast' -import { extractCollection } from '~/shared/utils/apiHelpers' +import { extractCollection, extractTotal } from '~/shared/utils/apiHelpers' export interface Document { id: string @@ -58,13 +58,6 @@ const total = ref(0) const loading = ref(false) const loaded = ref(false) -const extractTotal = (payload: unknown, fallbackLength: number): number => { - const p = payload as Record | null - if (typeof p?.totalItems === 'number') return p.totalItems - if (typeof p?.['hydra:totalItems'] === 'number') return p['hydra:totalItems'] - return fallbackLength -} - export function useDocuments() { const { get, patch, postFormData, delete: del } = useApi() const { showError, showSuccess } = useToast() diff --git a/frontend/app/composables/usePieceEdit.ts b/frontend/app/composables/usePieceEdit.ts index 215b9ba..b5ad95b 100644 --- a/frontend/app/composables/usePieceEdit.ts +++ b/frontend/app/composables/usePieceEdit.ts @@ -7,7 +7,7 @@ import { useToast } from '~/composables/useToast' import { useDocuments } from '~/composables/useDocuments' import { useConstructeurs } from '~/composables/useConstructeurs' import { useConstructeurLinks } from '~/composables/useConstructeurLinks' -import { usePieceHistory } from '~/composables/usePieceHistory' +import { useEntityHistory } from '~/composables/useEntityHistory' import { extractRelationId } from '~/shared/apiRelations' import { canPreviewDocument } from '~/utils/documentPreview' import { formatPieceStructurePreview } from '~/shared/modelUtils' @@ -47,7 +47,7 @@ export function usePieceEdit(pieceId: string) { loading: historyLoading, error: historyError, loadHistory, - } = usePieceHistory() + } = useEntityHistory('piece') const piece = ref(null) const loading = ref(true) diff --git a/frontend/app/composables/usePieceHistory.ts b/frontend/app/composables/usePieceHistory.ts deleted file mode 100644 index 7f4e607..0000000 --- a/frontend/app/composables/usePieceHistory.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Backward-compatible wrapper around useEntityHistory. - * Real logic lives in useEntityHistory.ts. - */ -import { useEntityHistory, type EntityHistoryActor, type EntityHistoryEntry } from './useEntityHistory' - -export type PieceHistoryActor = EntityHistoryActor -export type PieceHistoryEntry = EntityHistoryEntry - -export function usePieceHistory() { - return useEntityHistory('piece') -} diff --git a/frontend/app/composables/usePieces.ts b/frontend/app/composables/usePieces.ts index 42c1724..29fbe5b 100644 --- a/frontend/app/composables/usePieces.ts +++ b/frontend/app/composables/usePieces.ts @@ -4,7 +4,7 @@ import { useApi } from './useApi' import { uniqueConstructeurIds } from '~/shared/constructeurUtils' import { useConstructeurs, type Constructeur } from './useConstructeurs' import { extractRelationId, normalizeRelationIds } from '~/shared/apiRelations' -import { extractCollection } from '~/shared/utils/apiHelpers' +import { extractCollection, extractTotal } from '~/shared/utils/apiHelpers' export interface Piece { id: string @@ -53,17 +53,6 @@ const total = ref(0) const loading = ref(false) const loaded = ref(false) -const extractTotal = (payload: unknown, fallbackLength: number): number => { - const p = payload as Record | null - if (typeof p?.totalItems === 'number') { - return p.totalItems - } - if (typeof p?.['hydra:totalItems'] === 'number') { - return p['hydra:totalItems'] - } - return fallbackLength -} - export function usePieces() { const { showSuccess } = useToast() const { get, post, patch, delete: del } = useApi() diff --git a/frontend/app/composables/useProductHistory.ts b/frontend/app/composables/useProductHistory.ts deleted file mode 100644 index aa45d20..0000000 --- a/frontend/app/composables/useProductHistory.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Backward-compatible wrapper around useEntityHistory. - * Real logic lives in useEntityHistory.ts. - */ -import { useEntityHistory, type EntityHistoryActor, type EntityHistoryEntry } from './useEntityHistory' - -export type ProductHistoryActor = EntityHistoryActor -export type ProductHistoryEntry = EntityHistoryEntry - -export function useProductHistory() { - return useEntityHistory('product') -} diff --git a/frontend/app/composables/useProducts.ts b/frontend/app/composables/useProducts.ts index e63a1df..ddf47fb 100644 --- a/frontend/app/composables/useProducts.ts +++ b/frontend/app/composables/useProducts.ts @@ -5,7 +5,7 @@ import { humanizeError } from '~/shared/utils/errorMessages' import { uniqueConstructeurIds } from '~/shared/constructeurUtils' import { useConstructeurs, type Constructeur } from './useConstructeurs' import { extractRelationId, normalizeRelationIds } from '~/shared/apiRelations' -import { extractCollection } from '~/shared/utils/apiHelpers' +import { extractCollection, extractTotal } from '~/shared/utils/apiHelpers' export interface Product { id: string @@ -66,17 +66,6 @@ const replaceInCache = (item: Product): boolean => { return false } -const extractTotal = (payload: unknown, fallbackLength: number): number => { - const p = payload as Record | null - if (typeof p?.totalItems === 'number') { - return p.totalItems - } - if (typeof p?.['hydra:totalItems'] === 'number') { - return p['hydra:totalItems'] - } - return fallbackLength -} - export function useProducts() { const { showError } = useToast() const { get, post, patch, delete: del } = useApi() diff --git a/frontend/app/pages/catalogues/composants.vue b/frontend/app/pages/catalogues/composants.vue index 636d716..785baa9 100644 --- a/frontend/app/pages/catalogues/composants.vue +++ b/frontend/app/pages/catalogues/composants.vue @@ -1,8 +1,13 @@ + +