-
-
Notifications
You must be signed in to change notification settings - Fork 622
Expand file tree
/
Copy pathAssetReferences.vue
More file actions
99 lines (92 loc) · 3.16 KB
/
AssetReferences.vue
File metadata and controls
99 lines (92 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<div v-if="!isLoaded" class="flex items-center justify-center">
<ui-button @click="loadReferences" :text="__('View Usage')" variant="filled" size="sm" />
</div>
<div v-else>
<Listing
:url="url"
:columns="columns"
:per-page="5"
:show-pagination-totals="false"
:show-pagination-page-links="false"
:show-pagination-per-page-selector="false"
:allow-search="false"
:allow-customizing-columns="false"
>
<template #initializing>
<div class="flex flex-col gap-[8px] justify-between py-1 px-5">
<ui-skeleton class="h-[18px] w-full" />
<ui-skeleton class="h-[18px] w-full" />
<ui-skeleton class="h-[18px] w-full" />
</div>
</template>
<template #default="{ items }">
<ui-description v-if="items?.length" :text="__('In Use')" class="mb-3" />
<table v-if="items?.length" class="w-full [&_td]:px-0.75 [&_td]:py-1 [&_td]:text-sm">
<ListingTableHead sr-only />
<ListingTableBody class="divide-y divide-gray-200 dark:divide-gray-700">
<template #cell-title="{ row: entry }">
<div class="flex items-center gap-2">
<StatusIndicator :status="entry.status" />
<Link :href="entry.edit_url" class="line-clamp-1 overflow-hidden text-ellipsis">{{ entry.title }}</Link>
</div>
</template>
<template #cell-collection="{ row: entry }">
<div class="text-end">
<ui-badge :text="entry.collection?.title" size="sm" />
</div>
</template>
</ListingTableBody>
</table>
<ui-subheading v-else class="text-center h-full flex items-center justify-center py-4">
{{ __('This asset is not being used anywhere.') }}
</ui-subheading>
</template>
</Listing>
</div>
</template>
<script>
import {
StatusIndicator,
Listing,
ListingTableHead,
ListingTableBody,
} from '@/components/ui';
import { Link } from '@inertiajs/vue3';
export default {
components: {
StatusIndicator,
Listing,
ListingTableHead,
ListingTableBody,
Link,
},
props: {
assetId: {
type: String,
required: true,
},
},
data() {
return {
isLoaded: false,
};
},
computed: {
url() {
return cp_url(`assets/${utf8btoa(this.assetId)}/references`);
},
columns() {
return [
{ label: 'Title', field: 'title', visible: true },
{ label: 'Collection name', field: 'collection', visible: true },
];
},
},
methods: {
loadReferences() {
this.isLoaded = true;
},
},
};
</script>