@xleddyl/nuxt-cms 0.1.23 → 0.1.24
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/dist/module.json +1 -1
- package/dist/module.mjs +16 -3
- package/dist/runtime/app/components/cms/BlocksField.vue +2 -9
- package/dist/runtime/app/components/cms/Button.vue +4 -2
- package/dist/runtime/app/components/cms/ConfirmModal.vue +5 -14
- package/dist/runtime/app/components/cms/Drawer.d.vue.ts +30 -0
- package/dist/runtime/app/components/cms/Drawer.vue +65 -0
- package/dist/runtime/app/components/cms/Drawer.vue.d.ts +30 -0
- package/dist/runtime/app/components/cms/DropdownMenu.d.vue.ts +0 -3
- package/dist/runtime/app/components/cms/DropdownMenu.vue +2 -7
- package/dist/runtime/app/components/cms/DropdownMenu.vue.d.ts +0 -3
- package/dist/runtime/app/components/cms/EmptyState.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/EmptyState.vue +6 -7
- package/dist/runtime/app/components/cms/EmptyState.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/EntryDrawer.d.vue.ts +21 -0
- package/dist/runtime/app/components/cms/EntryDrawer.vue +193 -0
- package/dist/runtime/app/components/cms/EntryDrawer.vue.d.ts +21 -0
- package/dist/runtime/app/components/cms/EntryForm.vue +19 -7
- package/dist/runtime/app/components/cms/FieldInput.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/FieldInput.vue +13 -27
- package/dist/runtime/app/components/cms/FieldInput.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/Form.vue +1 -1
- package/dist/runtime/app/components/cms/FormField.d.vue.ts +4 -5
- package/dist/runtime/app/components/cms/FormField.vue +9 -7
- package/dist/runtime/app/components/cms/FormField.vue.d.ts +4 -5
- package/dist/runtime/app/components/cms/JsonField.vue +3 -4
- package/dist/runtime/app/components/cms/LocaleSwitch.d.vue.ts +14 -0
- package/dist/runtime/app/components/cms/LocaleSwitch.vue +29 -0
- package/dist/runtime/app/components/cms/LocaleSwitch.vue.d.ts +14 -0
- package/dist/runtime/app/components/cms/MediaField.vue +7 -17
- package/dist/runtime/app/components/cms/MediaGallery.vue +48 -78
- package/dist/runtime/app/components/cms/MediaThumb.d.vue.ts +6 -0
- package/dist/runtime/app/components/cms/MediaThumb.vue +40 -0
- package/dist/runtime/app/components/cms/MediaThumb.vue.d.ts +6 -0
- package/dist/runtime/app/components/cms/Modal.d.vue.ts +1 -4
- package/dist/runtime/app/components/cms/Modal.vue +8 -7
- package/dist/runtime/app/components/cms/Modal.vue.d.ts +1 -4
- package/dist/runtime/app/components/cms/PageHeader.d.vue.ts +1 -1
- package/dist/runtime/app/components/cms/PageHeader.vue +6 -6
- package/dist/runtime/app/components/cms/PageHeader.vue.d.ts +1 -1
- package/dist/runtime/app/components/cms/RelationField.vue +0 -4
- package/dist/runtime/app/components/cms/SelectMenu.vue +23 -3
- package/dist/runtime/app/components/cms/SlugField.vue +1 -2
- package/dist/runtime/app/components/cms/Spinner.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/Spinner.vue +5 -0
- package/dist/runtime/app/components/cms/Spinner.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/StatusBadge.d.vue.ts +6 -0
- package/dist/runtime/app/components/cms/StatusBadge.vue +11 -0
- package/dist/runtime/app/components/cms/StatusBadge.vue.d.ts +6 -0
- package/dist/runtime/app/components/cms/Table.d.vue.ts +3 -6
- package/dist/runtime/app/components/cms/Table.vue +72 -27
- package/dist/runtime/app/components/cms/Table.vue.d.ts +3 -6
- package/dist/runtime/app/components/cms/Toaster.vue +4 -4
- package/dist/runtime/app/components/cms/TranslatableField.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/TranslatableField.vue +7 -44
- package/dist/runtime/app/components/cms/TranslatableField.vue.d.ts +1 -0
- package/dist/runtime/app/layouts/cms-admin.vue +10 -20
- package/dist/runtime/app/pages/admin-collection.vue +130 -103
- package/dist/runtime/app/pages/admin-entry.vue +6 -24
- package/dist/runtime/app/pages/admin-login.vue +12 -31
- package/dist/runtime/app/pages/admin-media.vue +8 -2
- package/dist/runtime/app/utils/ui.d.ts +0 -7
- package/dist/runtime/app/utils/ui.js +0 -5
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/server/api/collection.get.js +8 -3
- package/dist/runtime/server/utils/relations.d.ts +1 -0
- package/dist/runtime/server/utils/relations.js +25 -0
- package/dist/runtime/shared/index.d.ts +10 -3
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { asc, eq, inArray } from "drizzle-orm";
|
|
2
2
|
import { createError } from "h3";
|
|
3
|
+
import cmsConfig from "#cms-config";
|
|
3
4
|
import { useDb } from "#cms-db";
|
|
4
5
|
import * as cmsTables from "#cms-tables";
|
|
5
6
|
import { resolveTable, tableColumns } from "./registry.js";
|
|
@@ -57,6 +58,30 @@ export async function saveManyToMany(db, name, sourceId, lists) {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
export async function relationTitles(db, entry, rows) {
|
|
62
|
+
const config = cmsConfig;
|
|
63
|
+
const titles = {};
|
|
64
|
+
for (const [key, field] of Object.entries(entry.fields)) {
|
|
65
|
+
if (field.type !== "relation" || !field.to) continue;
|
|
66
|
+
const targetEntry = config[field.to];
|
|
67
|
+
const target = resolveTable(field.to);
|
|
68
|
+
if (!targetEntry?.titleField || !target) continue;
|
|
69
|
+
const ids = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const row of rows) {
|
|
71
|
+
const value = row[key];
|
|
72
|
+
for (const id of Array.isArray(value) ? value : [value]) {
|
|
73
|
+
if (id != null) ids.add(String(id));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!ids.size) continue;
|
|
77
|
+
const columns = tableColumns(target);
|
|
78
|
+
const titleColumn = columns[targetEntry.titleField];
|
|
79
|
+
if (!titleColumn) continue;
|
|
80
|
+
const found = await db.select({ id: columns.id, title: titleColumn }).from(target).where(inArray(columns.id, [...ids]));
|
|
81
|
+
titles[key] = Object.fromEntries(found.map((row) => [row.id, row.title]));
|
|
82
|
+
}
|
|
83
|
+
return titles;
|
|
84
|
+
}
|
|
60
85
|
export async function attachManyToMany(db, name, entry, rows) {
|
|
61
86
|
const keys = manyToManyKeys(entry);
|
|
62
87
|
const ids = rows.map((row) => row.id).filter((id) => id != null);
|
|
@@ -121,14 +121,21 @@ export interface BlocksFieldInput extends FieldInputBase {
|
|
|
121
121
|
blocks: Record<string, BlockInput>;
|
|
122
122
|
}
|
|
123
123
|
export type CmsFieldInput = TextFieldInput | RichtextFieldInput | NumberFieldInput | BooleanFieldInput | DateFieldInput | EmailFieldInput | SlugFieldInput | SelectFieldInput | JsonFieldInput | MediaFieldInput | RelationFieldInput | BlocksFieldInput;
|
|
124
|
-
|
|
124
|
+
interface CmsEntryInputBase {
|
|
125
125
|
id: string;
|
|
126
126
|
label: string;
|
|
127
|
-
kind: 'collection' | 'single';
|
|
128
|
-
titleField?: string;
|
|
129
127
|
drafts?: boolean;
|
|
130
128
|
fields: Record<string, CmsFieldInput>;
|
|
131
129
|
}
|
|
130
|
+
export interface CmsCollectionInput extends CmsEntryInputBase {
|
|
131
|
+
kind: 'collection';
|
|
132
|
+
titleField: string;
|
|
133
|
+
}
|
|
134
|
+
export interface CmsSingleInput extends CmsEntryInputBase {
|
|
135
|
+
kind: 'single';
|
|
136
|
+
titleField?: never;
|
|
137
|
+
}
|
|
138
|
+
export type CmsEntryInput = CmsCollectionInput | CmsSingleInput;
|
|
132
139
|
export type CmsConfigInput = Record<string, CmsEntryInput>;
|
|
133
140
|
export declare function defineCmsConfig<T extends CmsConfigInput>(config: T): T;
|
|
134
141
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xleddyl/nuxt-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Edoardo Alberti (https://github.com/xleddyl)",
|