mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
27b72603e1
* feat: show quantity in card view if quantity == 0 (hay-kot/homebox#672)
* Update frontend/components/Item/Card.vue
---------
Co-authored-by: bee-eater <bee-eater@users.noreply.github.com>
Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
Former-commit-id: d8e49622e5
79 lines
2.3 KiB
Vue
79 lines
2.3 KiB
Vue
<template>
|
|
<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}`"
|
|
>
|
|
{{ item.location.name }}
|
|
</NuxtLink>
|
|
</div>
|
|
</div>
|
|
<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>
|
|
<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>
|
|
<div class="tooltip" data-tip="Quantity">
|
|
<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" />
|
|
</div>
|
|
</div>
|
|
</NuxtLink>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";
|
|
|
|
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}`);
|
|
});
|
|
|
|
const top3 = computed(() => {
|
|
return props.item.labels.slice(0, 3) || [];
|
|
});
|
|
|
|
const props = defineProps({
|
|
item: {
|
|
type: Object as () => ItemOut | ItemSummary,
|
|
required: true,
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<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>
|