# Detail Views for Piece, Composant, Product — Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Add consultation (read-only detail) pages for Piece, Composant, and Product with edit/view toggle, matching the existing Machine detail pattern. **Architecture:** Each entity gets a new page (`/piece/[id].vue`, `/component/[id].vue`, `/product/[id].vue`) that reuses the existing edit composables but adds a `isEditMode` toggle. In view mode: text display only, empty fields hidden, documents section hidden if empty. In edit mode: existing form UI. Catalogs and cross-links updated to point to detail pages instead of edit pages. **Tech Stack:** Nuxt 4, Vue 3 Composition API, DaisyUI 5, TailwindCSS 4 --- ## File Map | Action | File | Responsibility | |--------|------|----------------| | Create | `app/pages/piece/[id].vue` | Piece detail page with edit/view toggle | | Create | `app/pages/component/[id].vue` | Component detail page with edit/view toggle | | Create | `app/pages/product/[id].vue` | Product detail page with edit/view toggle | | Create | `app/components/DetailHeader.vue` | Shared header with title + edit/view toggle button (reusable across all 3 entities) | | Modify | `app/pages/pieces-catalog.vue` | Link to `/piece/{id}` instead of `/pieces/{id}/edit` + add "Détails" button | | Modify | `app/pages/component-catalog.vue` | Link to `/component/{id}` instead of `/component/{id}/edit` + add "Détails" button | | Modify | `app/pages/product-catalog.vue` | Link to `/product/{id}` instead of `/product/{id}/edit` + add "Détails" button | | Modify | `app/pages/comments.vue` | Update entity URL map to use detail pages | | Modify | `app/components/PieceItem.vue:183` | Update "Ouvrir la fiche produit" link | | Modify | `app/components/ComponentItem.vue:130` | Update "Voir le produit" link | | Keep | `app/pages/pieces/[id]/edit.vue` | Keep existing edit page (still works, redirects optional later) | | Keep | `app/pages/component/[id]/edit.vue` | Keep existing edit page | | Keep | `app/pages/product/[id]/edit.vue` | Keep existing edit page | --- ## Patterns to Follow (from Machine detail) **View/Edit toggle:** ```vue
{{ entity.name }}
``` **Hide empty fields in view mode:** ```vue
``` **Hide documents section if empty:** ```vue
``` **Query param for direct edit:** ```ts if (route.query.edit === 'true' && canEdit.value) { isEditMode.value = true } ``` **Catalog buttons pattern (like machines/index.vue):** ```vue Détails ``` --- ## Task 1: Create shared DetailHeader component **Files:** - Create: `app/components/DetailHeader.vue` - [ ] **Step 1: Create DetailHeader.vue** Based on `app/components/machine/MachineDetailHeader.vue` pattern. Shared across piece/composant/product. ```vue ``` - [ ] **Step 2: Commit** ```bash git add app/components/DetailHeader.vue git commit -m "feat(detail) : add shared DetailHeader component for entity detail pages" ``` --- ## Task 2: Create Piece detail page **Files:** - Create: `app/pages/piece/[id].vue` - Reference: `app/pages/pieces/[id]/edit.vue` (existing edit page) - Reference: `app/composables/usePieceEdit.ts` (reuse) - [ ] **Step 1: Create `/piece/[id].vue`** This page reuses `usePieceEdit` composable and adds `isEditMode` toggle. In view mode, fields are displayed as text; empty fields are hidden. Documents section hidden if empty. Edit mode shows the full form. Key sections in view mode (only shown if value exists): - **Catégorie** — always shown (always has a value) - **Nom** — always shown - **Description** — `v-if="isEditMode || piece?.description"` - **Référence** — `v-if="isEditMode || editionForm.reference"` - **Fournisseurs** — `v-if="isEditMode || editionForm.constructeurIds.length"` - **Prix** — `v-if="isEditMode || editionForm.prix"` - **Produits requis (skeleton)** — `v-if="isEditMode || structureProducts.length"` - **Skeleton preview** — `v-if="isEditMode || resolvedStructure"` - **Champs personnalisés** — `v-if="isEditMode || customFieldInputs.length"`, inside: each field hidden if no value in view mode - **Documents** — `v-if="isEditMode || pieceDocuments.length > 0"` - **Historique** — always shown - **Commentaires** — always shown ```vue