2022-09-03 09:17:57 +00:00
|
|
|
<template>
|
2023-10-07 02:51:08 +00:00
|
|
|
<NuxtLink class="group card rounded-md border border-gray-300" :to="`/item/${item.id}`">
|
|
|
|
<div class="relative h-[200px]">
|
|
|
|
<img v-if="imageUrl" class="h-[200px] w-full object-cover rounded-t shadow-sm border-gray-300" :src="imageUrl" />
|
|
|
|
<div class="absolute bottom-1 left-1">
|
|
|
|
<NuxtLink
|
|
|
|
v-if="item.location"
|
|
|
|
class="text-sm hover:link badge shadow-md rounded-md"
|
|
|
|
:to="`/location/${item.location.id}`"
|
|
|
|
>
|
2023-01-01 21:50:48 +00:00
|
|
|
{{ item.location.name }}
|
2023-01-22 06:15:23 +00:00
|
|
|
</NuxtLink>
|
|
|
|
</div>
|
2023-01-01 21:50:48 +00:00
|
|
|
</div>
|
2023-10-07 02:51:08 +00:00
|
|
|
<div class="rounded-b p-4 pt-2 flex-grow col-span-4 flex flex-col gap-y-1 bg-base-100">
|
|
|
|
<h2 class="text-lg font-bold two-line">{{ item.name }}</h2>
|
|
|
|
<div class="divider my-0"></div>
|
2023-01-01 21:50:48 +00:00
|
|
|
<div class="flex justify-between gap-2">
|
|
|
|
<div v-if="item.insured" class="tooltip z-10" data-tip="Insured">
|
|
|
|
<Icon class="h-5 w-5 text-primary" name="mdi-shield-check" />
|
|
|
|
</div>
|
2024-01-04 21:10:44 +00:00
|
|
|
<div class="tooltip" data-tip="Quantity">
|
2023-01-01 21:50:48 +00:00
|
|
|
<span class="badge h-5 w-5 badge-primary badge-sm text-xs">
|
|
|
|
{{ item.quantity }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Markdown class="mb-2 text-clip three-line" :source="item.description" />
|
|
|
|
<div class="flex gap-2 flex-wrap -mr-1 mt-auto justify-end">
|
|
|
|
<LabelChip v-for="label in top3" :key="label.id" :label="label" size="sm" />
|
2022-09-03 09:17:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</NuxtLink>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-09-12 22:47:27 +00:00
|
|
|
import { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";
|
2023-01-01 21:50:48 +00:00
|
|
|
|
2023-10-07 02:51:08 +00:00
|
|
|
const api = useUserApi();
|
|
|
|
|
|
|
|
const imageUrl = computed(() => {
|
|
|
|
if (!props.item.imageId) {
|
|
|
|
return "/no-image.jpg";
|
|
|
|
}
|
|
|
|
|
|
|
|
return api.authURL(`/items/${props.item.id}/attachments/${props.item.imageId}`);
|
|
|
|
});
|
|
|
|
|
2023-01-01 21:50:48 +00:00
|
|
|
const top3 = computed(() => {
|
|
|
|
return props.item.labels.slice(0, 3) || [];
|
|
|
|
});
|
2022-09-03 09:17:57 +00:00
|
|
|
|
2022-09-06 18:32:13 +00:00
|
|
|
const props = defineProps({
|
2022-09-03 09:17:57 +00:00
|
|
|
item: {
|
2022-09-12 22:47:27 +00:00
|
|
|
type: Object as () => ItemOut | ItemSummary,
|
2022-09-03 09:17:57 +00:00
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
2023-01-01 21:50:48 +00:00
|
|
|
|
|
|
|
<style lang="css">
|
|
|
|
.three-line {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-line-clamp: 3;
|
|
|
|
line-clamp: 3;
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
}
|
|
|
|
|
|
|
|
.two-line {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
line-clamp: 2;
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
}
|
|
|
|
</style>
|