Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | 1x 16x 1x 3x 16x 1x 1x 1x 6x 1x 9x 9x 9x 9x 9x 13x 9x 9x 9x 9x 9x 9x 1x 1x 1x 1x 1x 1x 1x | <template>
<PageLayout :title="t('catalog.title')" class="catalog-page">
<template #action>
<button
class="btn btn-outline-secondary refresh-catalog-btn"
:disabled="catalogStore.loading"
@click="refreshCatalog"
>
<font-awesome-icon icon="fa-solid fa-rotate-right" class="me-md-2" />
<span class="d-none d-md-inline">{{ t('common.refresh') }}</span>
</button>
</template>
<div class="container-fluid">
<SearchFilterHeader
v-model="searchQuery"
:placeholder="t('catalog.search-placeholder')"
:filtered-count="filteredCount"
:total-count="totalCount"
/>
</div>
<!-- Loading state -->
<div v-if="catalogStore.loading && catalogStore.entities.length === 0" class="text-center py-5">
<div class="spinner-border" role="status">
<span class="visually-hidden">{{ t('common.loading') }}</span>
</div>
<p class="text-muted mt-3">{{ t('common.loading') }}</p>
</div>
<!-- Empty state -->
<div v-else-if="filteredCount === 0" class="alert alert-info" role="alert">
<i class="fa fa-info-circle fa-fw me-2" />
{{ searchQuery ? t('common.noResults') : t('catalog.no-public-entities') }}
</div>
<!-- Entities grid -->
<VirtualCardGrid
v-else
:items="filteredEntities"
:has-more="catalogStore.hasMore"
:is-loading="catalogStore.loading"
:offset-height="280"
@load-more="catalogStore.loadMore()"
>
<template #card="{ item: entity }">
<EntityCard
:entity="entity"
navigation-source="catalog"
@fork="handleFork(entity)"
@link="handleLink(entity)"
/>
</template>
</VirtualCardGrid>
<!-- Error message -->
<div v-if="catalogStore.error" class="alert alert-danger mt-4" role="alert">
<i class="fa fa-exclamation-triangle fa-fw me-2" />
{{ catalogStore.error }}
</div>
</PageLayout>
<FloatingPageActions :scroll-top-title="t('common.backToTop')" />
</template>
<script setup lang="ts">
// @implements UC-CATALOG-001.1, UC-CATALOG-002.1, UC-CATALOG-003.1, UC-CATALOG-004.1, UC-ENTITY-010.1, UC-ENTITY-012.1, UC-ENTITY-013.1
import { onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useCatalogStore } from '@/stores/catalog'
import { useEntitiesStore } from '@/stores/entities'
import { useUILanguage } from '@/composables/useUILanguage'
import { useDebouncedSearch } from '@/composables/useDebouncedSearch'
import PageLayout from '@/components/PageLayout.vue'
import VirtualCardGrid from '@/components/VirtualCardGrid.vue'
import EntityCard from '@/components/EntityCard.vue'
import FloatingPageActions from '@/components/FloatingPageActions.vue'
import SearchFilterHeader from '@/components/SearchFilterHeader.vue'
import type { Entity } from '@/stores/entities'
const router = useRouter()
const catalogStore = useCatalogStore()
const entitiesStore = useEntitiesStore()
const { t } = useUILanguage()
const { searchQuery, appliedQuery, runSearchNow } = useDebouncedSearch(async (query) => {
await catalogStore.fetchCatalog(query)
})
const filteredCount = computed(() =>
Math.max(catalogStore.filteredTotal, catalogStore.entities.length)
)
const totalCount = computed(() => Math.max(catalogStore.total, filteredCount.value))
const filteredEntities = computed(() => catalogStore.entities)
onMounted(async () => {
await runSearchNow()
})
async function refreshCatalog() {
searchQuery.value = appliedQuery.value
await runSearchNow()
}
function displayEntityName(entity: Entity): string {
Eif (typeof entity.name === 'string') return entity.name
return entity.name?.en || entity.name?.fr || 'Unnamed Entity'
}
async function handleFork(entity: Entity) {
try {
// Fork entity using the entities store
const forkedEntity = await entitiesStore.forkEntity(entity.id, {
name: `${displayEntityName(entity)} (Fork)`,
visibility: 'flow-members'
})
// Mark as forked locally
catalogStore.markAsForked(entity.id)
// Show success notification (integrate with toast service later)
await router.push({ name: 'entity-items', params: { entityId: forkedEntity.id } })
} catch {
// Handle error silently (integrate with toast service later)
}
}
async function handleLink(entity: Entity) {
try {
await entitiesStore.linkEntity(entity.id)
catalogStore.markAsLinked(entity.id)
} catch {
// Handle error silently (integrate with toast service later)
}
}
</script>
<style scoped>
/* Remove padding from PageLayout for this page */
.catalog-page :deep(.page-content) {
padding: 0 !important;
}
/* Add spacing back to header section */
.page-header-spacing {
padding: 0 2rem;
}
/* Scrollable edit form */
.border-primary .card-body {
max-height: 70vh;
overflow-y: auto;
}
.default-picture {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
font-size: 3rem;
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.input-group {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.input-group .form-control:focus {
box-shadow: none;
border-color: #689909;
}
.input-group .input-group-text {
border-color: #e9ecef;
}
/* Mobile optimization */
@media (max-width: 767px) {
.page-header-spacing {
padding: 0 1rem;
}
.display-6 {
font-size: 1.5rem;
}
.card-header h5 {
font-size: 1rem;
}
/* Stack form fields vertically */
.row.g-3 {
row-gap: 0.75rem !important;
}
/* Form buttons can be full width, but not action buttons */
.card .btn {
width: 100%;
margin-top: 0.5rem;
}
}
</style>
|