mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 08:40:28 +00:00
add copy button support for item details
This commit is contained in:
parent
033068af62
commit
8940f98de6
5 changed files with 51 additions and 8 deletions
|
@ -1,13 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<button class="btn btn-outline btn-square btn-sm" @click="copyText">
|
<button class="" @click="copyText">
|
||||||
<label
|
<label
|
||||||
class="swap swap-rotate"
|
class="swap swap-rotate"
|
||||||
:class="{
|
:class="{
|
||||||
'swap-active': copied,
|
'swap-active': copied,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<Icon class="swap-off h-5 w-5" name="mdi-content-copy" />
|
<Icon
|
||||||
<Icon class="swap-on h-5 w-5" name="mdi-clipboard" />
|
class="swap-off"
|
||||||
|
name="mdi-content-copy"
|
||||||
|
:style="{
|
||||||
|
height: `${iconSize}px`,
|
||||||
|
width: `${iconSize}px`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<Icon
|
||||||
|
class="swap-on"
|
||||||
|
name="mdi-clipboard"
|
||||||
|
:style="{
|
||||||
|
height: `${iconSize}px`,
|
||||||
|
width: `${iconSize}px`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -18,6 +32,10 @@
|
||||||
type: String as () => string,
|
type: String as () => string,
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
|
iconSize: {
|
||||||
|
type: Number as () => number,
|
||||||
|
default: 20,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const copied = ref(false);
|
const copied = ref(false);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="border-t border-gray-300 px-4 py-5 sm:p-0">
|
<div class="border-t border-gray-300 px-4 py-5 sm:p-0">
|
||||||
<dl class="sm:divide-y sm:divide-gray-300">
|
<dl class="sm:divide-y sm:divide-gray-300">
|
||||||
<div v-for="(detail, i) in details" :key="i" class="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div v-for="(detail, i) in details" :key="i" class="py-4 sm:grid group sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
<dt class="text-sm font-medium text-base-content">
|
<dt class="text-sm font-medium text-base-content">
|
||||||
{{ detail.name }}
|
{{ detail.name }}
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm text-base-content sm:col-span-2 sm:mt-0">
|
<dd class="text-sm text-base-content text-start sm:col-span-2">
|
||||||
<slot :name="detail.slot || detail.name" v-bind="{ detail }">
|
<slot :name="detail.slot || detail.name" v-bind="{ detail }">
|
||||||
<DateTime v-if="detail.type == 'date'" :date="detail.text" />
|
<DateTime v-if="detail.type == 'date'" :date="detail.text" />
|
||||||
<Currency v-else-if="detail.type == 'currency'" :amount="detail.text" />
|
<Currency v-else-if="detail.type == 'currency'" :amount="detail.text" />
|
||||||
|
@ -23,7 +23,15 @@
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
<span class="flex items-center">
|
||||||
{{ detail.text }}
|
{{ detail.text }}
|
||||||
|
<span
|
||||||
|
v-if="detail.copyable"
|
||||||
|
class="opacity-0 group-hover:opacity-100 ml-4 my-0 duration-75 transition-opacity"
|
||||||
|
>
|
||||||
|
<CopyText :text="detail.text.toString()" :icon-size="16" class="btn btn-xs btn-ghost btn-circle" />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</slot>
|
</slot>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
|
@ -29,6 +29,7 @@ type MarkdownDetail = BaseDetail & {
|
||||||
export type Detail = BaseDetail & {
|
export type Detail = BaseDetail & {
|
||||||
text: StringLike;
|
text: StringLike;
|
||||||
type?: "text";
|
type?: "text";
|
||||||
|
copyable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AnyDetail = DateDetail | CurrencyDetail | LinkDetail | MarkdownDetail | Detail;
|
export type AnyDetail = DateDetail | CurrencyDetail | LinkDetail | MarkdownDetail | Detail;
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
item.value?.attachments.reduce((acc, cur) => {
|
item.value?.attachments.reduce((acc, cur) => {
|
||||||
if (cur.type === "photo") {
|
if (cur.type === "photo") {
|
||||||
acc.push({
|
acc.push({
|
||||||
|
// @ts-expect-error - it's impossible for this to be null at this point
|
||||||
src: api.authURL(`/items/${item.value.id}/attachments/${cur.id}`),
|
src: api.authURL(`/items/${item.value.id}/attachments/${cur.id}`),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -99,6 +100,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const assetID = computed<Details>(() => {
|
const assetID = computed<Details>(() => {
|
||||||
|
if (!item.value) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (item.value?.assetId === "000-000") {
|
if (item.value?.assetId === "000-000") {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -112,6 +117,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const itemDetails = computed<Details>(() => {
|
const itemDetails = computed<Details>(() => {
|
||||||
|
if (!item.value) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: "Description",
|
name: "Description",
|
||||||
|
@ -125,14 +134,17 @@
|
||||||
{
|
{
|
||||||
name: "Serial Number",
|
name: "Serial Number",
|
||||||
text: item.value?.serialNumber,
|
text: item.value?.serialNumber,
|
||||||
|
copyable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Model Number",
|
name: "Model Number",
|
||||||
text: item.value?.modelNumber,
|
text: item.value?.modelNumber,
|
||||||
|
copyable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Manufacturer",
|
name: "Manufacturer",
|
||||||
text: item.value?.manufacturer,
|
text: item.value?.manufacturer,
|
||||||
|
copyable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Insured",
|
name: "Insured",
|
||||||
|
@ -384,6 +396,7 @@
|
||||||
<span class="text-base-content">
|
<span class="text-base-content">
|
||||||
{{ item ? item.name : "" }}
|
{{ item ? item.name : "" }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div v-if="item.parent" class="text-sm breadcrumbs pb-0">
|
<div v-if="item.parent" class="text-sm breadcrumbs pb-0">
|
||||||
<ul class="text-base-content/70">
|
<ul class="text-base-content/70">
|
||||||
<li>
|
<li>
|
||||||
|
@ -393,6 +406,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<template #description>
|
<template #description>
|
||||||
|
<p class="text-lg">
|
||||||
|
{{ item ? item.description : "" }}
|
||||||
|
</p>
|
||||||
<div class="flex flex-wrap gap-2 mt-3">
|
<div class="flex flex-wrap gap-2 mt-3">
|
||||||
<NuxtLink ref="badge" class="badge p-3" :to="`/location/${item.location.id}`">
|
<NuxtLink ref="badge" class="badge p-3" :to="`/location/${item.location.id}`">
|
||||||
<Icon name="heroicons-map-pin" class="mr-2 swap-on"></Icon>
|
<Icon name="heroicons-map-pin" class="mr-2 swap-on"></Icon>
|
||||||
|
|
|
@ -221,11 +221,11 @@
|
||||||
<BaseButton size="sm" @click="generateToken"> Generate Invite Link </BaseButton>
|
<BaseButton size="sm" @click="generateToken"> Generate Invite Link </BaseButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="token" class="pt-4 flex items-center pl-1">
|
<div v-if="token" class="pt-4 flex items-center pl-1">
|
||||||
<CopyText class="mr-2 btn-primary" :text="tokenUrl" />
|
<CopyText class="mr-2 btn-primary btn btn-outline btn-square btn-sm" :text="tokenUrl" />
|
||||||
{{ tokenUrl }}
|
{{ tokenUrl }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="token" class="pt-4 flex items-center pl-1">
|
<div v-if="token" class="pt-4 flex items-center pl-1">
|
||||||
<CopyText class="mr-2 btn-primary" :text="token" />
|
<CopyText class="mr-2 btn-primary btn btn-outline btn-square btn-sm" :text="token" />
|
||||||
{{ token }}
|
{{ token }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue