tinyzoo 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -0
- package/README.md +46 -2
- package/app/app.config.ts +35 -0
- package/app/assets/brand/characters/bright/bird.svg +1 -0
- package/app/assets/brand/characters/bright/bunny.svg +1 -0
- package/app/assets/brand/characters/bright/elephant.svg +1 -0
- package/app/assets/brand/characters/bright/fox.svg +1 -0
- package/app/assets/brand/characters/bright/frog.svg +1 -0
- package/app/assets/brand/characters/bright/octopus.svg +1 -0
- package/app/assets/brand/characters/muted/bee.svg +1 -0
- package/app/assets/brand/characters/muted/bird.svg +1 -0
- package/app/assets/brand/characters/muted/butterfly.svg +1 -0
- package/app/assets/brand/characters/muted/chick.svg +1 -0
- package/app/assets/brand/characters/muted/cow.svg +1 -0
- package/app/assets/brand/characters/muted/deer.svg +1 -0
- package/app/assets/brand/characters/muted/duck.svg +1 -0
- package/app/assets/brand/characters/muted/elephant.svg +1 -0
- package/app/assets/brand/characters/muted/fox.svg +1 -0
- package/app/assets/brand/characters/muted/hedgehog.svg +1 -0
- package/app/assets/brand/characters/muted/koala.svg +1 -0
- package/app/assets/brand/characters/muted/ladybug.svg +1 -0
- package/app/assets/brand/characters/muted/lion.svg +1 -0
- package/app/assets/brand/characters/muted/mouse.svg +1 -0
- package/app/assets/brand/characters/muted/octopus.svg +1 -0
- package/app/assets/brand/characters/muted/owl.svg +1 -0
- package/app/assets/brand/characters/muted/panda.svg +1 -0
- package/app/assets/brand/characters/muted/penguin.svg +1 -0
- package/app/assets/brand/characters/muted/pig.svg +1 -0
- package/app/assets/brand/characters/muted/poodle.svg +1 -0
- package/app/assets/brand/characters/muted/raccoon.svg +1 -0
- package/app/assets/brand/characters/muted/seal.svg +1 -0
- package/app/assets/brand/characters/muted/sheep.svg +1 -0
- package/app/assets/brand/characters/muted/snail.svg +1 -0
- package/app/assets/brand/characters/muted/turtle.svg +1 -0
- package/app/assets/brand/characters/muted/whale.svg +1 -0
- package/app/assets/brand/logo/favicon.svg +1 -0
- package/app/assets/brand/logo/logo-primary-reversed.svg +1 -0
- package/app/assets/brand/logo/logo-primary.svg +1 -0
- package/app/assets/brand/logo/mascot-reversed.svg +1 -0
- package/app/assets/brand/logo/mascot.svg +1 -0
- package/app/assets/brand/logo/wordmark-reversed.svg +1 -0
- package/app/assets/brand/logo/wordmark.svg +1 -0
- package/app/assets/css/cms-admin.css +607 -0
- package/app/components/CmsBlocks.vue +30 -0
- package/app/components/CmsCell.vue +16 -0
- package/app/components/CmsCellBadge.vue +18 -0
- package/app/components/CmsCellBlocks.vue +9 -0
- package/app/components/CmsCellBoolean.vue +12 -0
- package/app/components/CmsCellCode.vue +7 -0
- package/app/components/CmsCellColor.vue +13 -0
- package/app/components/CmsCellDate.vue +10 -0
- package/app/components/CmsCellExcerpt.vue +21 -0
- package/app/components/CmsCellGallery.vue +10 -0
- package/app/components/CmsCellGroup.vue +23 -0
- package/app/components/CmsCellNumber.vue +7 -0
- package/app/components/CmsCellRelation.vue +8 -0
- package/app/components/CmsCellText.vue +12 -0
- package/app/components/CmsCellThumb.vue +18 -0
- package/app/components/CmsConfirmDialog.vue +55 -0
- package/app/components/CmsContent.vue +103 -0
- package/app/components/CmsDayPicker.vue +44 -0
- package/app/components/CmsEmptyState.vue +35 -0
- package/app/components/CmsField.vue +111 -0
- package/app/components/CmsFieldBlocks.vue +353 -0
- package/app/components/CmsFieldBoolean.vue +8 -0
- package/app/components/CmsFieldColor.vue +42 -0
- package/app/components/CmsFieldDate.vue +131 -0
- package/app/components/CmsFieldGallery.vue +114 -0
- package/app/components/CmsFieldGroup.vue +53 -0
- package/app/components/CmsFieldMedia.vue +219 -0
- package/app/components/CmsFieldNumber.vue +11 -0
- package/app/components/CmsFieldRelationMany.vue +54 -0
- package/app/components/CmsFieldRelationOne.vue +47 -0
- package/app/components/CmsFieldRichText.vue +45 -0
- package/app/components/CmsFieldSelect.vue +41 -0
- package/app/components/CmsFieldSlug.vue +46 -0
- package/app/components/CmsFieldText.vue +75 -0
- package/app/components/CmsFormSections.vue +150 -0
- package/app/components/CmsHighlight.vue +22 -0
- package/app/components/CmsImage.vue +39 -0
- package/app/components/CmsLinkPicker.vue +122 -0
- package/app/components/CmsLinkTarget.vue +35 -0
- package/app/components/CmsListFilters.vue +107 -0
- package/app/components/CmsLiveNotice.vue +64 -0
- package/app/components/CmsLoadError.vue +24 -0
- package/app/components/CmsMascot.vue +10 -0
- package/app/components/CmsMediaLibrary.vue +114 -0
- package/app/components/CmsMediaPreview.vue +34 -0
- package/app/components/CmsMediaThumb.vue +22 -0
- package/app/components/CmsMoment.vue +42 -0
- package/app/components/CmsNav.vue +39 -0
- package/app/components/CmsPage.vue +86 -0
- package/app/components/CmsPasswordInput.vue +22 -0
- package/app/components/CmsPresence.vue +29 -0
- package/app/components/CmsPreviewPanel.vue +131 -0
- package/app/components/CmsPublishReview.vue +102 -0
- package/app/components/CmsRevisions.vue +195 -0
- package/app/components/CmsRichTextEditor.vue +290 -0
- package/app/components/CmsSearch.vue +99 -0
- package/app/components/CmsSection.vue +20 -0
- package/app/components/CmsSingletonForm.vue +283 -0
- package/app/components/CmsStatusBadge.vue +21 -0
- package/app/components/CmsTime.vue +16 -0
- package/app/components/CmsTranslationRef.vue +27 -0
- package/app/components/CmsTreeList.vue +453 -0
- package/app/components/CmsUnsavedText.vue +34 -0
- package/app/components/CmsWordmark.vue +10 -0
- package/app/composables/useCmsAdminHead.ts +18 -0
- package/app/composables/useCmsCollab.ts +165 -0
- package/app/composables/useCmsConfirm.ts +39 -0
- package/app/composables/useCmsEntryActions.ts +75 -0
- package/app/composables/useCmsFocus.ts +13 -0
- package/app/composables/useCmsForm.ts +273 -0
- package/app/composables/useCmsI18n.ts +185 -0
- package/app/composables/useCmsLinkTargets.ts +84 -0
- package/app/composables/useCmsLive.ts +199 -0
- package/app/composables/useCmsSearch.ts +62 -0
- package/app/composables/useCmsSeo.ts +99 -0
- package/app/composables/useCmsSignedIn.ts +24 -0
- package/app/composables/useCmsUiLocale.ts +24 -0
- package/app/i18n/cs.ts +781 -0
- package/app/i18n/de.ts +781 -0
- package/app/i18n/en.ts +782 -0
- package/app/i18n/types.ts +22 -0
- package/app/layouts/admin.vue +224 -0
- package/app/layouts/cms-auth.vue +37 -0
- package/app/middleware/cms-api-not-a-page.global.ts +10 -0
- package/app/middleware/cms-auth.global.ts +16 -0
- package/app/pages/admin/[entity]/[id].vue +1109 -0
- package/app/pages/admin/[entity]/index.vue +733 -0
- package/app/pages/admin/account.vue +117 -0
- package/app/pages/admin/forgot.vue +50 -0
- package/app/pages/admin/index.vue +184 -0
- package/app/pages/admin/invite/[token].vue +73 -0
- package/app/pages/admin/login.vue +84 -0
- package/app/pages/admin/media.vue +494 -0
- package/app/pages/admin/privacy.vue +193 -0
- package/app/pages/admin/reset/[token].vue +52 -0
- package/app/pages/admin/setup.vue +87 -0
- package/app/pages/admin/styleguide.vue +261 -0
- package/app/pages/admin/team.vue +258 -0
- package/app/plugins/cmsLivePreview.client.ts +20 -0
- package/app/plugins/cmsSignedOut.client.ts +31 -0
- package/app/utils/cmsBlockType.ts +11 -0
- package/app/utils/cmsBrand.ts +38 -0
- package/app/utils/cmsDiff.ts +83 -0
- package/app/utils/cmsFetch.ts +7 -0
- package/app/utils/cmsFocusInvalid.ts +22 -0
- package/app/utils/cmsIssues.ts +128 -0
- package/app/utils/cmsJson.ts +28 -0
- package/app/utils/cmsMedia.ts +63 -0
- package/app/utils/cmsSections.ts +154 -0
- package/app/utils/cmsTime.ts +41 -0
- package/cli/backup.ts +713 -0
- package/cli/breaking.ts +174 -0
- package/cli/content-migrate.ts +239 -0
- package/cli/db.ts +86 -0
- package/cli/export.ts +336 -0
- package/cli/generate.ts +146 -0
- package/cli/import.ts +643 -0
- package/cli/index.ts +140 -0
- package/cli/links-convert.ts +291 -0
- package/cli/seed-engine.ts +705 -0
- package/cli/seed.ts +339 -0
- package/cli/status.ts +49 -0
- package/cli/tar.ts +304 -0
- package/cli/transfer.ts +677 -0
- package/cli/up.ts +27 -0
- package/cli/upgrade.ts +60 -0
- package/cli/versions.ts +60 -0
- package/forms/components/CmsForm.vue +186 -0
- package/forms/index.ts +203 -0
- package/forms/messages.ts +104 -0
- package/forms/retention.ts +48 -0
- package/forms/server/form.get.ts +12 -0
- package/forms/server/form.post.ts +109 -0
- package/forms/server/formSettings.ts +12 -0
- package/forms/server/forms.ts +127 -0
- package/module.ts +373 -0
- package/nuxt.config.ts +43 -0
- package/package.json +98 -3
- package/server/api/cms/[entity]/[id]/revisions/[rev].get.ts +19 -0
- package/server/api/cms/[entity]/[id]/revisions/index.get.ts +14 -0
- package/server/api/cms/[entity]/[id].delete.ts +52 -0
- package/server/api/cms/[entity]/[id].get.ts +21 -0
- package/server/api/cms/[entity]/[id].patch.ts +116 -0
- package/server/api/cms/[entity]/_export.get.ts +69 -0
- package/server/api/cms/[entity]/_move.post.ts +81 -0
- package/server/api/cms/[entity]/_order.post.ts +49 -0
- package/server/api/cms/[entity]/_tree.get.ts +41 -0
- package/server/api/cms/[entity]/index.get.ts +62 -0
- package/server/api/cms/[entity]/index.post.ts +38 -0
- package/server/api/cms/[entity]/options.get.ts +55 -0
- package/server/api/cms/_auth/accept.post.ts +33 -0
- package/server/api/cms/_auth/forgot.post.ts +39 -0
- package/server/api/cms/_auth/invite/[token].get.ts +18 -0
- package/server/api/cms/_auth/login.post.ts +42 -0
- package/server/api/cms/_auth/logout.post.ts +7 -0
- package/server/api/cms/_auth/me.get.ts +5 -0
- package/server/api/cms/_auth/me.patch.ts +32 -0
- package/server/api/cms/_auth/password.post.ts +29 -0
- package/server/api/cms/_auth/reset.post.ts +34 -0
- package/server/api/cms/_auth/setup.post.ts +46 -0
- package/server/api/cms/_auth/status.get.ts +18 -0
- package/server/api/cms/_collab/session.get.ts +30 -0
- package/server/api/cms/_collab/socket.ts +51 -0
- package/server/api/cms/_collab/unsaved.delete.ts +16 -0
- package/server/api/cms/_graph.get.ts +20 -0
- package/server/api/cms/_links/resolve.post.ts +17 -0
- package/server/api/cms/_links.get.ts +81 -0
- package/server/api/cms/_live.ts +30 -0
- package/server/api/cms/_media/[id]/usage.get.ts +14 -0
- package/server/api/cms/_media/[id].delete.ts +29 -0
- package/server/api/cms/_media/[id].get.ts +13 -0
- package/server/api/cms/_media/[id].patch.ts +64 -0
- package/server/api/cms/_media/exists.post.ts +15 -0
- package/server/api/cms/_media/img/[id]/[file].get.ts +42 -0
- package/server/api/cms/_media/index.get.ts +44 -0
- package/server/api/cms/_media/index.post.ts +147 -0
- package/server/api/cms/_media/raw/[...key].get.ts +85 -0
- package/server/api/cms/_media/raw/[...key].head.ts +2 -0
- package/server/api/cms/_overview.get.ts +87 -0
- package/server/api/cms/_preview.post.ts +17 -0
- package/server/api/cms/_privacy/delete.post.ts +14 -0
- package/server/api/cms/_privacy/export.post.ts +25 -0
- package/server/api/cms/_privacy/lookup.post.ts +27 -0
- package/server/api/cms/_search.get.ts +17 -0
- package/server/api/cms/_singleton/[name].get.ts +19 -0
- package/server/api/cms/_singleton/[name].put.ts +76 -0
- package/server/api/cms/_users/[id]/resend.post.ts +25 -0
- package/server/api/cms/_users/[id].delete.ts +21 -0
- package/server/api/cms/_users/[id].patch.ts +45 -0
- package/server/api/cms/_users/index.get.ts +28 -0
- package/server/api/cms/_users/index.post.ts +39 -0
- package/server/api/content/[entity]/[slug].get.ts +74 -0
- package/server/api/content/[entity]/index.get.ts +100 -0
- package/server/api/content/_global/[name].get.ts +23 -0
- package/server/api/content/_search.get.ts +28 -0
- package/server/api/content/_sitemap.get.ts +8 -0
- package/server/api/content/_tree/[entity].get.ts +31 -0
- package/server/api/content-types.ts.get.ts +17 -0
- package/server/api/health/live.get.ts +10 -0
- package/server/api/health/ready.get.ts +21 -0
- package/server/api/openapi.get.ts +48 -0
- package/server/api/openapi.json.get.ts +32 -0
- package/server/db/driver.ts +8 -0
- package/server/mail/mailer.ts +43 -0
- package/server/middleware/cms-0-headers.ts +37 -0
- package/server/middleware/cms-0-migrate-gate.ts +14 -0
- package/server/middleware/cms-csrf.ts +28 -0
- package/server/middleware/cms-limits.ts +20 -0
- package/server/middleware/cms-redirects.ts +21 -0
- package/server/middleware/cms-session.ts +41 -0
- package/server/middleware/cms-z-plugin-access.ts +15 -0
- package/server/plugins/cms-0-config-check.ts +35 -0
- package/server/plugins/cms-changes.ts +53 -0
- package/server/plugins/cms-content-etag.ts +21 -0
- package/server/plugins/cms-errors.ts +45 -0
- package/server/plugins/cms-migrate.ts +5 -0
- package/server/plugins/cms-plugins.ts +17 -0
- package/server/plugins/cms-search.ts +12 -0
- package/server/plugins/cms-setup-code.ts +15 -0
- package/server/routes/sitemap.xml.get.ts +25 -0
- package/server/store/redis.ts +95 -0
- package/server/store/types.ts +21 -0
- package/server/tasks/cms/retention.ts +10 -0
- package/server/tasks/cms/scheduled.ts +10 -0
- package/server/tasks/cms/search-reindex.ts +12 -0
- package/server/utils/cmsAudit.ts +29 -0
- package/server/utils/cmsAuth.ts +143 -0
- package/server/utils/cmsBlocks.ts +47 -0
- package/server/utils/cmsChanges.ts +222 -0
- package/server/utils/cmsCollab.ts +286 -0
- package/server/utils/cmsCollabServer.ts +451 -0
- package/server/utils/cmsCollate.ts +27 -0
- package/server/utils/cmsContent.ts +376 -0
- package/server/utils/cmsCrud.ts +361 -0
- package/server/utils/cmsCsv.ts +24 -0
- package/server/utils/cmsDb.ts +23 -0
- package/server/utils/cmsDemo.ts +36 -0
- package/server/utils/cmsEmails.ts +125 -0
- package/server/utils/cmsErrors.ts +40 -0
- package/server/utils/cmsFold.ts +17 -0
- package/server/utils/cmsImageSizes.ts +51 -0
- package/server/utils/cmsJson.ts +6 -0
- package/server/utils/cmsLinkAddress.ts +50 -0
- package/server/utils/cmsLinks.ts +248 -0
- package/server/utils/cmsListQuery.ts +93 -0
- package/server/utils/cmsLive.ts +393 -0
- package/server/utils/cmsLocales.ts +96 -0
- package/server/utils/cmsMail.ts +28 -0
- package/server/utils/cmsMediaGc.ts +188 -0
- package/server/utils/cmsMediaKeys.ts +62 -0
- package/server/utils/cmsMigrate.ts +86 -0
- package/server/utils/cmsPreviewDraft.ts +72 -0
- package/server/utils/cmsPrivacy.ts +176 -0
- package/server/utils/cmsPublished.ts +57 -0
- package/server/utils/cmsRange.ts +38 -0
- package/server/utils/cmsRateLimit.ts +82 -0
- package/server/utils/cmsRedirects.ts +160 -0
- package/server/utils/cmsRetention.ts +61 -0
- package/server/utils/cmsRevisions.ts +103 -0
- package/server/utils/cmsScheduler.ts +45 -0
- package/server/utils/cmsScrub.ts +107 -0
- package/server/utils/cmsSearch.ts +354 -0
- package/server/utils/cmsSession.ts +102 -0
- package/server/utils/cmsSetupCode.ts +97 -0
- package/server/utils/cmsSitemap.ts +176 -0
- package/server/utils/cmsStorage.ts +580 -0
- package/server/utils/cmsStore.ts +109 -0
- package/server/utils/cmsTiming.ts +14 -0
- package/server/utils/cmsTooMany.ts +9 -0
- package/server/utils/cmsTranslationWrite.ts +186 -0
- package/server/utils/cmsTree.ts +251 -0
- package/server/utils/cmsTreeAddress.ts +65 -0
- package/server/utils/cmsUpload.ts +228 -0
- package/server/utils/cmsWebhooks.ts +104 -0
- package/shared/json.ts +11 -0
- package/shared/richtext-editor.ts +56 -0
- package/shared/richtext-normalize.ts +33 -0
- package/shared/richtext-paste.ts +151 -0
- package/shared/storage-delivery.ts +53 -0
- package/src/blocks.ts +624 -0
- package/src/changes.ts +54 -0
- package/src/content-shape.ts +340 -0
- package/src/deprecate.ts +64 -0
- package/src/descriptor.ts +149 -0
- package/src/docs.ts +27 -0
- package/src/emitter.ts +94 -0
- package/src/entity.ts +624 -0
- package/src/errorReport.ts +41 -0
- package/src/fields.ts +465 -0
- package/src/i18n.ts +26 -0
- package/src/index.ts +54 -0
- package/src/linkref.ts +31 -0
- package/src/links.ts +179 -0
- package/src/locales.ts +39 -0
- package/src/media.ts +48 -0
- package/src/migrate.ts +236 -0
- package/src/openapi.ts +377 -0
- package/src/paths.ts +88 -0
- package/src/plugin.ts +505 -0
- package/src/presets.ts +230 -0
- package/src/richtext.ts +88 -0
- package/src/sdk.ts +181 -0
- package/src/search.ts +312 -0
- package/src/seed.ts +225 -0
- package/src/setupCode.ts +30 -0
- package/src/system.ts +219 -0
- package/src/tree.ts +421 -0
- package/src/upgrades.ts +137 -0
- package/starter/.env.example +10 -0
- package/starter/README.md +65 -0
- package/starter/app/app.config.ts +10 -0
- package/starter/app/app.vue +12 -0
- package/starter/app/assets/css/main.css +15 -0
- package/starter/app/components/global/BlockContact.vue +15 -0
- package/starter/app/components/global/BlockCta.vue +15 -0
- package/starter/app/components/global/BlockHero.vue +23 -0
- package/starter/app/components/global/BlockImage.vue +13 -0
- package/starter/app/components/global/BlockText.vue +12 -0
- package/starter/app/composables/useSite.ts +77 -0
- package/starter/app/error.vue +28 -0
- package/starter/app/layouts/default.vue +106 -0
- package/starter/app/lib/cms-content.ts +152 -0
- package/starter/app/pages/[...slug].vue +66 -0
- package/starter/app/pages/hledat.vue +59 -0
- package/starter/app/pages/index.vue +20 -0
- package/starter/cms.config.ts +137 -0
- package/starter/compose.yaml +15 -0
- package/starter/drizzle.config.ts +8 -0
- package/starter/gitignore.txt +8 -0
- package/starter/nuxt.config.ts +13 -0
- package/starter/package.json +38 -0
- package/starter/scripts/typecheck.mjs +38 -0
- package/starter/seed/index.ts +297 -0
- package/starter/seed/media/about.jpg +0 -0
- package/starter/seed/media/hero.jpg +0 -0
- package/starter/seed/media/logo.png +0 -0
- package/starter/seed/media/news-bread.jpg +0 -0
- package/starter/seed/media/news-morning.jpg +0 -0
- package/starter/server/db/migrations/0000_init.sql +269 -0
- package/starter/server/db/migrations/0001_page_tree.sql +5 -0
- package/starter/server/db/migrations/0002_opening_hours_per_language.sql +1 -0
- package/starter/server/db/migrations/meta/0000_snapshot.json +1890 -0
- package/starter/server/db/migrations/meta/0001_snapshot.json +1887 -0
- package/starter/server/db/migrations/meta/0002_snapshot.json +1893 -0
- package/starter/server/db/migrations/meta/_journal.json +27 -0
- package/starter/server/db/schema.ts +253 -0
- package/starter/server/plugins/sitemap.ts +11 -0
- package/starter/server/routes/robots.txt.get.ts +12 -0
- package/starter/tsconfig.json +9 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DropdownMenuItem } from '@nuxt/ui'
|
|
3
|
+
|
|
4
|
+
// Collection list. Quiet by design: the count sits next to the title, status tabs,
|
|
5
|
+
// filters and search share one bare row, the title cell carries the thumbnail and
|
|
6
|
+
// URL, the whole row opens the entry, and the rest lives behind one "…" menu.
|
|
7
|
+
// Search, filters, sort and page live in the address, so a list can be reloaded,
|
|
8
|
+
// shared or returned to as it was. Selecting rows offers bulk actions; collections
|
|
9
|
+
// with a manual order can be arranged by dragging.
|
|
10
|
+
definePageMeta({ layout: 'admin', key: (route) => route.path })
|
|
11
|
+
const route = useRoute()
|
|
12
|
+
const router = useRouter()
|
|
13
|
+
const toast = useToast()
|
|
14
|
+
const { t, tl, entityLabel, entitySingular, fieldLabel, formatNumber, formatDateWith } = useCmsI18n()
|
|
15
|
+
const entity = computed(() => route.params.entity as string)
|
|
16
|
+
|
|
17
|
+
const { data: graph } = await useFetch<any[]>('/api/cms/_graph', { key: 'cms-graph' })
|
|
18
|
+
const meta = computed(() => (graph.value ?? []).find((e: any) => e.name === entity.value))
|
|
19
|
+
const fieldOf = (key: string) => meta.value?.fields.find((f: any) => f.key === key)
|
|
20
|
+
const title = computed(() => entityLabel(meta.value) || entity.value)
|
|
21
|
+
useHead({ title })
|
|
22
|
+
const publish = computed(() => meta.value?.publish)
|
|
23
|
+
const orderField = computed(() => (meta.value?.orderField as string | null) ?? null)
|
|
24
|
+
|
|
25
|
+
// ── how this list looks (from the content, or admin.list.layout) ──
|
|
26
|
+
// table: rows · grid: picture cards (logos, albums) · dated: Upcoming / Past by date ·
|
|
27
|
+
// tree: pages under pages (CmsTreeList brings its own data, search and arranging)
|
|
28
|
+
const layout = computed<'table' | 'grid' | 'dated' | 'tree'>(() => meta.value?.listLayout ?? 'table')
|
|
29
|
+
const listColumns = computed<string[]>(() => meta.value?.listColumns ?? [])
|
|
30
|
+
const dateKey = computed(() => (layout.value === 'dated' ? listColumns.value.find((k) => fieldOf(k)?.type === 'datetime') : undefined))
|
|
31
|
+
|
|
32
|
+
// ── the list's state, from and to the address ──
|
|
33
|
+
const qs = (k: string) => (typeof route.query[k] === 'string' ? (route.query[k] as string) : '')
|
|
34
|
+
const limit = 20
|
|
35
|
+
const page = ref(Math.max(1, Number(qs('page')) || 1))
|
|
36
|
+
const q = ref(qs('q'))
|
|
37
|
+
const status = ref<'all' | 'published' | 'scheduled' | 'draft'>((['published', 'scheduled', 'draft'].includes(qs('status')) ? qs('status') : 'all') as any)
|
|
38
|
+
// Dated lists: what is coming (from today on, soonest first) or what has been.
|
|
39
|
+
const when = ref<'upcoming' | 'past'>(qs('when') === 'past' ? 'past' : 'upcoming')
|
|
40
|
+
const defaultSort = computed(() => dateKey.value ?? orderField.value ?? 'updatedAt')
|
|
41
|
+
const defaultDir = computed<'asc' | 'desc'>(() => (dateKey.value ? (when.value === 'past' ? 'desc' : 'asc') : orderField.value ? 'asc' : 'desc'))
|
|
42
|
+
const sort = ref(qs('sort') || defaultSort.value)
|
|
43
|
+
const dir = ref<'asc' | 'desc'>(qs('dir') === 'asc' || qs('dir') === 'desc' ? (qs('dir') as any) : defaultDir.value)
|
|
44
|
+
const filters = ref<Record<string, string>>(Object.fromEntries(Object.entries(route.query).filter(([k, v]) => k.startsWith('filter.') && typeof v === 'string')) as Record<string, string>)
|
|
45
|
+
watch([q, entity, status, filters], () => { page.value = 1 })
|
|
46
|
+
watch(when, () => {
|
|
47
|
+
page.value = 1
|
|
48
|
+
sort.value = defaultSort.value
|
|
49
|
+
dir.value = defaultDir.value
|
|
50
|
+
})
|
|
51
|
+
// Today, as a date: the same on the server and in the browser all day long.
|
|
52
|
+
const today = new Date().toISOString().slice(0, 10)
|
|
53
|
+
const dateRange = computed<Record<string, string>>(() => (dateKey.value
|
|
54
|
+
? { [`filter.${dateKey.value}.${when.value === 'past' ? 'to' : 'from'}`]: today }
|
|
55
|
+
: {}))
|
|
56
|
+
|
|
57
|
+
const listQuery = computed(() => ({
|
|
58
|
+
page: page.value, q: q.value || undefined, sort: sort.value, dir: dir.value, limit,
|
|
59
|
+
status: status.value === 'all' ? undefined : status.value, ...filters.value, ...dateRange.value,
|
|
60
|
+
}))
|
|
61
|
+
let urlTimer: ReturnType<typeof setTimeout> | null = null
|
|
62
|
+
watch(listQuery, (lq) => {
|
|
63
|
+
if (urlTimer) clearTimeout(urlTimer)
|
|
64
|
+
urlTimer = setTimeout(() => {
|
|
65
|
+
const query: Record<string, string> = {}
|
|
66
|
+
if (lq.page > 1) query.page = String(lq.page)
|
|
67
|
+
if (lq.q) query.q = lq.q
|
|
68
|
+
if (lq.status) query.status = lq.status
|
|
69
|
+
if (dateKey.value && when.value === 'past') query.when = 'past'
|
|
70
|
+
if (sort.value !== defaultSort.value) query.sort = sort.value
|
|
71
|
+
if (dir.value !== (sort.value === defaultSort.value ? defaultDir.value : 'desc')) query.dir = dir.value
|
|
72
|
+
Object.assign(query, filters.value)
|
|
73
|
+
router.replace({ query })
|
|
74
|
+
}, 300)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const { data, refresh, status: fetchStatus, error } = await useFetch<{ rows: Record<string, any>[]; total: number }>((): string => `/api/cms/${entity.value}`, {
|
|
78
|
+
query: listQuery,
|
|
79
|
+
watch: [entity],
|
|
80
|
+
})
|
|
81
|
+
// Someone else created, changed or deleted something here: refresh (a burst of
|
|
82
|
+
// changes, e.g. a bulk edit, refreshes once).
|
|
83
|
+
let liveRefresh: ReturnType<typeof setTimeout> | null = null
|
|
84
|
+
useCmsLiveTopic(`list:${entity.value}`, () => {
|
|
85
|
+
liveRefresh ??= setTimeout(() => {
|
|
86
|
+
liveRefresh = null
|
|
87
|
+
if (!arranging.value) refreshAll()
|
|
88
|
+
}, 400)
|
|
89
|
+
})
|
|
90
|
+
onBeforeUnmount(() => {
|
|
91
|
+
if (liveRefresh) clearTimeout(liveRefresh)
|
|
92
|
+
if (urlTimer) clearTimeout(urlTimer)
|
|
93
|
+
})
|
|
94
|
+
// "In progress": drafts and scheduled entries, above the list — what people come
|
|
95
|
+
// back for. Shown on the unfiltered first page of collections with drafts.
|
|
96
|
+
type Rows = { rows: Record<string, any>[]; total: number }
|
|
97
|
+
const progressQuery = (s: 'draft' | 'scheduled') => ({ status: s, limit: 4, sort: 'updatedAt', dir: 'desc' })
|
|
98
|
+
const draftsFetch = publish.value ? await useFetch<Rows>((): string => `/api/cms/${entity.value}`, { query: progressQuery('draft'), key: `cms-progress-draft:${entity.value}` }) : null
|
|
99
|
+
const scheduledFetch = publish.value?.dateField ? await useFetch<Rows>((): string => `/api/cms/${entity.value}`, { query: progressQuery('scheduled'), key: `cms-progress-scheduled:${entity.value}` }) : null
|
|
100
|
+
const inProgress = computed(() => [
|
|
101
|
+
...(draftsFetch?.data.value?.rows ?? []).map((row) => ({ row, kind: 'draft' as const })),
|
|
102
|
+
...(scheduledFetch?.data.value?.rows ?? []).map((row) => ({ row, kind: 'scheduled' as const })),
|
|
103
|
+
].slice(0, 4))
|
|
104
|
+
const showProgress = computed(() => inProgress.value.length > 0 && status.value === 'all' && !q.value && !Object.keys(filters.value).length && page.value === 1)
|
|
105
|
+
function refreshAll() {
|
|
106
|
+
refresh()
|
|
107
|
+
draftsFetch?.refresh()
|
|
108
|
+
scheduledFetch?.refresh()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const rows = computed(() => data.value?.rows ?? [])
|
|
112
|
+
const total = computed(() => data.value?.total ?? 0)
|
|
113
|
+
const pages = computed(() => Math.max(1, Math.ceil(total.value / limit)))
|
|
114
|
+
// Form submissions come from visitors: nothing to create here.
|
|
115
|
+
const canCreate = computed(() => meta.value?.can?.create !== false && meta.value?.adminCreate !== false)
|
|
116
|
+
const canDelete = computed(() => meta.value?.can?.delete !== false)
|
|
117
|
+
const canPublish = computed(() => !!publish.value && meta.value?.can?.publish !== false)
|
|
118
|
+
const narrowed = computed(() => !!q.value || status.value !== 'all' || Object.keys(filters.value).length > 0)
|
|
119
|
+
|
|
120
|
+
// ── filters: by field type (the publish status has its tabs) ──
|
|
121
|
+
const filterable = computed(() => (meta.value?.fields ?? []).filter((f: any) =>
|
|
122
|
+
f.key !== publish.value?.field && f.key !== orderField.value
|
|
123
|
+
&& (['select', 'boolean', 'media', 'datetime'].includes(f.type) || f.relation?.kind === 'many-to-one' || f.relation?.kind === 'many-to-many')
|
|
124
|
+
// A picture in the details panel (the sharing image) is not what people look for.
|
|
125
|
+
&& !(f.type === 'media' && f.meta?.position === 'sidebar')))
|
|
126
|
+
|
|
127
|
+
// ── columns (which ones show is remembered per collection, in this browser) ──
|
|
128
|
+
const titleKey = computed(() => meta.value?.titleField as string)
|
|
129
|
+
const configured = listColumns
|
|
130
|
+
const thumbKey = computed(() => configured.value.find((k) => fieldOf(k)?.type === 'media'))
|
|
131
|
+
const slugKey = computed(() => (meta.value?.fields ?? []).find((f: any) => f.type === 'slug')?.key as string | undefined)
|
|
132
|
+
const optionalCols = computed(() => configured.value.filter((k) => k !== titleKey.value && k !== thumbKey.value && k !== slugKey.value && k !== dateKey.value))
|
|
133
|
+
const hidden = ref<string[]>([])
|
|
134
|
+
const colsKey = computed(() => `cms:list-columns:${entity.value}`)
|
|
135
|
+
onMounted(() => {
|
|
136
|
+
try {
|
|
137
|
+
hidden.value = JSON.parse(localStorage.getItem(colsKey.value) || '[]')
|
|
138
|
+
}
|
|
139
|
+
catch { /* storage blocked: all columns */ }
|
|
140
|
+
})
|
|
141
|
+
function toggleColumn(key: string, show: boolean) {
|
|
142
|
+
hidden.value = show ? hidden.value.filter((k) => k !== key) : [...hidden.value, key]
|
|
143
|
+
try {
|
|
144
|
+
localStorage.setItem(colsKey.value, JSON.stringify(hidden.value))
|
|
145
|
+
}
|
|
146
|
+
catch { /* storage blocked: for this visit only */ }
|
|
147
|
+
}
|
|
148
|
+
const otherCols = computed(() => optionalCols.value.filter((k) => !hidden.value.includes(k)))
|
|
149
|
+
// On a phone the columns fold into one cell; a state-like column (a select shown as dot + word)
|
|
150
|
+
// stays in it, so a row never loses whether it is new, read or done.
|
|
151
|
+
const phoneState = computed(() => otherCols.value.find((k) => /^(status|state)$/i.test(k) && fieldOf(k)?.ui?.cell === 'CmsCellBadge')
|
|
152
|
+
?? otherCols.value.find((k) => fieldOf(k)?.ui?.cell === 'CmsCellBadge'))
|
|
153
|
+
const columnItems = computed<DropdownMenuItem[]>(() => [
|
|
154
|
+
{ type: 'label', label: t('list.columns') },
|
|
155
|
+
...optionalCols.value.map((k) => ({
|
|
156
|
+
type: 'checkbox' as const, label: fieldLabel(fieldOf(k)) || k, checked: !hidden.value.includes(k),
|
|
157
|
+
onUpdateChecked: (v: boolean) => toggleColumn(k, v), onSelect: (e: Event) => e.preventDefault(),
|
|
158
|
+
})),
|
|
159
|
+
])
|
|
160
|
+
|
|
161
|
+
function toggleSort(key: string) {
|
|
162
|
+
if (sort.value === key) dir.value = dir.value === 'asc' ? 'desc' : 'asc'
|
|
163
|
+
else { sort.value = key; dir.value = key === 'updatedAt' ? 'desc' : 'asc' }
|
|
164
|
+
}
|
|
165
|
+
const ariaSort = (key: string) => (sort.value === key ? (dir.value === 'asc' ? 'ascending' : 'descending') : undefined)
|
|
166
|
+
const rowTitle = (row: any) => (titleKey.value && row[titleKey.value]) || t('common.untitled')
|
|
167
|
+
const thumbOf = (row: any) => (thumbKey.value ? row[`${thumbKey.value}__media`] : null)
|
|
168
|
+
const range = computed(() => {
|
|
169
|
+
const from = total.value ? (page.value - 1) * limit + 1 : 0
|
|
170
|
+
return t('list.range', { from: formatNumber(from), to: formatNumber(Math.min(page.value * limit, total.value)), total: formatNumber(total.value) })
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// ── selection and bulk actions (each entry through its own rules) ──
|
|
174
|
+
const selected = ref<Set<string>>(new Set())
|
|
175
|
+
watch(rows, () => { selected.value = new Set([...selected.value].filter((id) => rows.value.some((r) => r.id === id))) })
|
|
176
|
+
const allSelected = computed(() => rows.value.length > 0 && rows.value.every((r) => selected.value.has(r.id)))
|
|
177
|
+
function toggleRow(id: string, on: boolean) {
|
|
178
|
+
const next = new Set(selected.value)
|
|
179
|
+
if (on) next.add(id)
|
|
180
|
+
else next.delete(id)
|
|
181
|
+
selected.value = next
|
|
182
|
+
}
|
|
183
|
+
function toggleAll(on: boolean) { selected.value = on ? new Set(rows.value.map((r) => r.id)) : new Set() }
|
|
184
|
+
const bulkBusy = ref(false)
|
|
185
|
+
const confirmBulkDelete = ref(false)
|
|
186
|
+
const selectedRows = computed(() => rows.value.filter((r) => selected.value.has(r.id)))
|
|
187
|
+
// Offer only what changes something: Publish when a draft is selected, Take off the
|
|
188
|
+
// website when something selected is on it.
|
|
189
|
+
const anyDraftSelected = computed(() => selectedRows.value.some((r) => !isLive(r)))
|
|
190
|
+
const anyLiveSelected = computed(() => selectedRows.value.some(isLive))
|
|
191
|
+
const confirm = useCmsConfirm()
|
|
192
|
+
const askUnpublish = (count: number) => confirm({
|
|
193
|
+
title: t('list.unpublishTitle', { count }), description: t('list.unpublishBody', { count }),
|
|
194
|
+
icon: 'i-lucide-eye-off', confirmLabel: t('editor.unpublish'), color: 'warning',
|
|
195
|
+
})
|
|
196
|
+
/** Publishing several at once skips each one's review: say which, before they go live. */
|
|
197
|
+
const askPublish = (rows: Record<string, any>[]) => confirm({
|
|
198
|
+
title: t('list.publishTitle', { count: rows.length }),
|
|
199
|
+
description: [
|
|
200
|
+
t('list.publishBody', { count: rows.length }),
|
|
201
|
+
...rows.slice(0, 5).map((r) => `• ${rowTitle(r)}`),
|
|
202
|
+
...(rows.length > 5 ? [t('list.andMore', { count: rows.length - 5 })] : []),
|
|
203
|
+
].join('\n'),
|
|
204
|
+
icon: 'i-lucide-globe', confirmLabel: t('editor.publish'), cancelLabel: t('common.cancel'), color: 'warning',
|
|
205
|
+
})
|
|
206
|
+
async function runBulk(action: 'publish' | 'unpublish' | 'delete') {
|
|
207
|
+
const p = publish.value
|
|
208
|
+
// Each entry only where it changes: publishing what is live already (or taking a
|
|
209
|
+
// draft off the website) would only count wrong in the message.
|
|
210
|
+
const targets = selectedRows.value.filter((r) => action === 'delete' || (action === 'publish' ? !isLive(r) : isLive(r)))
|
|
211
|
+
if (!targets.length) return
|
|
212
|
+
if (action === 'unpublish' && !await askUnpublish(targets.length)) return
|
|
213
|
+
if (action === 'publish' && !await askPublish(targets)) return
|
|
214
|
+
bulkBusy.value = true
|
|
215
|
+
let ok = 0
|
|
216
|
+
let failed = 0
|
|
217
|
+
for (const row of targets) {
|
|
218
|
+
try {
|
|
219
|
+
const url: string = `/api/cms/${entity.value}/${row.id}`
|
|
220
|
+
if (action === 'delete') await $fetch(url, { method: 'DELETE' })
|
|
221
|
+
else {
|
|
222
|
+
const body: Record<string, any> = { [p!.field]: action === 'publish' ? p!.publishedValue : p!.draftValue }
|
|
223
|
+
await $fetch(url, { method: 'PATCH', body })
|
|
224
|
+
}
|
|
225
|
+
ok++
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
failed++
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
bulkBusy.value = false
|
|
232
|
+
confirmBulkDelete.value = false
|
|
233
|
+
selected.value = new Set()
|
|
234
|
+
toast.add({
|
|
235
|
+
title: t(action === 'delete' ? 'list.bulkDeleted' : action === 'publish' ? 'list.bulkPublished' : 'list.bulkUnpublished', { count: ok }),
|
|
236
|
+
description: failed ? t('list.bulkFailed', { count: failed }) : undefined,
|
|
237
|
+
icon: failed ? 'i-lucide-triangle-alert' : 'i-lucide-check', color: failed ? 'warning' : 'success',
|
|
238
|
+
})
|
|
239
|
+
refreshAll()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ── manual order: drag rows (or move them with the keyboard), then save ──
|
|
243
|
+
const arranging = ref(false)
|
|
244
|
+
const arrangeRows = ref<any[]>([])
|
|
245
|
+
const arrangeTooMany = ref(false)
|
|
246
|
+
const savingOrder = ref(false)
|
|
247
|
+
async function startArrange() {
|
|
248
|
+
const res = await cmsFetch<{ rows: any[]; total: number }>(`/api/cms/${entity.value}`, { query: { sort: orderField.value, dir: 'asc', limit: 100 } })
|
|
249
|
+
arrangeTooMany.value = res.total > res.rows.length
|
|
250
|
+
arrangeRows.value = res.rows
|
|
251
|
+
arrangedFrom.value = res.rows.map((r) => r.id)
|
|
252
|
+
selected.value = new Set()
|
|
253
|
+
arranging.value = true
|
|
254
|
+
}
|
|
255
|
+
// A new order that was not saved yet is lost on leaving: ask, like an unsaved form.
|
|
256
|
+
const arrangedFrom = ref<string[]>([])
|
|
257
|
+
const orderChanged = computed(() => arranging.value && arrangeRows.value.map((r) => r.id).join() !== arrangedFrom.value.join())
|
|
258
|
+
async function askToLeaveOrder() {
|
|
259
|
+
if (!orderChanged.value) return true
|
|
260
|
+
return confirm({
|
|
261
|
+
title: t('list.orderUnsavedTitle'), description: t('list.orderUnsavedBody'), icon: 'i-lucide-arrow-up-down',
|
|
262
|
+
cancelLabel: t('editor.stay'), confirmLabel: t('editor.leave'), color: 'warning',
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
onBeforeRouteLeave(askToLeaveOrder)
|
|
266
|
+
onBeforeRouteUpdate((to, from) => (to.path !== from.path ? askToLeaveOrder() : true))
|
|
267
|
+
function onBeforeUnload(e: BeforeUnloadEvent) {
|
|
268
|
+
if (!orderChanged.value) return
|
|
269
|
+
e.preventDefault()
|
|
270
|
+
e.returnValue = ''
|
|
271
|
+
}
|
|
272
|
+
onMounted(() => window.addEventListener('beforeunload', onBeforeUnload))
|
|
273
|
+
onBeforeUnmount(() => window.removeEventListener('beforeunload', onBeforeUnload))
|
|
274
|
+
const dragFrom = ref<number | null>(null)
|
|
275
|
+
function onDragOver(i: number) {
|
|
276
|
+
const from = dragFrom.value
|
|
277
|
+
if (from === null || from === i) return
|
|
278
|
+
const list = [...arrangeRows.value]
|
|
279
|
+
const [moved] = list.splice(from, 1)
|
|
280
|
+
list.splice(i, 0, moved)
|
|
281
|
+
arrangeRows.value = list
|
|
282
|
+
dragFrom.value = i
|
|
283
|
+
}
|
|
284
|
+
function move(i: number, delta: number) {
|
|
285
|
+
const j = i + delta
|
|
286
|
+
if (j < 0 || j >= arrangeRows.value.length) return
|
|
287
|
+
const list = [...arrangeRows.value]
|
|
288
|
+
;[list[i], list[j]] = [list[j], list[i]]
|
|
289
|
+
arrangeRows.value = list
|
|
290
|
+
}
|
|
291
|
+
async function saveOrder() {
|
|
292
|
+
savingOrder.value = true
|
|
293
|
+
try {
|
|
294
|
+
await cmsFetch(`/api/cms/${entity.value}/_order`, { method: 'POST', body: { ids: arrangeRows.value.map((r) => r.id) } })
|
|
295
|
+
toast.add({ title: t('list.orderSaved'), icon: 'i-lucide-check', color: 'success' })
|
|
296
|
+
arrangedFrom.value = arrangeRows.value.map((r) => r.id)
|
|
297
|
+
arranging.value = false
|
|
298
|
+
sort.value = orderField.value!
|
|
299
|
+
dir.value = 'asc'
|
|
300
|
+
refresh()
|
|
301
|
+
}
|
|
302
|
+
catch (e: any) {
|
|
303
|
+
toast.add({ title: t('team.actionFailed'), description: e?.data?.statusMessage, icon: 'i-lucide-x', color: 'error' })
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
savingOrder.value = false
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ── row actions ──
|
|
311
|
+
async function setPublished(row: any, next: boolean) {
|
|
312
|
+
const p = publish.value
|
|
313
|
+
if (!p) return
|
|
314
|
+
if (!next && !await askUnpublish(1)) return
|
|
315
|
+
try {
|
|
316
|
+
const url: string = `/api/cms/${entity.value}/${row.id}`
|
|
317
|
+
const body: Record<string, any> = { [p.field]: next ? p.publishedValue : p.draftValue }
|
|
318
|
+
await $fetch(url, { method: 'PATCH', body })
|
|
319
|
+
toast.add({ title: next ? t('editor.publishedToast') : t('editor.unpublishedToast'), icon: 'i-lucide-check', color: 'success' })
|
|
320
|
+
refreshAll()
|
|
321
|
+
}
|
|
322
|
+
catch (e: any) {
|
|
323
|
+
toast.add({ title: t('team.actionFailed'), description: e.data?.statusMessage, icon: 'i-lucide-x', color: 'error' })
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function rowMenu(row: any): DropdownMenuItem[][] {
|
|
327
|
+
const groups: DropdownMenuItem[][] = []
|
|
328
|
+
const p = publish.value
|
|
329
|
+
if (p && meta.value?.can?.publish !== false) {
|
|
330
|
+
const live = row[p.field] === p.publishedValue
|
|
331
|
+
groups.push([live
|
|
332
|
+
? { label: t('editor.unpublish'), icon: 'i-lucide-eye-off', onSelect: () => setPublished(row, false) }
|
|
333
|
+
: { label: t('editor.publish'), icon: 'i-lucide-globe', onSelect: () => setPublished(row, true) }])
|
|
334
|
+
}
|
|
335
|
+
const entry: DropdownMenuItem[] = []
|
|
336
|
+
const path = rowPublicPath(row)
|
|
337
|
+
if (path && (!p || isLive(row))) entry.push({ label: t('editor.viewOnSite'), icon: 'i-lucide-arrow-up-right', to: path, target: '_blank' })
|
|
338
|
+
if (meta.value?.can?.create !== false && !meta.value?.singleton) entry.push({ label: t('editor.duplicate'), icon: 'i-lucide-copy', onSelect: () => duplicateRow(row) })
|
|
339
|
+
if (entry.length) groups.push(entry)
|
|
340
|
+
if (meta.value?.can?.delete !== false) {
|
|
341
|
+
groups.push([{ label: t('editor.delete'), icon: 'i-lucide-trash-2', color: 'error' as const, onSelect: () => deleteRow(row) }])
|
|
342
|
+
}
|
|
343
|
+
return groups
|
|
344
|
+
}
|
|
345
|
+
const entryActions = useCmsEntryActions()
|
|
346
|
+
// The CSV holds what the list shows: the same search, status tab and filters.
|
|
347
|
+
const exportHref = computed(() => {
|
|
348
|
+
const params = new URLSearchParams()
|
|
349
|
+
for (const [k, v] of Object.entries(route.query)) {
|
|
350
|
+
if ((k === 'q' || k === 'status' || k.startsWith('filter.')) && typeof v === 'string' && v) params.set(k, v)
|
|
351
|
+
}
|
|
352
|
+
const qs = params.toString()
|
|
353
|
+
return `/api/cms/${entity.value}/_export${qs ? '?' + qs : ''}`
|
|
354
|
+
})
|
|
355
|
+
async function duplicateRow(row: any) {
|
|
356
|
+
const copy = await entryActions.duplicate(entity.value, meta.value, row.id)
|
|
357
|
+
if (copy) await router.push(`/admin/${entity.value}/${copy}`)
|
|
358
|
+
}
|
|
359
|
+
async function deleteRow(row: any) {
|
|
360
|
+
if (await entryActions.remove(entity.value, meta.value, row.id, rowTitle(row))) refreshAll()
|
|
361
|
+
}
|
|
362
|
+
/** The entry's address on the website, in the default language (from the preview template). */
|
|
363
|
+
function rowPublicPath(row: any): string | null {
|
|
364
|
+
const paths: Record<string, string> | null = meta.value?.previewPaths ?? null
|
|
365
|
+
if (!paths) return null
|
|
366
|
+
const template = paths[meta.value?.locales?.default ?? ''] ?? Object.values(paths)[0]
|
|
367
|
+
if (!template) return null
|
|
368
|
+
let ok = true
|
|
369
|
+
const out = template.replace(/:(\w+)/g, (_m: string, k: string) => {
|
|
370
|
+
const v = row[k]
|
|
371
|
+
if (v === undefined || v === null || v === '') ok = false
|
|
372
|
+
return encodeURIComponent(String(v ?? ''))
|
|
373
|
+
})
|
|
374
|
+
return ok ? out : null
|
|
375
|
+
}
|
|
376
|
+
// Translations: name only what is missing ("EN missing"), nothing when all are there.
|
|
377
|
+
const missingLocales = (row: any) => (meta.value?.locales?.all ?? []).filter((code: string) => !(row.__locales ?? []).includes(code))
|
|
378
|
+
const isLive = (row: any) => !!publish.value && row[publish.value.field] === publish.value.publishedValue
|
|
379
|
+
// Grid: pictures that are the content (album covers) fill the card; logos sit whole on a light tile.
|
|
380
|
+
const gridFill = computed(() => !!publish.value)
|
|
381
|
+
// Dated lists, grouped by month.
|
|
382
|
+
const monthGroups = computed(() => {
|
|
383
|
+
const out: { label: string; rows: any[] }[] = []
|
|
384
|
+
for (const row of rows.value) {
|
|
385
|
+
const label = dateKey.value && row[dateKey.value] ? formatDateWith(row[dateKey.value], { month: 'long', year: 'numeric' }) : t('common.none')
|
|
386
|
+
const last = out[out.length - 1]
|
|
387
|
+
if (last?.label === label) last.rows.push(row)
|
|
388
|
+
else out.push({ label, rows: [row] })
|
|
389
|
+
}
|
|
390
|
+
return out
|
|
391
|
+
})
|
|
392
|
+
const leaf = (d: any) => ({
|
|
393
|
+
day: formatDateWith(d, { day: 'numeric' }).replace('.', ''),
|
|
394
|
+
month: formatDateWith(d, { month: 'short' }).replace('.', ''),
|
|
395
|
+
})
|
|
396
|
+
const whenTabs = computed(() => [
|
|
397
|
+
{ value: 'upcoming', label: t('list.upcoming') },
|
|
398
|
+
{ value: 'past', label: t('list.past') },
|
|
399
|
+
])
|
|
400
|
+
|
|
401
|
+
const tabs = computed(() => [
|
|
402
|
+
{ value: 'all', label: t('list.all') },
|
|
403
|
+
{ value: 'published', label: t('editor.published') },
|
|
404
|
+
...(publish.value?.dateField ? [{ value: 'scheduled', label: t('editor.scheduled') }] : []),
|
|
405
|
+
{ value: 'draft', label: t('editor.draft') },
|
|
406
|
+
])
|
|
407
|
+
</script>
|
|
408
|
+
|
|
409
|
+
<template>
|
|
410
|
+
<CmsPage v-if="graph && !meta" :title="t('nav.notFoundTitle')">
|
|
411
|
+
<CmsEmptyState variant="no-results" icon="i-lucide-map-pin-off" :title="t('nav.notFoundTitle')" :description="t('nav.notFoundBody')">
|
|
412
|
+
<template #actions>
|
|
413
|
+
<UButton to="/admin" color="neutral" variant="outline" icon="i-lucide-house">{{ t('nav.home') }}</UButton>
|
|
414
|
+
</template>
|
|
415
|
+
</CmsEmptyState>
|
|
416
|
+
</CmsPage>
|
|
417
|
+
<!-- another language is another form (its own values, version and shared text): rebuilt, not patched -->
|
|
418
|
+
<CmsSingletonForm v-else-if="meta?.singleton" :key="`${entity}:${route.query.locale ?? ''}`" :entity="entity" :meta="meta" />
|
|
419
|
+
<CmsPage
|
|
420
|
+
v-else :title="title" :description="tl(meta?.description) || undefined"
|
|
421
|
+
:breadcrumbs="[{ label: t('nav.home'), to: '/admin' }, { label: title }]"
|
|
422
|
+
>
|
|
423
|
+
<template #badge>
|
|
424
|
+
<span v-if="total && !dateKey" class="cms-display text-[1.75rem] leading-tight text-dimmed tabular-nums">{{ formatNumber(total) }}</span>
|
|
425
|
+
</template>
|
|
426
|
+
<template #actions>
|
|
427
|
+
<UTooltip :text="t('list.exportHint')">
|
|
428
|
+
<UButton
|
|
429
|
+
:href="exportHref" download external color="neutral" variant="ghost" icon="i-lucide-download"
|
|
430
|
+
:aria-label="t('list.exportNamed', { label: title })"
|
|
431
|
+
><span class="max-md:hidden">{{ t('list.export') }}</span></UButton>
|
|
432
|
+
</UTooltip>
|
|
433
|
+
<UButton v-if="canCreate" :to="`/admin/${entity}/new`" icon="i-lucide-plus" :aria-label="t('editor.newTitle', { label: entitySingular(meta).toLowerCase() })">
|
|
434
|
+
<span class="max-sm:sr-only">{{ entitySingular(meta) }}</span>
|
|
435
|
+
</UButton>
|
|
436
|
+
</template>
|
|
437
|
+
|
|
438
|
+
<!-- a page tree: indented pages, dragged or moved into place -->
|
|
439
|
+
<CmsTreeList v-if="layout === 'tree'" :entity="entity" :meta="meta" :can-create="canCreate" />
|
|
440
|
+
|
|
441
|
+
<template v-else>
|
|
442
|
+
<!-- In progress: drafts and scheduled entries, what people come back for -->
|
|
443
|
+
<section v-if="showProgress && !arranging" class="mb-8 max-sm:hidden" :aria-label="t('list.inProgress')">
|
|
444
|
+
<h2 class="cms-label mb-2">{{ t('list.inProgress') }}</h2>
|
|
445
|
+
<ul class="grid grid-cols-1 gap-2.5 sm:grid-cols-2">
|
|
446
|
+
<li v-for="p in inProgress" :key="p.row.id" class="cms-card relative flex min-w-0 items-center gap-3 p-3 hover:border-accented transition-colors">
|
|
447
|
+
<img
|
|
448
|
+
v-if="thumbOf(p.row)?.url" :src="thumbOf(p.row).url" alt="" loading="lazy" decoding="async"
|
|
449
|
+
class="size-11 shrink-0 rounded-md object-cover border border-default"
|
|
450
|
+
>
|
|
451
|
+
<div v-else-if="thumbKey" class="size-11 shrink-0 rounded-md bg-elevated" />
|
|
452
|
+
<div class="min-w-0 flex-1">
|
|
453
|
+
<NuxtLink :to="`/admin/${entity}/${p.row.id}`" class="block truncate text-sm font-medium text-highlighted after:absolute after:inset-0">{{ rowTitle(p.row) }}</NuxtLink>
|
|
454
|
+
<p class="truncate text-xs text-muted flex items-center gap-1.5">
|
|
455
|
+
<CmsStatusBadge :published="p.kind === 'scheduled'" :scheduled-for="publish?.dateField ? p.row[publish.dateField] : null" class="!text-xs" />
|
|
456
|
+
<span aria-hidden="true">·</span>
|
|
457
|
+
<CmsTime :value="p.row.updatedAt" relative />
|
|
458
|
+
</p>
|
|
459
|
+
</div>
|
|
460
|
+
<UButton
|
|
461
|
+
:to="`/admin/${entity}/${p.row.id}`" size="sm" class="relative shrink-0 max-sm:hidden"
|
|
462
|
+
:color="p.kind === 'draft' ? 'primary' : 'neutral'" :variant="p.kind === 'draft' ? 'solid' : 'outline'"
|
|
463
|
+
>{{ p.kind === 'draft' ? t('home.finish') : t('common.edit') }}</UButton>
|
|
464
|
+
</li>
|
|
465
|
+
</ul>
|
|
466
|
+
</section>
|
|
467
|
+
|
|
468
|
+
<!-- arranging: the hint and save; with rows selected: bulk actions; else: tabs, filters, search -->
|
|
469
|
+
<div v-if="arranging" class="flex flex-wrap items-center justify-between gap-3 mb-3 min-h-8">
|
|
470
|
+
<p class="text-sm text-muted">{{ t('list.arrangeHint') }}</p>
|
|
471
|
+
<div class="flex gap-2">
|
|
472
|
+
<UButton color="neutral" variant="ghost" size="sm" @click="arranging = false">{{ t('common.cancel') }}</UButton>
|
|
473
|
+
<UButton size="sm" icon="i-lucide-check" :loading="savingOrder" :disabled="arrangeTooMany" @click="saveOrder">{{ t('list.saveOrder') }}</UButton>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
<div v-else-if="selected.size" class="sticky top-0 z-20 flex flex-wrap items-center gap-2 mb-3 min-h-8 py-2 -mt-2 bg-(--cms-page-bg) border-b border-default" role="toolbar" :aria-label="t('list.bulkActions')">
|
|
477
|
+
<span class="text-sm text-highlighted tabular-nums mr-2">{{ t('list.selected', { count: selected.size }) }}</span>
|
|
478
|
+
<UButton v-if="canPublish && anyDraftSelected" size="sm" color="neutral" variant="outline" icon="i-lucide-globe" :loading="bulkBusy" @click="runBulk('publish')">{{ t('editor.publish') }}</UButton>
|
|
479
|
+
<UButton v-if="canPublish && anyLiveSelected" size="sm" color="neutral" variant="outline" icon="i-lucide-eye-off" :disabled="bulkBusy" @click="runBulk('unpublish')">{{ t('editor.unpublish') }}</UButton>
|
|
480
|
+
<UButton v-if="canDelete" size="sm" color="error" variant="ghost" icon="i-lucide-trash-2" :disabled="bulkBusy" @click="confirmBulkDelete = true">{{ t('common.delete') }}</UButton>
|
|
481
|
+
<UButton size="sm" color="neutral" variant="link" @click="toggleAll(false)">{{ t('list.clearSelection') }}</UButton>
|
|
482
|
+
</div>
|
|
483
|
+
<div v-else class="flex flex-wrap items-center justify-between gap-x-3 gap-y-2 mb-3">
|
|
484
|
+
<div class="cms-scroll-x flex items-center gap-x-4 gap-y-2 min-w-0 max-w-full">
|
|
485
|
+
<UTabs
|
|
486
|
+
v-if="dateKey" v-model="when" :items="whenTabs" :content="false" variant="link" size="sm"
|
|
487
|
+
:ui="{ list: 'border-0 gap-4', trigger: 'px-0' }"
|
|
488
|
+
/>
|
|
489
|
+
<UTabs
|
|
490
|
+
v-else-if="publish" v-model="status" :items="tabs" :content="false" variant="link" size="sm"
|
|
491
|
+
:ui="{ list: 'border-0 gap-4', trigger: 'px-0 whitespace-nowrap' }"
|
|
492
|
+
/>
|
|
493
|
+
<CmsListFilters v-if="filterable.length" v-model="filters" :fields="filterable" />
|
|
494
|
+
</div>
|
|
495
|
+
<div class="flex items-center gap-1 w-full sm:w-auto">
|
|
496
|
+
<UInput
|
|
497
|
+
v-model="q" icon="i-lucide-search" :placeholder="t('common.search')" :loading="fetchStatus === 'pending'"
|
|
498
|
+
size="sm" variant="ghost" class="w-full sm:w-64" :aria-label="t('common.search')"
|
|
499
|
+
>
|
|
500
|
+
<template v-if="q" #trailing>
|
|
501
|
+
<UButton color="neutral" variant="link" size="xs" icon="i-lucide-x" :aria-label="t('common.clear')" @click="q = ''" />
|
|
502
|
+
</template>
|
|
503
|
+
</UInput>
|
|
504
|
+
<UDropdownMenu v-if="optionalCols.length && layout === 'table'" :items="columnItems" :content="{ align: 'end' }">
|
|
505
|
+
<UButton color="neutral" variant="ghost" size="sm" icon="i-lucide-columns-3" :aria-label="t('list.columns')" class="max-sm:hidden" />
|
|
506
|
+
</UDropdownMenu>
|
|
507
|
+
<UTooltip v-if="orderField && meta?.can?.update !== false" :text="t('list.arrange')">
|
|
508
|
+
<UButton color="neutral" variant="ghost" size="sm" icon="i-lucide-arrow-up-down" :aria-label="t('list.arrange')" @click="startArrange" />
|
|
509
|
+
</UTooltip>
|
|
510
|
+
</div>
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
<div :class="layout === 'grid' && !arranging && rows.length ? '' : 'cms-card overflow-hidden'">
|
|
514
|
+
<ol v-if="arranging" :aria-label="t('list.arrange')">
|
|
515
|
+
<li
|
|
516
|
+
v-for="(row, i) in arrangeRows" :key="row.id" draggable="true"
|
|
517
|
+
class="flex items-center gap-3 px-4 py-2.5 border-b border-default last:border-0"
|
|
518
|
+
:class="dragFrom === i ? 'bg-elevated' : ''"
|
|
519
|
+
@dragstart="dragFrom = i" @dragover.prevent="onDragOver(i)" @dragend="dragFrom = null" @drop.prevent="dragFrom = null"
|
|
520
|
+
>
|
|
521
|
+
<UIcon name="i-lucide-grip-vertical" class="size-4 shrink-0 text-dimmed cursor-grab" aria-hidden="true" />
|
|
522
|
+
<span class="w-6 shrink-0 text-xs text-dimmed tabular-nums">{{ i + 1 }}</span>
|
|
523
|
+
<img v-if="thumbOf(row)?.url" :src="thumbOf(row).url" alt="" class="size-8 shrink-0 rounded object-contain bg-white border border-default">
|
|
524
|
+
<span class="flex-1 min-w-0 truncate text-sm text-highlighted">{{ rowTitle(row) }}</span>
|
|
525
|
+
<UButton size="xs" color="neutral" variant="ghost" icon="i-lucide-arrow-up" :disabled="i === 0" :aria-label="t('list.moveUp', { name: rowTitle(row) })" @click="move(i, -1)" />
|
|
526
|
+
<UButton size="xs" color="neutral" variant="ghost" icon="i-lucide-arrow-down" :disabled="i === arrangeRows.length - 1" :aria-label="t('list.moveDown', { name: rowTitle(row) })" @click="move(i, 1)" />
|
|
527
|
+
</li>
|
|
528
|
+
<li v-if="arrangeTooMany" class="px-4 py-2.5 text-xs text-muted">{{ t('list.arrangeTooMany') }}</li>
|
|
529
|
+
</ol>
|
|
530
|
+
<CmsLoadError v-else-if="error" :error="error" @retry="refresh()" />
|
|
531
|
+
|
|
532
|
+
<CmsEmptyState
|
|
533
|
+
v-else-if="!rows.length && fetchStatus !== 'pending' && narrowed"
|
|
534
|
+
variant="no-results" :title="q ? t('list.noResultsTitle', { q }) : t('list.emptyTitle', { label: title.toLowerCase() })"
|
|
535
|
+
:description="q ? t('list.noResultsDescription') : undefined"
|
|
536
|
+
>
|
|
537
|
+
<template v-if="q" #actions>
|
|
538
|
+
<UButton color="neutral" variant="outline" @click="q = ''">{{ t('list.clearSearch') }}</UButton>
|
|
539
|
+
</template>
|
|
540
|
+
</CmsEmptyState>
|
|
541
|
+
|
|
542
|
+
<CmsEmptyState
|
|
543
|
+
v-else-if="!rows.length && fetchStatus !== 'pending' && dateKey && when === 'upcoming'"
|
|
544
|
+
variant="no-results" :title="t('list.nothingUpcoming')" :description="t('list.nothingUpcomingBody')"
|
|
545
|
+
>
|
|
546
|
+
<template v-if="canCreate" #actions>
|
|
547
|
+
<UButton :to="`/admin/${entity}/new`" icon="i-lucide-plus">{{ entitySingular(meta) }}</UButton>
|
|
548
|
+
</template>
|
|
549
|
+
</CmsEmptyState>
|
|
550
|
+
|
|
551
|
+
<CmsEmptyState
|
|
552
|
+
v-else-if="!rows.length && fetchStatus !== 'pending'"
|
|
553
|
+
:icon="meta?.icon" :character="entity" :title="t('list.emptyTitle', { label: title.toLowerCase() })"
|
|
554
|
+
:description="tl(meta?.description) || t('list.emptyDescription')"
|
|
555
|
+
>
|
|
556
|
+
<template v-if="canCreate" #actions>
|
|
557
|
+
<UButton :to="`/admin/${entity}/new`" icon="i-lucide-plus">{{ t('list.emptyAction') }}</UButton>
|
|
558
|
+
</template>
|
|
559
|
+
</CmsEmptyState>
|
|
560
|
+
|
|
561
|
+
<!-- grid: the picture is the point (logos, albums) -->
|
|
562
|
+
<ul v-else-if="layout === 'grid'" class="grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4">
|
|
563
|
+
<li v-for="row in rows" :key="row.id" class="cms-card group relative overflow-hidden p-2.5 hover:border-accented transition-colors">
|
|
564
|
+
<div class="aspect-[4/3] overflow-hidden rounded-lg" :class="gridFill ? 'bg-elevated' : 'bg-[#F7F7F5]'">
|
|
565
|
+
<img
|
|
566
|
+
v-if="thumbOf(row)?.url" :src="thumbOf(row).url" :alt="''" loading="lazy" decoding="async"
|
|
567
|
+
class="size-full" :class="gridFill ? 'object-cover' : 'object-contain p-4'"
|
|
568
|
+
>
|
|
569
|
+
<!-- no picture yet: the name stands in, as it does on the website -->
|
|
570
|
+
<div v-else class="size-full grid place-items-center px-4 text-center cms-display text-base text-muted">
|
|
571
|
+
{{ rowTitle(row) }}
|
|
572
|
+
</div>
|
|
573
|
+
</div>
|
|
574
|
+
<div class="flex items-start justify-between gap-2 pt-2.5 px-0.5">
|
|
575
|
+
<div class="min-w-0">
|
|
576
|
+
<NuxtLink :to="`/admin/${entity}/${row.id}`" class="block truncate text-sm font-medium text-highlighted after:absolute after:inset-0" :aria-label="t('list.openItem', { name: rowTitle(row) })">{{ rowTitle(row) }}</NuxtLink>
|
|
577
|
+
<p class="truncate text-xs text-muted flex items-center gap-1.5">
|
|
578
|
+
<CmsStatusBadge v-if="publish" :published="isLive(row)" :scheduled-for="publish.dateField ? row[publish.dateField] : null" class="!text-xs" />
|
|
579
|
+
<template v-else-if="otherCols[0] && fieldOf(otherCols[0]) && row[otherCols[0]]"><CmsCell :field="fieldOf(otherCols[0])" :row="row" :entity="entity" /></template>
|
|
580
|
+
</p>
|
|
581
|
+
</div>
|
|
582
|
+
<UDropdownMenu v-if="rowMenu(row).length" :items="rowMenu(row)" :content="{ align: 'end' }">
|
|
583
|
+
<UButton class="relative z-10 -mr-1 -mt-0.5" color="neutral" variant="ghost" size="xs" icon="i-lucide-ellipsis" :aria-label="t('editor.moreActions')" />
|
|
584
|
+
</UDropdownMenu>
|
|
585
|
+
</div>
|
|
586
|
+
</li>
|
|
587
|
+
</ul>
|
|
588
|
+
|
|
589
|
+
<!-- dated: Upcoming / Past, by month, the date first -->
|
|
590
|
+
<div v-else-if="dateKey">
|
|
591
|
+
<section v-for="g in monthGroups" :key="g.label">
|
|
592
|
+
<h3 class="px-4 pt-3 pb-1.5 text-xs font-medium text-muted first-letter:uppercase bg-(--cms-sunken) border-b border-(--ui-border-muted)">{{ g.label }}</h3>
|
|
593
|
+
<ul>
|
|
594
|
+
<li v-for="row in g.rows" :key="row.id" class="relative flex items-center gap-3 px-4 py-3 border-b border-(--ui-border-muted) last:border-0 hover:bg-elevated/40 transition-colors">
|
|
595
|
+
<span class="cms-date"><b>{{ leaf(row[dateKey]).day }}</b><span>{{ leaf(row[dateKey]).month }}</span></span>
|
|
596
|
+
<div class="min-w-0 flex-1">
|
|
597
|
+
<NuxtLink :to="`/admin/${entity}/${row.id}`" class="block truncate text-sm font-medium text-highlighted after:absolute after:inset-0" :aria-label="t('list.openItem', { name: rowTitle(row) })">{{ rowTitle(row) }}</NuxtLink>
|
|
598
|
+
<p class="truncate text-xs text-muted">
|
|
599
|
+
<template v-for="(key, k) in otherCols" :key="key">
|
|
600
|
+
<span v-if="k" aria-hidden="true"> · </span><CmsCell v-if="fieldOf(key)" :field="fieldOf(key)" :row="row" :entity="entity" />
|
|
601
|
+
</template>
|
|
602
|
+
</p>
|
|
603
|
+
</div>
|
|
604
|
+
<UDropdownMenu v-if="rowMenu(row).length" :items="rowMenu(row)" :content="{ align: 'end' }">
|
|
605
|
+
<UButton class="relative z-10" color="neutral" variant="ghost" size="sm" icon="i-lucide-ellipsis" :aria-label="t('editor.moreActions')" />
|
|
606
|
+
</UDropdownMenu>
|
|
607
|
+
</li>
|
|
608
|
+
</ul>
|
|
609
|
+
</section>
|
|
610
|
+
</div>
|
|
611
|
+
|
|
612
|
+
<!-- table -->
|
|
613
|
+
<div v-else class="overflow-x-auto">
|
|
614
|
+
<table class="w-full text-sm">
|
|
615
|
+
<thead class="max-sm:hidden">
|
|
616
|
+
<tr class="border-b border-default text-muted">
|
|
617
|
+
<th scope="col" class="w-10 pl-4 max-sm:hidden">
|
|
618
|
+
<UCheckbox :model-value="allSelected" :aria-label="t('list.selectAll')" @update:model-value="(v: any) => toggleAll(!!v)" />
|
|
619
|
+
</th>
|
|
620
|
+
<th scope="col" :aria-sort="ariaSort(titleKey)" class="text-left font-medium px-4 py-2.5">
|
|
621
|
+
<button type="button" class="inline-flex items-center gap-1 hover:text-highlighted" @click="toggleSort(titleKey)">
|
|
622
|
+
{{ fieldLabel(fieldOf(titleKey)) }}
|
|
623
|
+
<UIcon v-if="sort === titleKey" :name="dir === 'asc' ? 'i-lucide-arrow-up' : 'i-lucide-arrow-down'" class="size-3.5" />
|
|
624
|
+
</button>
|
|
625
|
+
</th>
|
|
626
|
+
<th v-for="key in otherCols" :key="key" scope="col" :aria-sort="ariaSort(key)" class="text-left font-medium px-4 py-2.5 whitespace-nowrap max-md:hidden">
|
|
627
|
+
<button type="button" class="inline-flex items-center gap-1 hover:text-highlighted" @click="toggleSort(key)">
|
|
628
|
+
{{ fieldLabel(fieldOf(key)) || key }}
|
|
629
|
+
<UIcon v-if="sort === key" :name="dir === 'asc' ? 'i-lucide-arrow-up' : 'i-lucide-arrow-down'" class="size-3.5" />
|
|
630
|
+
</button>
|
|
631
|
+
</th>
|
|
632
|
+
<th v-if="meta?.locales" scope="col" class="text-left font-medium px-4 py-2.5 whitespace-nowrap max-lg:hidden">{{ t('translation.languages') }}</th>
|
|
633
|
+
<th scope="col" :aria-sort="ariaSort('updatedAt')" class="text-right font-medium px-4 py-2.5 whitespace-nowrap max-sm:hidden">
|
|
634
|
+
<button type="button" class="inline-flex items-center gap-1 hover:text-highlighted" @click="toggleSort('updatedAt')">
|
|
635
|
+
{{ t('list.updated') }}
|
|
636
|
+
<UIcon v-if="sort === 'updatedAt'" :name="dir === 'asc' ? 'i-lucide-arrow-up' : 'i-lucide-arrow-down'" class="size-3.5" />
|
|
637
|
+
</button>
|
|
638
|
+
</th>
|
|
639
|
+
<th class="w-12"><span class="sr-only">{{ t('editor.moreActions') }}</span></th>
|
|
640
|
+
</tr>
|
|
641
|
+
</thead>
|
|
642
|
+
<tbody>
|
|
643
|
+
<tr
|
|
644
|
+
v-for="row in rows" :key="row.id"
|
|
645
|
+
class="relative border-b border-(--ui-border-muted) last:border-0 hover:bg-elevated/40 transition-colors cursor-pointer"
|
|
646
|
+
>
|
|
647
|
+
<td class="relative z-10 w-10 pl-4 max-sm:hidden">
|
|
648
|
+
<UCheckbox :model-value="selected.has(row.id)" :aria-label="t('list.selectItem', { name: rowTitle(row) })" @update:model-value="(v: any) => toggleRow(row.id, !!v)" />
|
|
649
|
+
</td>
|
|
650
|
+
<td class="px-4 py-3 w-full max-w-0 sm:min-w-56">
|
|
651
|
+
<!-- one stretched link makes the whole row open the entry -->
|
|
652
|
+
<NuxtLink :to="`/admin/${entity}/${row.id}`" class="absolute inset-0" :aria-label="t('list.openItem', { name: rowTitle(row) })" />
|
|
653
|
+
<div class="flex items-center gap-3 min-w-0">
|
|
654
|
+
<img
|
|
655
|
+
v-if="thumbOf(row)?.url" :src="thumbOf(row).url" alt="" loading="lazy" decoding="async"
|
|
656
|
+
class="size-10 shrink-0 rounded-md object-cover border border-default"
|
|
657
|
+
>
|
|
658
|
+
<div v-else-if="thumbKey" class="size-10 shrink-0 rounded-md bg-elevated" />
|
|
659
|
+
<div class="min-w-0">
|
|
660
|
+
<div class="font-medium text-highlighted truncate">{{ rowTitle(row) }}</div>
|
|
661
|
+
<div v-if="slugKey && row[slugKey]" class="text-xs text-muted truncate max-sm:hidden">/{{ row[slugKey] }}</div>
|
|
662
|
+
<!-- phones: the essentials in one line under the title -->
|
|
663
|
+
<div class="sm:hidden text-xs text-muted flex items-center gap-1.5 min-w-0">
|
|
664
|
+
<CmsStatusBadge v-if="publish" :published="isLive(row)" :scheduled-for="publish.dateField ? row[publish.dateField] : null" class="!text-xs shrink-0" />
|
|
665
|
+
<!-- no publishing here (form messages): the row's own state — new, read, done — still shows -->
|
|
666
|
+
<CmsCell v-else-if="phoneState" :field="fieldOf(phoneState)" :row="row" :entity="entity" class="!text-xs shrink-0" />
|
|
667
|
+
<span v-if="publish || (phoneState && row[phoneState])" aria-hidden="true">·</span>
|
|
668
|
+
<CmsTime :value="row.updatedAt" relative class="truncate" />
|
|
669
|
+
</div>
|
|
670
|
+
</div>
|
|
671
|
+
</div>
|
|
672
|
+
</td>
|
|
673
|
+
<td v-for="key in otherCols" :key="key" class="px-4 py-3 whitespace-nowrap max-md:hidden">
|
|
674
|
+
<CmsStatusBadge
|
|
675
|
+
v-if="publish && key === publish.field" :published="isLive(row)"
|
|
676
|
+
:scheduled-for="publish.dateField ? row[publish.dateField] : null"
|
|
677
|
+
/>
|
|
678
|
+
<CmsCell v-else-if="fieldOf(key)" :field="fieldOf(key)" :row="row" :entity="entity" />
|
|
679
|
+
<span v-else>{{ row[key] ?? t('common.none') }}</span>
|
|
680
|
+
</td>
|
|
681
|
+
<td v-if="meta?.locales" class="px-4 py-3 whitespace-nowrap max-lg:hidden">
|
|
682
|
+
<span v-if="missingLocales(row).length" class="inline-flex items-center rounded-full bg-warning/10 px-2 py-0.5 text-xs font-medium cms-unsaved">
|
|
683
|
+
{{ t('translation.missing', { lang: missingLocales(row).map((c: string) => c.toUpperCase()).join(', ') }) }}
|
|
684
|
+
</span>
|
|
685
|
+
<span v-else class="text-xs text-dimmed">{{ t('translation.complete') }}</span>
|
|
686
|
+
</td>
|
|
687
|
+
<td class="px-4 py-3 text-right text-muted whitespace-nowrap max-sm:hidden">
|
|
688
|
+
<CmsTime :value="row.updatedAt" relative />
|
|
689
|
+
</td>
|
|
690
|
+
<td class="px-2 py-3 text-right">
|
|
691
|
+
<UDropdownMenu v-if="rowMenu(row).length" :items="rowMenu(row)" :content="{ align: 'end' }">
|
|
692
|
+
<UButton class="relative z-10" color="neutral" variant="ghost" size="sm" icon="i-lucide-ellipsis" :aria-label="t('editor.moreActions')" />
|
|
693
|
+
</UDropdownMenu>
|
|
694
|
+
</td>
|
|
695
|
+
</tr>
|
|
696
|
+
</tbody>
|
|
697
|
+
</table>
|
|
698
|
+
</div>
|
|
699
|
+
</div>
|
|
700
|
+
|
|
701
|
+
<div v-if="!arranging && total > limit" class="flex items-center justify-between mt-3 text-sm text-muted">
|
|
702
|
+
<span class="tabular-nums">{{ range }}</span>
|
|
703
|
+
<div class="flex gap-1">
|
|
704
|
+
<UButton size="sm" variant="ghost" color="neutral" icon="i-lucide-chevron-left" :aria-label="t('common.previous')" :disabled="page <= 1" @click="page--" />
|
|
705
|
+
<UButton size="sm" variant="ghost" color="neutral" icon="i-lucide-chevron-right" :aria-label="t('common.next')" :disabled="page >= pages" @click="page++" />
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
|
|
709
|
+
</template>
|
|
710
|
+
|
|
711
|
+
<!-- notes a plugin adds under the list (the forms plugin: messages are deleted after a while) -->
|
|
712
|
+
<p v-for="(note, i) in meta?.notices ?? []" :key="i" class="mt-3 flex items-center gap-1.5 text-xs text-muted">
|
|
713
|
+
<UIcon :name="note.icon || 'i-lucide-info'" class="size-3.5 shrink-0" aria-hidden="true" />
|
|
714
|
+
{{ t(note.key, note.params) }}
|
|
715
|
+
</p>
|
|
716
|
+
|
|
717
|
+
<UModal :open="confirmBulkDelete" :title="t('list.bulkDeleteTitle', { count: selected.size })" @update:open="(v: boolean) => { confirmBulkDelete = v }">
|
|
718
|
+
<template #body>
|
|
719
|
+
<p class="text-sm text-muted">{{ t('list.bulkDeleteBody') }}</p>
|
|
720
|
+
<ul class="mt-3 space-y-1 text-sm text-highlighted">
|
|
721
|
+
<li v-for="r in selectedRows.slice(0, 5)" :key="r.id" class="truncate">{{ rowTitle(r) }}</li>
|
|
722
|
+
<li v-if="selectedRows.length > 5" class="text-muted">{{ t('list.andMore', { count: selectedRows.length - 5 }) }}</li>
|
|
723
|
+
</ul>
|
|
724
|
+
</template>
|
|
725
|
+
<template #footer>
|
|
726
|
+
<div class="flex justify-end gap-2 w-full">
|
|
727
|
+
<UButton color="neutral" variant="ghost" @click="confirmBulkDelete = false">{{ t('common.cancel') }}</UButton>
|
|
728
|
+
<UButton color="error" icon="i-lucide-trash-2" :loading="bulkBusy" @click="runBulk('delete')">{{ t('common.delete') }}</UButton>
|
|
729
|
+
</div>
|
|
730
|
+
</template>
|
|
731
|
+
</UModal>
|
|
732
|
+
</CmsPage>
|
|
733
|
+
</template>
|