Files
Inventory/frontend/app/components/DetailHeader.vue
r-dev 6a43f08df8 fix(ui) : phase 1 review fixes — machine context links, type annotations, double arrow
- Add ?from=machine&machineId=xxx query params to entity NuxtLinks in hierarchy
- Add useRoute + machineId computed to ComponentItem, PieceItem, MachineProductsCard
- Add :string type to confirmRemove* handlers in machine page
- Remove unicode arrow from DetailHeader backLabel (icon already provides it)
- Add !isEditMode guard on product links in MachineProductsCard

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 17:12:20 +02:00

60 lines
1.7 KiB
Vue

<template>
<div class="flex flex-col gap-4 md:flex-row md:items-start md:justify-between">
<div class="flex flex-col gap-2">
<h1 class="text-3xl font-bold">{{ title }}</h1>
<p v-if="subtitle" class="text-sm text-base-content/70">{{ subtitle }}</p>
</div>
<div class="flex items-center gap-2">
<button
v-if="canEdit"
class="btn btn-primary"
:class="{ 'btn-outline': isEditMode }"
@click="$emit('toggle-edit')"
>
<IconLucideSquarePen v-if="!isEditMode" class="w-5 h-5 mr-2" aria-hidden="true" />
<IconLucideEye v-else class="w-5 h-5 mr-2" aria-hidden="true" />
{{ isEditMode ? 'Voir détails' : 'Modifier' }}
</button>
<NuxtLink :to="backDestination" class="btn btn-ghost btn-sm md:btn-md">
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
{{ backLabel }}
</NuxtLink>
</div>
</div>
</template>
<script setup lang="ts">
import IconLucideSquarePen from '~icons/lucide/square-pen'
import IconLucideEye from '~icons/lucide/eye'
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
const route = useRoute()
const props = defineProps<{
title: string
subtitle?: string
isEditMode: boolean
canEdit: boolean
backLink: string
backLinkLabel?: string
}>()
defineEmits<{
'toggle-edit': []
}>()
const backDestination = computed(() => {
if (route.query.from === 'machine' && route.query.machineId) {
return `/machine/${route.query.machineId}`
}
return props.backLink
})
const backLabel = computed(() => {
if (route.query.from === 'machine') {
return 'Retour à la machine'
}
return props.backLinkLabel ?? 'Retour au catalogue'
})
</script>