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,453 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DropdownMenuItem } from '@nuxt/ui'
|
|
3
|
+
|
|
4
|
+
// The list of a page tree (definePages({ tree: true })): pages indented under their
|
|
5
|
+
// parents with the whole address under each title. Branches fold; a page is dragged
|
|
6
|
+
// into place (on a page's middle to put it under that one, near an edge to put it
|
|
7
|
+
// before or after) or, without a mouse — on a phone, from the keyboard — moved with
|
|
8
|
+
// "Move up / Move down" and the "Move…" dialog, which picks the parent and the place.
|
|
9
|
+
// Every move is one call to /_move: the page and everything below it get new
|
|
10
|
+
// addresses, and the server says how many changed.
|
|
11
|
+
const props = defineProps<{ entity: string; meta: any; canCreate: boolean }>()
|
|
12
|
+
const { t, tl, entitySingular, formatNumber } = useCmsI18n()
|
|
13
|
+
const toast = useToast()
|
|
14
|
+
const router = useRouter()
|
|
15
|
+
const confirm = useCmsConfirm()
|
|
16
|
+
const entryActions = useCmsEntryActions()
|
|
17
|
+
|
|
18
|
+
interface Row {
|
|
19
|
+
id: string; parentId: string | null; title: string; slug: string; position: number
|
|
20
|
+
status?: string; publishAt?: string | null; onSite: boolean; paths: Record<string, string>; locales: string[] | null; updatedAt: string
|
|
21
|
+
}
|
|
22
|
+
const { data, refresh, error } = await useFetch<{ rows: Row[]; maxDepth: number }>(() => `/api/cms/${props.entity}/_tree`, { key: `cms-tree:${props.entity}` })
|
|
23
|
+
useCmsLiveTopic(`list:${props.entity}`, () => refresh())
|
|
24
|
+
// The graph tells whether the site has redirects: the dialog can promise them.
|
|
25
|
+
const { data: graph } = await useFetch<any[]>('/api/cms/_graph', { key: 'cms-graph' })
|
|
26
|
+
const hasRedirects = computed(() => (graph.value ?? []).some((e: any) => e.preset === 'redirects'))
|
|
27
|
+
|
|
28
|
+
const publish = computed(() => props.meta?.publish)
|
|
29
|
+
const locales = computed(() => props.meta?.locales as { default: string; all: string[] } | null)
|
|
30
|
+
const maxDepth = computed(() => data.value?.maxDepth ?? 4)
|
|
31
|
+
const rows = computed(() => data.value?.rows ?? [])
|
|
32
|
+
const byId = computed(() => new Map(rows.value.map((r) => [r.id, r])))
|
|
33
|
+
const sortRows = (list: Row[]) => [...list].sort((a, b) => a.position - b.position || a.title.localeCompare(b.title) || (a.id < b.id ? -1 : 1))
|
|
34
|
+
// A page whose parent is not in the list (not readable by this person) is shown at the top.
|
|
35
|
+
const childrenOf = computed(() => {
|
|
36
|
+
const m = new Map<string | null, Row[]>()
|
|
37
|
+
for (const r of rows.value) {
|
|
38
|
+
const key = r.parentId && byId.value.has(r.parentId) ? r.parentId : null
|
|
39
|
+
m.set(key, [...(m.get(key) ?? []), r])
|
|
40
|
+
}
|
|
41
|
+
for (const [k, v] of m) m.set(k, sortRows(v))
|
|
42
|
+
return m
|
|
43
|
+
})
|
|
44
|
+
const kids = (id: string | null) => childrenOf.value.get(id) ?? []
|
|
45
|
+
function descendants(id: string): Set<string> {
|
|
46
|
+
const out = new Set<string>()
|
|
47
|
+
const walk = (p: string) => { for (const c of kids(p)) if (!out.has(c.id)) { out.add(c.id); walk(c.id) } }
|
|
48
|
+
walk(id)
|
|
49
|
+
return out
|
|
50
|
+
}
|
|
51
|
+
const depthOf = (id: string): number => { let d = 1; for (let r = byId.value.get(id); r?.parentId && byId.value.has(r.parentId) && d < 50; r = byId.value.get(r.parentId)) d++; return d }
|
|
52
|
+
const heightOf = (id: string): number => kids(id).reduce((h, c) => Math.max(h, 1 + heightOf(c.id)), 0)
|
|
53
|
+
|
|
54
|
+
// ── folding (remembered per collection, in this browser) ──
|
|
55
|
+
const folded = ref<Set<string>>(new Set())
|
|
56
|
+
const foldKey = computed(() => `cms:tree-folded:${props.entity}`)
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
try { folded.value = new Set(JSON.parse(localStorage.getItem(foldKey.value) || '[]')) }
|
|
59
|
+
catch { /* storage blocked: everything open */ }
|
|
60
|
+
})
|
|
61
|
+
function remember() {
|
|
62
|
+
try { localStorage.setItem(foldKey.value, JSON.stringify([...folded.value])) }
|
|
63
|
+
catch { /* for this visit only */ }
|
|
64
|
+
}
|
|
65
|
+
function toggle(id: string, open?: boolean) {
|
|
66
|
+
const next = new Set(folded.value)
|
|
67
|
+
const wantOpen = open ?? next.has(id)
|
|
68
|
+
if (wantOpen) next.delete(id)
|
|
69
|
+
else next.add(id)
|
|
70
|
+
folded.value = next
|
|
71
|
+
remember()
|
|
72
|
+
}
|
|
73
|
+
const branches = computed(() => rows.value.filter((r) => kids(r.id).length))
|
|
74
|
+
const allOpen = computed(() => branches.value.every((r) => !folded.value.has(r.id)))
|
|
75
|
+
function toggleAll() {
|
|
76
|
+
folded.value = allOpen.value ? new Set(branches.value.map((r) => r.id)) : new Set()
|
|
77
|
+
remember()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── filter ──
|
|
81
|
+
const q = ref('')
|
|
82
|
+
const fold = (s: string) => s.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase()
|
|
83
|
+
const addressOf = (r: Row) => r.paths[locales.value?.default ?? ''] ?? Object.values(r.paths)[0] ?? ''
|
|
84
|
+
const matching = computed(() => {
|
|
85
|
+
const term = fold(q.value.trim())
|
|
86
|
+
if (!term) return null
|
|
87
|
+
const keep = new Set<string>()
|
|
88
|
+
for (const r of rows.value) {
|
|
89
|
+
if (!fold(r.title).includes(term) && !fold(addressOf(r)).includes(term)) continue
|
|
90
|
+
for (let c: Row | undefined = r; c && !keep.has(c.id); c = c.parentId ? byId.value.get(c.parentId) : undefined) keep.add(c.id)
|
|
91
|
+
}
|
|
92
|
+
return keep
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// ── what is shown: the tree, flattened, in order ──
|
|
96
|
+
interface Shown { row: Row; depth: number; open: boolean; count: number }
|
|
97
|
+
const shown = computed<Shown[]>(() => {
|
|
98
|
+
const out: Shown[] = []
|
|
99
|
+
const walk = (parent: string | null, depth: number) => {
|
|
100
|
+
for (const r of kids(parent)) {
|
|
101
|
+
if (matching.value && !matching.value.has(r.id)) continue
|
|
102
|
+
const count = kids(r.id).length
|
|
103
|
+
const open = !!matching.value || !folded.value.has(r.id)
|
|
104
|
+
out.push({ row: r, depth, open, count })
|
|
105
|
+
if (count && open) walk(r.id, depth + 1)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
walk(null, 0)
|
|
109
|
+
return out
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
const isLive = (r: Row) => !!publish.value && r.status === publish.value.publishedValue
|
|
113
|
+
const missingLocales = (r: Row) => (locales.value?.all ?? []).filter((c) => !(r.locales ?? []).includes(c))
|
|
114
|
+
|
|
115
|
+
// ── moving ──
|
|
116
|
+
const moving = ref(false)
|
|
117
|
+
async function move(id: string, parent: string | null, index: number): Promise<boolean> {
|
|
118
|
+
const r = byId.value.get(id)
|
|
119
|
+
if (moving.value || !r) return false
|
|
120
|
+
// Told before asking the server (which checks it all again).
|
|
121
|
+
if (parent && (parent === id || descendants(id).has(parent))) {
|
|
122
|
+
toast.add({ title: t('tree.moveFailed'), description: t('validation.treeCycle', { loop: `${r.title} → … → ${r.title}` }), icon: 'i-lucide-x', color: 'error' })
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
if ((parent ? depthOf(parent) : 0) + 1 + heightOf(id) > maxDepth.value) {
|
|
126
|
+
toast.add({ title: t('tree.moveFailed'), description: t('validation.treeDepth', { max: maxDepth.value }), icon: 'i-lucide-x', color: 'error' })
|
|
127
|
+
return false
|
|
128
|
+
}
|
|
129
|
+
moving.value = true
|
|
130
|
+
try {
|
|
131
|
+
const res = await cmsFetch<{ moved: { from: string; to: string }[]; redirects: number }>(`/api/cms/${props.entity}/_move`, { method: 'POST', body: { id, parent, index } })
|
|
132
|
+
await refresh()
|
|
133
|
+
if (parent) toggle(parent, true)
|
|
134
|
+
const changed = res.moved.length
|
|
135
|
+
toast.add({
|
|
136
|
+
title: t('tree.moved'),
|
|
137
|
+
description: changed
|
|
138
|
+
? `${t('tree.movedAddresses', { count: changed })} ${res.redirects ? t('tree.redirectsMade') : hasRedirects.value ? '' : t('tree.noRedirects')}`.trim()
|
|
139
|
+
: undefined,
|
|
140
|
+
icon: 'i-lucide-check', color: 'success',
|
|
141
|
+
})
|
|
142
|
+
announce.value = t('tree.movedAnnounce', { name: r.title })
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
catch (err: any) {
|
|
146
|
+
const issue = Array.isArray(err?.data?.data) ? err.data.data[0] : null
|
|
147
|
+
toast.add({ title: t('tree.moveFailed'), description: issue ? cmsIssueMessage(issue, { type: 'slug' }, t as any) : cmsRequestError(err, t as any), icon: 'i-lucide-x', color: 'error' })
|
|
148
|
+
return false
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
moving.value = false
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const announce = ref('')
|
|
155
|
+
|
|
156
|
+
/** One place up or down among the siblings: the keyboard's (and the phone's) way to arrange. */
|
|
157
|
+
async function nudge(r: Row, delta: -1 | 1) {
|
|
158
|
+
const sibs = kids(r.parentId && byId.value.has(r.parentId) ? r.parentId : null)
|
|
159
|
+
const i = sibs.findIndex((s) => s.id === r.id)
|
|
160
|
+
const j = i + delta
|
|
161
|
+
if (i < 0 || j < 0 || j >= sibs.length) return
|
|
162
|
+
await move(r.id, r.parentId, j)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Drag: the middle of a row puts the page under it, the top and bottom edges before and after it.
|
|
166
|
+
const dragId = ref<string | null>(null)
|
|
167
|
+
const drop = ref<{ id: string; mode: 'before' | 'after' | 'into' } | null>(null)
|
|
168
|
+
const blocked = computed(() => (dragId.value ? new Set([dragId.value, ...descendants(dragId.value)]) : new Set<string>()))
|
|
169
|
+
function onDragStart(e: DragEvent, r: Row) {
|
|
170
|
+
dragId.value = r.id
|
|
171
|
+
if (e.dataTransfer) {
|
|
172
|
+
e.dataTransfer.effectAllowed = 'move'
|
|
173
|
+
e.dataTransfer.setData('text/plain', r.id)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function onDragOver(e: DragEvent, r: Row) {
|
|
177
|
+
if (!dragId.value || blocked.value.has(r.id)) { drop.value = null; return }
|
|
178
|
+
e.preventDefault()
|
|
179
|
+
const box = (e.currentTarget as HTMLElement).getBoundingClientRect()
|
|
180
|
+
const y = (e.clientY - box.top) / box.height
|
|
181
|
+
drop.value = { id: r.id, mode: y < 0.28 ? 'before' : y > 0.72 ? 'after' : 'into' }
|
|
182
|
+
}
|
|
183
|
+
function endDrag() {
|
|
184
|
+
dragId.value = null
|
|
185
|
+
drop.value = null
|
|
186
|
+
}
|
|
187
|
+
async function onDrop(e: DragEvent, r: Row) {
|
|
188
|
+
e.preventDefault()
|
|
189
|
+
const id = dragId.value
|
|
190
|
+
const d = drop.value
|
|
191
|
+
endDrag()
|
|
192
|
+
if (!id || !d || blocked.value.has(r.id)) return
|
|
193
|
+
if (d.mode === 'into') return void await move(id, r.id, kids(r.id).filter((c) => c.id !== id).length)
|
|
194
|
+
const parent = r.parentId && byId.value.has(r.parentId) ? r.parentId : null
|
|
195
|
+
const sibs = kids(parent).filter((c) => c.id !== id)
|
|
196
|
+
const at = sibs.findIndex((c) => c.id === r.id)
|
|
197
|
+
await move(id, parent, d.mode === 'before' ? at : at + 1)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ── the "Move…" dialog: where it goes and in which place ──
|
|
201
|
+
const dialog = ref<{ row: Row; parent: string | null; place: string } | null>(null)
|
|
202
|
+
const dialogOpen = computed({ get: () => !!dialog.value, set: (v: boolean) => { if (!v) dialog.value = null } })
|
|
203
|
+
const trail = (r: Row): string => {
|
|
204
|
+
const parts: string[] = []
|
|
205
|
+
for (let c: Row | undefined = r; c && parts.length < 12; c = c.parentId ? byId.value.get(c.parentId) : undefined) parts.unshift(c.title || t('common.untitled'))
|
|
206
|
+
return parts.join(' / ')
|
|
207
|
+
}
|
|
208
|
+
/** Where the page may go: the top level, or any page that is not it or below it, as deep as the tree allows. */
|
|
209
|
+
const parentChoices = computed(() => {
|
|
210
|
+
const d = dialog.value
|
|
211
|
+
if (!d) return []
|
|
212
|
+
const own = new Set([d.row.id, ...descendants(d.row.id)])
|
|
213
|
+
const height = heightOf(d.row.id)
|
|
214
|
+
const items = [{ value: '__top', label: t('tree.moveTop') }]
|
|
215
|
+
const walk = (parent: string | null) => {
|
|
216
|
+
for (const r of kids(parent)) {
|
|
217
|
+
if (own.has(r.id)) continue
|
|
218
|
+
if (depthOf(r.id) + 1 + height <= maxDepth.value) items.push({ value: r.id, label: trail(r) })
|
|
219
|
+
walk(r.id)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
walk(null)
|
|
223
|
+
return items
|
|
224
|
+
})
|
|
225
|
+
const placeChoices = computed(() => {
|
|
226
|
+
const d = dialog.value
|
|
227
|
+
if (!d) return []
|
|
228
|
+
const sibs = kids(d.parent).filter((s) => s.id !== d.row.id)
|
|
229
|
+
if (!sibs.length) return [{ value: '__first', label: t('tree.moveOnly') }]
|
|
230
|
+
return [{ value: '__first', label: t('tree.moveFirst') }, ...sibs.map((s) => ({ value: s.id, label: t('tree.moveAfter', { name: s.title || t('common.untitled') }) }))]
|
|
231
|
+
})
|
|
232
|
+
/** Where the page sits among its siblings after a move: where it is now, or last under a new parent. */
|
|
233
|
+
function placeIn(parent: string | null, r: Row): string {
|
|
234
|
+
const sibs = kids(parent).filter((s) => s.id !== r.id)
|
|
235
|
+
const same = (r.parentId && byId.value.has(r.parentId) ? r.parentId : null) === parent
|
|
236
|
+
if (!sibs.length) return '__first'
|
|
237
|
+
if (!same) return sibs[sibs.length - 1]!.id
|
|
238
|
+
const before = kids(parent).findIndex((s) => s.id === r.id) - 1
|
|
239
|
+
return before < 0 ? '__first' : kids(parent)[before]!.id
|
|
240
|
+
}
|
|
241
|
+
function openMove(r: Row) {
|
|
242
|
+
const parent = r.parentId && byId.value.has(r.parentId) ? r.parentId : null
|
|
243
|
+
dialog.value = { row: r, parent, place: placeIn(parent, r) }
|
|
244
|
+
}
|
|
245
|
+
watch(() => dialog.value?.parent, (parent) => { if (dialog.value && parent !== undefined) dialog.value.place = placeIn(parent, dialog.value.row) })
|
|
246
|
+
async function confirmMove() {
|
|
247
|
+
const d = dialog.value
|
|
248
|
+
if (!d) return
|
|
249
|
+
const sibs = kids(d.parent).filter((s) => s.id !== d.row.id)
|
|
250
|
+
const index = d.place === '__first' ? 0 : sibs.findIndex((s) => s.id === d.place) + 1
|
|
251
|
+
if (await move(d.row.id, d.parent, index)) dialog.value = null
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ── a row's own actions ──
|
|
255
|
+
async function setPublished(r: Row, next: boolean) {
|
|
256
|
+
const p = publish.value
|
|
257
|
+
if (!p) return
|
|
258
|
+
// The pages under this one that are on the website go off it with this one.
|
|
259
|
+
const below = next ? 0 : [...descendants(r.id)].filter((id) => rows.value.find((x) => x.id === id)?.onSite).length
|
|
260
|
+
if (!next && !await confirm({
|
|
261
|
+
title: t('list.unpublishTitle', { count: 1 }), description: below ? t('tree.unpublishBranchCount', { count: below }) : t('list.unpublishBody', { count: 1 }),
|
|
262
|
+
icon: 'i-lucide-eye-off', confirmLabel: t('editor.unpublish'), color: 'warning',
|
|
263
|
+
})) return
|
|
264
|
+
try {
|
|
265
|
+
await cmsFetch(`/api/cms/${props.entity}/${r.id}`, { method: 'PATCH', body: { [p.field]: next ? p.publishedValue : p.draftValue } })
|
|
266
|
+
toast.add({ title: next ? t('editor.publishedToast') : t('editor.unpublishedToast'), icon: 'i-lucide-check', color: 'success' })
|
|
267
|
+
refresh()
|
|
268
|
+
}
|
|
269
|
+
catch (e: any) {
|
|
270
|
+
toast.add({ title: t('team.actionFailed'), description: cmsRequestError(e, t as any), icon: 'i-lucide-x', color: 'error' })
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function duplicate(r: Row) {
|
|
274
|
+
const copy = await entryActions.duplicate(props.entity, props.meta, r.id)
|
|
275
|
+
if (copy) await router.push(`/admin/${props.entity}/${copy}`)
|
|
276
|
+
}
|
|
277
|
+
async function remove(r: Row) {
|
|
278
|
+
if (await entryActions.remove(props.entity, props.meta, r.id, r.title)) refresh()
|
|
279
|
+
}
|
|
280
|
+
function menu(r: Row, index: number, count: number): DropdownMenuItem[][] {
|
|
281
|
+
const groups: DropdownMenuItem[][] = []
|
|
282
|
+
const p = publish.value
|
|
283
|
+
if (p && props.meta?.can?.publish !== false) {
|
|
284
|
+
groups.push([isLive(r)
|
|
285
|
+
? { label: t('editor.unpublish'), icon: 'i-lucide-eye-off', onSelect: () => setPublished(r, false) }
|
|
286
|
+
: { label: t('editor.publish'), icon: 'i-lucide-globe', onSelect: () => setPublished(r, true) }])
|
|
287
|
+
}
|
|
288
|
+
const entry: DropdownMenuItem[] = []
|
|
289
|
+
const address = addressOf(r)
|
|
290
|
+
if (address && r.onSite) entry.push({ label: t('editor.viewOnSite'), icon: 'i-lucide-arrow-up-right', to: address, target: '_blank' })
|
|
291
|
+
if (props.canCreate) entry.push({ label: t('tree.addSubpage'), icon: 'i-lucide-corner-down-right', to: `/admin/${props.entity}/new?parent=${r.id}` })
|
|
292
|
+
if (props.meta?.can?.create !== false) entry.push({ label: t('editor.duplicate'), icon: 'i-lucide-copy', onSelect: () => duplicate(r) })
|
|
293
|
+
if (entry.length) groups.push(entry)
|
|
294
|
+
if (props.meta?.can?.update !== false) {
|
|
295
|
+
groups.push([
|
|
296
|
+
{ label: t('tree.move'), icon: 'i-lucide-folder-input', onSelect: () => openMove(r) },
|
|
297
|
+
{ label: t('tree.up'), icon: 'i-lucide-arrow-up', disabled: index === 0, onSelect: () => nudge(r, -1) },
|
|
298
|
+
{ label: t('tree.down'), icon: 'i-lucide-arrow-down', disabled: index === count - 1, onSelect: () => nudge(r, 1) },
|
|
299
|
+
])
|
|
300
|
+
}
|
|
301
|
+
if (props.meta?.can?.delete !== false) groups.push([{ label: t('editor.delete'), icon: 'i-lucide-trash-2', color: 'error' as const, onSelect: () => remove(r) }])
|
|
302
|
+
return groups
|
|
303
|
+
}
|
|
304
|
+
const siblingIndex = (r: Row) => kids(r.parentId && byId.value.has(r.parentId) ? r.parentId : null).findIndex((s) => s.id === r.id)
|
|
305
|
+
const siblingCount = (r: Row) => kids(r.parentId && byId.value.has(r.parentId) ? r.parentId : null).length
|
|
306
|
+
const canMove = computed(() => props.meta?.can?.update !== false)
|
|
307
|
+
</script>
|
|
308
|
+
|
|
309
|
+
<template>
|
|
310
|
+
<div>
|
|
311
|
+
<div class="flex flex-wrap items-center justify-between gap-x-3 gap-y-2 mb-3">
|
|
312
|
+
<p class="text-sm text-muted max-sm:hidden">{{ canMove ? t('tree.hint') : '' }}</p>
|
|
313
|
+
<div class="flex items-center gap-1 w-full sm:w-auto">
|
|
314
|
+
<UInput
|
|
315
|
+
v-model="q" icon="i-lucide-search" :placeholder="t('common.search')" size="sm" variant="ghost" class="w-full sm:w-64" :aria-label="t('common.search')"
|
|
316
|
+
>
|
|
317
|
+
<template v-if="q" #trailing>
|
|
318
|
+
<UButton color="neutral" variant="link" size="xs" icon="i-lucide-x" :aria-label="t('common.clear')" @click="q = ''" />
|
|
319
|
+
</template>
|
|
320
|
+
</UInput>
|
|
321
|
+
<UTooltip v-if="branches.length" :text="allOpen ? t('tree.collapseAll') : t('tree.expandAll')">
|
|
322
|
+
<UButton
|
|
323
|
+
color="neutral" variant="ghost" size="sm" :icon="allOpen ? 'i-lucide-chevrons-down-up' : 'i-lucide-chevrons-up-down'"
|
|
324
|
+
:aria-label="allOpen ? t('tree.collapseAll') : t('tree.expandAll')" @click="toggleAll"
|
|
325
|
+
/>
|
|
326
|
+
</UTooltip>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<div class="cms-card overflow-hidden">
|
|
331
|
+
<CmsLoadError v-if="error" :error="error" @retry="refresh()" />
|
|
332
|
+
<CmsEmptyState
|
|
333
|
+
v-else-if="!rows.length" :icon="meta?.icon" :character="entity"
|
|
334
|
+
:title="t('list.emptyTitle', { label: (tl(meta?.label) || entity).toLowerCase() })" :description="tl(meta?.description) || t('list.emptyDescription')"
|
|
335
|
+
>
|
|
336
|
+
<template v-if="canCreate" #actions>
|
|
337
|
+
<UButton :to="`/admin/${entity}/new`" icon="i-lucide-plus">{{ t('list.emptyAction') }}</UButton>
|
|
338
|
+
</template>
|
|
339
|
+
</CmsEmptyState>
|
|
340
|
+
<CmsEmptyState v-else-if="!shown.length" variant="no-results" :title="t('list.noResultsTitle', { q })" :description="t('list.noResultsDescription')">
|
|
341
|
+
<template #actions>
|
|
342
|
+
<UButton color="neutral" variant="outline" @click="q = ''">{{ t('list.clearSearch') }}</UButton>
|
|
343
|
+
</template>
|
|
344
|
+
</CmsEmptyState>
|
|
345
|
+
|
|
346
|
+
<ul v-else :aria-label="t('tree.label')">
|
|
347
|
+
<li
|
|
348
|
+
v-for="s in shown" :key="s.row.id"
|
|
349
|
+
class="cms-tree-row relative flex items-center gap-1.5 border-b border-(--ui-border-muted) last:border-0 py-2 pr-2 hover:bg-elevated/40 transition-colors"
|
|
350
|
+
:class="[
|
|
351
|
+
dragId === s.row.id ? 'opacity-40' : '',
|
|
352
|
+
drop?.id === s.row.id && drop.mode === 'into' ? 'bg-elevated ring-2 ring-inset ring-(--ui-border-accented)' : '',
|
|
353
|
+
drop?.id === s.row.id && drop.mode === 'before' ? 'cms-tree-before' : '',
|
|
354
|
+
drop?.id === s.row.id && drop.mode === 'after' ? 'cms-tree-after' : '',
|
|
355
|
+
]"
|
|
356
|
+
:style="{ paddingLeft: `${0.5 + s.depth * 1.5}rem` }" :aria-level="s.depth + 1"
|
|
357
|
+
@dragover="onDragOver($event, s.row)" @drop="onDrop($event, s.row)" @dragleave="drop = drop?.id === s.row.id ? null : drop"
|
|
358
|
+
>
|
|
359
|
+
<!-- fold / unfold -->
|
|
360
|
+
<UButton
|
|
361
|
+
v-if="s.count" size="xs" color="neutral" variant="ghost" class="shrink-0"
|
|
362
|
+
:icon="s.open ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'" :aria-expanded="s.open"
|
|
363
|
+
:aria-label="t(s.open ? 'tree.collapse' : 'tree.expand', { name: s.row.title })" @click="toggle(s.row.id)"
|
|
364
|
+
/>
|
|
365
|
+
<span v-else class="size-6 shrink-0" aria-hidden="true" />
|
|
366
|
+
<!-- the handle: a mouse drags here (not offered on touch screens: use Move…) -->
|
|
367
|
+
<span
|
|
368
|
+
v-if="canMove && !q" class="shrink-0 cursor-grab text-dimmed hover:text-default [@media(pointer:coarse)]:hidden" draggable="true"
|
|
369
|
+
:title="t('tree.drag', { name: s.row.title })" @dragstart="onDragStart($event, s.row)" @dragend="endDrag"
|
|
370
|
+
>
|
|
371
|
+
<UIcon name="i-lucide-grip-vertical" class="size-4" aria-hidden="true" />
|
|
372
|
+
</span>
|
|
373
|
+
<div class="relative min-w-0 flex-1">
|
|
374
|
+
<NuxtLink :to="`/admin/${entity}/${s.row.id}`" class="block truncate text-sm font-medium text-highlighted after:absolute after:-inset-y-2 after:inset-x-0">
|
|
375
|
+
{{ s.row.title || t('common.untitled') }}
|
|
376
|
+
</NuxtLink>
|
|
377
|
+
<p class="truncate font-mono text-xs text-muted">{{ addressOf(s.row) || '/' + s.row.slug }}</p>
|
|
378
|
+
<!-- below the wide layout the columns are gone: the state (and the missing language) sit under the address -->
|
|
379
|
+
<p v-if="publish || missingLocales(s.row).length" class="mt-1 flex items-center gap-x-3 gap-y-1 flex-wrap lg:hidden">
|
|
380
|
+
<span class="sm:hidden">
|
|
381
|
+
<span v-if="isLive(s.row) && !s.row.onSite" class="inline-flex items-center gap-1.5 text-xs text-muted">
|
|
382
|
+
<UIcon name="i-lucide-eye-off" class="size-3.5" aria-hidden="true" />{{ t('tree.hiddenShort') }}
|
|
383
|
+
</span>
|
|
384
|
+
<CmsStatusBadge v-else-if="publish" :published="isLive(s.row)" :scheduled-for="publish.dateField ? s.row.publishAt : null" class="!text-xs" />
|
|
385
|
+
</span>
|
|
386
|
+
<span v-if="meta?.locales && missingLocales(s.row).length" class="inline-flex items-center rounded-full bg-warning/10 px-2 py-0.5 text-xs font-medium cms-unsaved">
|
|
387
|
+
{{ t('translation.missing', { lang: missingLocales(s.row).map((c: string) => c.toUpperCase()).join(', ') }) }}
|
|
388
|
+
</span>
|
|
389
|
+
</p>
|
|
390
|
+
</div>
|
|
391
|
+
<span v-if="s.count && !s.open" class="shrink-0 text-xs text-dimmed max-sm:hidden">{{ t('tree.subpages', { count: formatNumber(s.count) }) }}</span>
|
|
392
|
+
<span v-if="meta?.locales && missingLocales(s.row).length" class="shrink-0 hidden lg:inline-flex items-center rounded-full bg-warning/10 px-2 py-0.5 text-xs font-medium cms-unsaved">
|
|
393
|
+
{{ t('translation.missing', { lang: missingLocales(s.row).map((c: string) => c.toUpperCase()).join(', ') }) }}
|
|
394
|
+
</span>
|
|
395
|
+
<span class="shrink-0 max-sm:hidden">
|
|
396
|
+
<UTooltip v-if="isLive(s.row) && !s.row.onSite" :text="t('tree.hiddenByParent')">
|
|
397
|
+
<span class="inline-flex items-center gap-1.5 text-sm text-muted" tabindex="0">
|
|
398
|
+
<UIcon name="i-lucide-eye-off" class="size-3.5" aria-hidden="true" />{{ t('tree.hiddenShort') }}
|
|
399
|
+
</span>
|
|
400
|
+
</UTooltip>
|
|
401
|
+
<CmsStatusBadge v-else-if="publish" :published="isLive(s.row)" :scheduled-for="publish.dateField ? s.row.publishAt : null" />
|
|
402
|
+
</span>
|
|
403
|
+
<UDropdownMenu :items="menu(s.row, siblingIndex(s.row), siblingCount(s.row))" :content="{ align: 'end' }">
|
|
404
|
+
<UButton class="relative z-10 shrink-0" color="neutral" variant="ghost" size="sm" icon="i-lucide-ellipsis" :aria-label="t('editor.moreActions')" />
|
|
405
|
+
</UDropdownMenu>
|
|
406
|
+
</li>
|
|
407
|
+
</ul>
|
|
408
|
+
</div>
|
|
409
|
+
<p class="sr-only" role="status" aria-live="polite">{{ announce }}</p>
|
|
410
|
+
|
|
411
|
+
<UModal
|
|
412
|
+
v-model:open="dialogOpen" :title="t('tree.moveTitle', { name: dialog?.row.title ?? '' })" :description="t('tree.moveBody')"
|
|
413
|
+
:ui="{ content: 'sm:max-w-lg' }"
|
|
414
|
+
>
|
|
415
|
+
<template #body>
|
|
416
|
+
<div v-if="dialog" class="space-y-4">
|
|
417
|
+
<UFormField :label="t('tree.moveParent')">
|
|
418
|
+
<USelectMenu
|
|
419
|
+
:model-value="dialog.parent ?? '__top'" :items="parentChoices" value-key="value" class="w-full" icon="i-lucide-folder-tree" :aria-label="t('tree.moveParent')"
|
|
420
|
+
@update:model-value="(v: string) => { dialog!.parent = v === '__top' ? null : v }"
|
|
421
|
+
/>
|
|
422
|
+
</UFormField>
|
|
423
|
+
<UFormField :label="t('tree.movePosition')">
|
|
424
|
+
<USelectMenu v-model="dialog.place" :items="placeChoices" value-key="value" class="w-full" icon="i-lucide-arrow-up-down" :aria-label="t('tree.movePosition')" />
|
|
425
|
+
</UFormField>
|
|
426
|
+
<p class="text-sm text-muted">{{ hasRedirects ? t('tree.moveRedirects') : t('tree.moveNoRedirects') }}</p>
|
|
427
|
+
</div>
|
|
428
|
+
</template>
|
|
429
|
+
<template #footer>
|
|
430
|
+
<div class="flex justify-end gap-2 w-full">
|
|
431
|
+
<UButton color="neutral" variant="ghost" @click="dialog = null">{{ t('common.cancel') }}</UButton>
|
|
432
|
+
<UButton icon="i-lucide-folder-input" :loading="moving" @click="confirmMove">{{ t('tree.moveConfirm') }}</UButton>
|
|
433
|
+
</div>
|
|
434
|
+
</template>
|
|
435
|
+
</UModal>
|
|
436
|
+
</div>
|
|
437
|
+
</template>
|
|
438
|
+
|
|
439
|
+
<style scoped>
|
|
440
|
+
/* A line where the dragged page would land: before or after this one. */
|
|
441
|
+
.cms-tree-before::before,
|
|
442
|
+
.cms-tree-after::after {
|
|
443
|
+
content: '';
|
|
444
|
+
position: absolute;
|
|
445
|
+
inset-inline: 0.5rem;
|
|
446
|
+
height: 2px;
|
|
447
|
+
background: var(--ui-text-highlighted);
|
|
448
|
+
border-radius: 1px;
|
|
449
|
+
pointer-events: none;
|
|
450
|
+
}
|
|
451
|
+
.cms-tree-before::before { top: -1px; }
|
|
452
|
+
.cms-tree-after::after { bottom: -1px; }
|
|
453
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Text someone typed into this entry and never saved (their tab closed or crashed):
|
|
3
|
+
// it is not in the form. The saved version is what opens; this says the other text
|
|
4
|
+
// exists, from when and from whom, and lets the person keep it (it goes into the
|
|
5
|
+
// form as their own unsaved change) or discard it. Nothing happens without a click.
|
|
6
|
+
import type { CmsCollab } from '../composables/useCmsCollab'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{ collab: CmsCollab | null }>()
|
|
9
|
+
const emit = defineEmits<{ keep: [values: Record<string, any>] }>()
|
|
10
|
+
const { t, formatDate } = useCmsI18n()
|
|
11
|
+
const left = computed(() => props.collab?.unsaved.value ?? null)
|
|
12
|
+
const title = computed(() => {
|
|
13
|
+
const u = left.value
|
|
14
|
+
if (!u) return ''
|
|
15
|
+
return u.by ? t('live.unsavedLeft', { time: formatDate(u.at), name: u.by }) : t('live.unsavedLeftAnon', { time: formatDate(u.at) })
|
|
16
|
+
})
|
|
17
|
+
async function keep() {
|
|
18
|
+
const u = left.value
|
|
19
|
+
if (!u) return
|
|
20
|
+
emit('keep', u.values)
|
|
21
|
+
await props.collab?.clearUnsaved()
|
|
22
|
+
}
|
|
23
|
+
async function discard() {
|
|
24
|
+
await props.collab?.clearUnsaved()
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<UAlert
|
|
30
|
+
v-if="left" color="warning" variant="subtle" icon="i-lucide-file-clock" class="mb-6" role="alert"
|
|
31
|
+
:title="title" :description="t('live.unsavedLeftBody')"
|
|
32
|
+
:actions="[{ label: t('live.unsavedKeep'), color: 'neutral', variant: 'outline', onClick: keep }, { label: t('live.unsavedDiscard'), color: 'neutral', variant: 'ghost', onClick: discard }]"
|
|
33
|
+
/>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The "tinyzoo" wordmark: near-black, cream in dark mode.
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<span class="inline-flex" aria-hidden="true">
|
|
7
|
+
<img :src="cmsBrand.wordmarkUrl" alt="" class="h-full w-auto dark:hidden" draggable="false">
|
|
8
|
+
<img :src="cmsBrand.wordmarkReversedUrl" alt="" class="h-full w-auto hidden dark:block" draggable="false">
|
|
9
|
+
</span>
|
|
10
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts the admin's look and language on <html> (data-cms-admin, data-cms-accent,
|
|
3
|
+
* lang) and the title template. Used by both admin layouts.
|
|
4
|
+
*/
|
|
5
|
+
export function useCmsAdminHead() {
|
|
6
|
+
const config = useCmsAdminConfig()
|
|
7
|
+
const { t, tl, locale } = useCmsI18n()
|
|
8
|
+
const productName = computed(() => tl(config.value.name, cmsBrand.name))
|
|
9
|
+
// No client name configured: the admin shows tinyzoo's own mark instead of an initial.
|
|
10
|
+
const unbranded = computed(() => productName.value === cmsBrand.name)
|
|
11
|
+
useHead(() => ({
|
|
12
|
+
htmlAttrs: { 'lang': locale.value, 'data-cms-admin': '', 'data-cms-accent': config.value.accent },
|
|
13
|
+
// The admin's tabs carry tinyzoo's mascot, so they stand apart from the website's.
|
|
14
|
+
link: [{ rel: 'icon', type: 'image/svg+xml', href: cmsBrand.faviconUrl, key: 'cms-admin-icon', tagPriority: 'high' }],
|
|
15
|
+
titleTemplate: (title?: string) => (title ? `${title} · ${productName.value}` : `${t('app.adminTitle')} · ${productName.value}`),
|
|
16
|
+
}))
|
|
17
|
+
return { productName, unbranded }
|
|
18
|
+
}
|