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