@xleddyl/nuxt-cms 0.1.61 → 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/dist/module.json +1 -1
- package/dist/module.mjs +133 -14
- package/dist/runtime/app/components/cms/BlocksField.vue +86 -10
- package/dist/runtime/app/components/cms/BrandMark.d.vue.ts +6 -0
- package/dist/runtime/app/components/cms/BrandMark.vue +19 -0
- package/dist/runtime/app/components/cms/BrandMark.vue.d.ts +6 -0
- package/dist/runtime/app/components/cms/Checkbox.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/Checkbox.vue +21 -0
- package/dist/runtime/app/components/cms/Checkbox.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/Drawer.vue +5 -9
- package/dist/runtime/app/components/cms/EmptyState.vue +4 -2
- package/dist/runtime/app/components/cms/EntryDrawer.vue +12 -3
- package/dist/runtime/app/components/cms/EntryForm.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/EntryForm.vue +104 -30
- package/dist/runtime/app/components/cms/EntryForm.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/FieldInput.vue +20 -5
- package/dist/runtime/app/components/cms/FormField.d.vue.ts +5 -3
- package/dist/runtime/app/components/cms/FormField.vue +8 -2
- package/dist/runtime/app/components/cms/FormField.vue.d.ts +5 -3
- package/dist/runtime/app/components/cms/Icon.vue +1 -1
- package/dist/runtime/app/components/cms/Input.d.vue.ts +0 -1
- package/dist/runtime/app/components/cms/Input.vue +7 -4
- package/dist/runtime/app/components/cms/Input.vue.d.ts +0 -1
- package/dist/runtime/app/components/cms/LocaleSwitch.vue +1 -1
- package/dist/runtime/app/components/cms/MediaFolderPicker.d.vue.ts +0 -1
- package/dist/runtime/app/components/cms/MediaFolderPicker.vue +1 -3
- package/dist/runtime/app/components/cms/MediaFolderPicker.vue.d.ts +0 -1
- package/dist/runtime/app/components/cms/MediaGallery.vue +24 -10
- package/dist/runtime/app/components/cms/MediaUpload.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/MediaUpload.vue +71 -41
- package/dist/runtime/app/components/cms/MediaUpload.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/Modal.vue +5 -9
- package/dist/runtime/app/components/cms/PageHeader.d.vue.ts +5 -3
- package/dist/runtime/app/components/cms/PageHeader.vue +16 -6
- package/dist/runtime/app/components/cms/PageHeader.vue.d.ts +5 -3
- package/dist/runtime/app/components/cms/PasswordInput.d.vue.ts +17 -0
- package/dist/runtime/app/components/cms/PasswordInput.vue +81 -0
- package/dist/runtime/app/components/cms/PasswordInput.vue.d.ts +17 -0
- package/dist/runtime/app/components/cms/RelationField.vue +7 -2
- package/dist/runtime/app/components/cms/SelectMenu.d.vue.ts +0 -1
- package/dist/runtime/app/components/cms/SelectMenu.vue +4 -11
- package/dist/runtime/app/components/cms/SelectMenu.vue.d.ts +0 -1
- package/dist/runtime/app/components/cms/SettingsAccount.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsAccount.vue +138 -0
- package/dist/runtime/app/components/cms/SettingsAccount.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsColumns.d.vue.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsColumns.vue +102 -0
- package/dist/runtime/app/components/cms/SettingsColumns.vue.d.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsEntry.d.vue.ts +6 -0
- package/dist/runtime/app/components/cms/SettingsEntry.vue +126 -0
- package/dist/runtime/app/components/cms/SettingsEntry.vue.d.ts +6 -0
- package/dist/runtime/app/components/cms/SettingsLayout.d.vue.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsLayout.vue +177 -0
- package/dist/runtime/app/components/cms/SettingsLayout.vue.d.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsModal.d.vue.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsModal.vue +174 -0
- package/dist/runtime/app/components/cms/SettingsModal.vue.d.ts +16 -0
- package/dist/runtime/app/components/cms/SettingsUsers.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsUsers.vue +274 -0
- package/dist/runtime/app/components/cms/SettingsUsers.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/Spinner.vue +2 -2
- package/dist/runtime/app/components/cms/Table.d.vue.ts +6 -8
- package/dist/runtime/app/components/cms/Table.vue +42 -47
- package/dist/runtime/app/components/cms/Table.vue.d.ts +6 -8
- package/dist/runtime/app/components/cms/Textarea.d.vue.ts +0 -1
- package/dist/runtime/app/components/cms/Textarea.vue +1 -2
- package/dist/runtime/app/components/cms/Textarea.vue.d.ts +0 -1
- package/dist/runtime/app/components/cms/Toaster.vue +1 -1
- package/dist/runtime/app/components/cms/WelcomeModal.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/WelcomeModal.vue +69 -0
- package/dist/runtime/app/components/cms/WelcomeModal.vue.d.ts +3 -0
- package/dist/runtime/app/composables/cms-account.d.ts +11 -0
- package/dist/runtime/app/composables/cms-account.js +23 -0
- package/dist/runtime/app/composables/cms-entry-disabled.js +1 -1
- package/dist/runtime/app/composables/cms-media-keys.d.ts +1 -0
- package/dist/runtime/app/composables/cms-media-keys.js +5 -0
- package/dist/runtime/app/composables/cms-media-library.js +3 -0
- package/dist/runtime/app/composables/cms-media-uploader.d.ts +11 -2
- package/dist/runtime/app/composables/cms-media-uploader.js +139 -12
- package/dist/runtime/app/composables/cms-overlay.d.ts +4 -0
- package/dist/runtime/app/composables/cms-overlay.js +23 -0
- package/dist/runtime/app/composables/cms-settings.d.ts +12 -0
- package/dist/runtime/app/composables/cms-settings.js +59 -0
- package/dist/runtime/app/composables/cms-theme.d.ts +9 -0
- package/dist/runtime/app/composables/cms-theme.js +27 -0
- package/dist/runtime/app/layouts/cms-admin.d.vue.ts +2 -2
- package/dist/runtime/app/layouts/cms-admin.vue +71 -17
- package/dist/runtime/app/layouts/cms-admin.vue.d.ts +2 -2
- package/dist/runtime/app/pages/admin-collection.vue +127 -101
- package/dist/runtime/app/pages/admin-entry.vue +2 -0
- package/dist/runtime/app/pages/admin-login.vue +18 -3
- package/dist/runtime/app/pages/admin-media.vue +5 -1
- package/dist/runtime/app/utils/ui.d.ts +2 -0
- package/dist/runtime/app/utils/ui.js +18 -0
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/generate.js +1 -1
- package/dist/runtime/server/api/account-password.put.d.ts +4 -0
- package/dist/runtime/server/api/account-password.put.js +38 -0
- package/dist/runtime/server/api/account-welcome.post.d.ts +4 -0
- package/dist/runtime/server/api/account-welcome.post.js +14 -0
- package/dist/runtime/server/api/account.put.d.ts +3 -0
- package/dist/runtime/server/api/account.put.js +25 -0
- package/dist/runtime/server/api/collection.get.js +1 -1
- package/dist/runtime/server/api/media.delete.js +2 -1
- package/dist/runtime/server/api/media.post.js +2 -1
- package/dist/runtime/server/api/media.put.js +2 -1
- package/dist/runtime/server/api/settings.delete.d.ts +4 -0
- package/dist/runtime/server/api/settings.delete.js +12 -0
- package/dist/runtime/server/api/settings.get.d.ts +3 -0
- package/dist/runtime/server/api/settings.get.js +15 -0
- package/dist/runtime/server/api/settings.put.d.ts +3 -0
- package/dist/runtime/server/api/settings.put.js +14 -0
- package/dist/runtime/server/api/user.delete.d.ts +4 -0
- package/dist/runtime/server/api/user.delete.js +12 -0
- package/dist/runtime/server/api/user.put.d.ts +3 -0
- package/dist/runtime/server/api/user.put.js +27 -0
- package/dist/runtime/server/api/users.get.d.ts +3 -0
- package/dist/runtime/server/api/users.get.js +11 -0
- package/dist/runtime/server/api/users.post.d.ts +3 -0
- package/dist/runtime/server/api/users.post.js +36 -0
- package/dist/runtime/server/plugins/session-validate.d.ts +2 -0
- package/dist/runtime/server/plugins/session-validate.js +13 -0
- package/dist/runtime/server/routes/auth/login.post.js +20 -10
- package/dist/runtime/server/utils/graphql-depth.js +12 -5
- package/dist/runtime/server/utils/graphql.js +2 -2
- package/dist/runtime/server/utils/media-folders.js +10 -2
- package/dist/runtime/server/utils/media.d.ts +1 -0
- package/dist/runtime/server/utils/media.js +4 -1
- package/dist/runtime/server/utils/migrate.js +1 -1
- package/dist/runtime/server/utils/password.d.ts +3 -0
- package/dist/runtime/server/utils/password.js +31 -0
- package/dist/runtime/server/utils/require-admin.d.ts +4 -2
- package/dist/runtime/server/utils/require-admin.js +32 -28
- package/dist/runtime/server/utils/same-origin.d.ts +2 -0
- package/dist/runtime/server/utils/same-origin.js +24 -0
- package/dist/runtime/server/utils/settings.d.ts +16 -0
- package/dist/runtime/server/utils/settings.js +31 -0
- package/dist/runtime/server/utils/users.d.ts +15 -0
- package/dist/runtime/server/utils/users.js +34 -0
- package/dist/runtime/shared/index.d.ts +13 -1
- package/dist/runtime/shared/index.js +2 -0
- package/dist/runtime/shared/layout.d.ts +33 -0
- package/dist/runtime/shared/layout.js +127 -0
- package/dist/runtime/shared/users.d.ts +18 -0
- package/dist/runtime/shared/users.js +1 -0
- package/dist/runtime/shared/validation.js +5 -4
- package/package.json +3 -3
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup>
|
|
30
|
-
import {
|
|
30
|
+
import { watch } from "#imports";
|
|
31
|
+
import { useCmsOverlay } from "../../composables/cms-overlay";
|
|
31
32
|
defineProps({
|
|
32
33
|
title: { type: String, required: false },
|
|
33
34
|
size: { type: String, required: false }
|
|
@@ -37,19 +38,14 @@ const emit = defineEmits(["after:leave"]);
|
|
|
37
38
|
function close() {
|
|
38
39
|
open.value = false;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
if (event.key === "Escape") close();
|
|
42
|
-
}
|
|
41
|
+
const overlay = useCmsOverlay(close);
|
|
43
42
|
watch(open, (value, previous) => {
|
|
44
43
|
if (import.meta.server) return;
|
|
45
44
|
if (value) {
|
|
46
|
-
|
|
45
|
+
overlay.activate();
|
|
47
46
|
} else {
|
|
48
|
-
|
|
47
|
+
overlay.deactivate();
|
|
49
48
|
if (previous) emit("after:leave");
|
|
50
49
|
}
|
|
51
50
|
});
|
|
52
|
-
onBeforeUnmount(() => {
|
|
53
|
-
if (import.meta.client) document.removeEventListener("keydown", onKeydown);
|
|
54
|
-
});
|
|
55
51
|
</script>
|
|
@@ -4,13 +4,15 @@ export interface CmsBreadcrumbLink {
|
|
|
4
4
|
}
|
|
5
5
|
type __VLS_Props = {
|
|
6
6
|
title: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
description?: string;
|
|
7
9
|
links?: CmsBreadcrumbLink[];
|
|
8
10
|
};
|
|
9
|
-
declare var
|
|
11
|
+
declare var __VLS_17: {}, __VLS_19: {};
|
|
10
12
|
type __VLS_Slots = {} & {
|
|
11
|
-
badge?: (props: typeof
|
|
13
|
+
badge?: (props: typeof __VLS_17) => any;
|
|
12
14
|
} & {
|
|
13
|
-
default?: (props: typeof
|
|
15
|
+
default?: (props: typeof __VLS_19) => any;
|
|
14
16
|
};
|
|
15
17
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
18
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -4,14 +4,22 @@
|
|
|
4
4
|
<nav v-if="links?.length" class="cms-breadcrumb">
|
|
5
5
|
<template v-for="link in links" :key="link.to">
|
|
6
6
|
<NuxtLink :to="link.to" class="cms-breadcrumb-link">{{ link.label }}</NuxtLink>
|
|
7
|
-
<CmsIcon name="chevron-right" class="cms-breadcrumb-separator size-
|
|
7
|
+
<CmsIcon name="chevron-right" class="cms-breadcrumb-separator size-3" />
|
|
8
8
|
</template>
|
|
9
9
|
</nav>
|
|
10
|
-
<div class="cms-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
</
|
|
14
|
-
<
|
|
10
|
+
<div class="cms-page-title-row">
|
|
11
|
+
<span v-if="icon" class="cms-page-icon">
|
|
12
|
+
<CmsIcon :name="icon" class="size-[18px]" />
|
|
13
|
+
</span>
|
|
14
|
+
<div class="cms-page-title-text">
|
|
15
|
+
<div class="cms-actions">
|
|
16
|
+
<h1 class="cms-title cms-title-md">
|
|
17
|
+
{{ title }}
|
|
18
|
+
</h1>
|
|
19
|
+
<slot name="badge" />
|
|
20
|
+
</div>
|
|
21
|
+
<p v-if="description" class="cms-page-description">{{ description }}</p>
|
|
22
|
+
</div>
|
|
15
23
|
</div>
|
|
16
24
|
</div>
|
|
17
25
|
<slot />
|
|
@@ -21,6 +29,8 @@
|
|
|
21
29
|
<script setup>
|
|
22
30
|
defineProps({
|
|
23
31
|
title: { type: String, required: true },
|
|
32
|
+
icon: { type: String, required: false },
|
|
33
|
+
description: { type: String, required: false },
|
|
24
34
|
links: { type: Array, required: false }
|
|
25
35
|
});
|
|
26
36
|
</script>
|
|
@@ -4,13 +4,15 @@ export interface CmsBreadcrumbLink {
|
|
|
4
4
|
}
|
|
5
5
|
type __VLS_Props = {
|
|
6
6
|
title: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
description?: string;
|
|
7
9
|
links?: CmsBreadcrumbLink[];
|
|
8
10
|
};
|
|
9
|
-
declare var
|
|
11
|
+
declare var __VLS_17: {}, __VLS_19: {};
|
|
10
12
|
type __VLS_Slots = {} & {
|
|
11
|
-
badge?: (props: typeof
|
|
13
|
+
badge?: (props: typeof __VLS_17) => any;
|
|
12
14
|
} & {
|
|
13
|
-
default?: (props: typeof
|
|
15
|
+
default?: (props: typeof __VLS_19) => any;
|
|
14
16
|
};
|
|
15
17
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
18
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
generate?: boolean;
|
|
3
|
+
copy?: boolean;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
autocomplete?: string;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_ModelProps = {
|
|
8
|
+
modelValue: string;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
+
"update:modelValue": (value: string) => any;
|
|
13
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CmsInput
|
|
3
|
+
v-model="model"
|
|
4
|
+
:type="visible ? 'text' : 'password'"
|
|
5
|
+
icon="key"
|
|
6
|
+
class="cms-password-input"
|
|
7
|
+
:autocomplete="autocomplete ?? 'new-password'"
|
|
8
|
+
:placeholder="placeholder"
|
|
9
|
+
>
|
|
10
|
+
<template #trailing>
|
|
11
|
+
<span class="cms-password-actions">
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
class="cms-password-action"
|
|
15
|
+
:title="visible ? 'Hide password' : 'Show password'"
|
|
16
|
+
:aria-label="visible ? 'Hide password' : 'Show password'"
|
|
17
|
+
@click="visible = !visible"
|
|
18
|
+
>
|
|
19
|
+
<CmsIcon :name="visible ? 'eye-slash' : 'eye'" class="size-4" />
|
|
20
|
+
</button>
|
|
21
|
+
<button
|
|
22
|
+
v-if="generate"
|
|
23
|
+
type="button"
|
|
24
|
+
class="cms-password-action"
|
|
25
|
+
title="Generate a password"
|
|
26
|
+
aria-label="Generate a password"
|
|
27
|
+
@click="regenerate"
|
|
28
|
+
>
|
|
29
|
+
<CmsIcon name="sparkles" class="size-4" />
|
|
30
|
+
</button>
|
|
31
|
+
<button
|
|
32
|
+
v-if="copy"
|
|
33
|
+
type="button"
|
|
34
|
+
class="cms-password-action"
|
|
35
|
+
:class="{ 'is-done': copied }"
|
|
36
|
+
:title="copied ? 'Copied' : 'Copy password'"
|
|
37
|
+
:aria-label="copied ? 'Copied' : 'Copy password'"
|
|
38
|
+
:disabled="!model"
|
|
39
|
+
@click="copyPassword"
|
|
40
|
+
>
|
|
41
|
+
<CmsIcon
|
|
42
|
+
:name="copied ? 'clipboard-document-check' : 'clipboard-document'"
|
|
43
|
+
class="size-4"
|
|
44
|
+
/>
|
|
45
|
+
</button>
|
|
46
|
+
</span>
|
|
47
|
+
</template>
|
|
48
|
+
</CmsInput>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup>
|
|
52
|
+
import { ref } from "#imports";
|
|
53
|
+
import { generatePassword } from "../../composables/cms-account";
|
|
54
|
+
defineProps({
|
|
55
|
+
generate: { type: Boolean, required: false },
|
|
56
|
+
copy: { type: Boolean, required: false },
|
|
57
|
+
placeholder: { type: String, required: false },
|
|
58
|
+
autocomplete: { type: String, required: false }
|
|
59
|
+
});
|
|
60
|
+
const model = defineModel({ type: String, ...{ required: true } });
|
|
61
|
+
const visible = ref(false);
|
|
62
|
+
const copied = ref(false);
|
|
63
|
+
let copiedTimer;
|
|
64
|
+
function regenerate() {
|
|
65
|
+
model.value = generatePassword();
|
|
66
|
+
visible.value = true;
|
|
67
|
+
}
|
|
68
|
+
async function copyPassword() {
|
|
69
|
+
if (!model.value) return;
|
|
70
|
+
try {
|
|
71
|
+
await navigator.clipboard.writeText(model.value);
|
|
72
|
+
copied.value = true;
|
|
73
|
+
clearTimeout(copiedTimer);
|
|
74
|
+
copiedTimer = setTimeout(() => {
|
|
75
|
+
copied.value = false;
|
|
76
|
+
}, 1600);
|
|
77
|
+
} catch {
|
|
78
|
+
copied.value = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
generate?: boolean;
|
|
3
|
+
copy?: boolean;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
autocomplete?: string;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_ModelProps = {
|
|
8
|
+
modelValue: string;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
+
"update:modelValue": (value: string) => any;
|
|
13
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
24
|
import { isTranslatableField } from "#nuxt-cms";
|
|
25
|
-
import { computed, onMounted, ref, watch } from "#imports";
|
|
25
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from "#imports";
|
|
26
26
|
import cmsConfig from "#cms-config";
|
|
27
27
|
import { useCmsRuntime } from "../../composables/cms-runtime";
|
|
28
28
|
import { useCmsToast } from "../../composables/cms-toast";
|
|
@@ -40,22 +40,26 @@ const fetched = ref([]);
|
|
|
40
40
|
const selectedRows = ref(/* @__PURE__ */ new Map());
|
|
41
41
|
const loading = ref(true);
|
|
42
42
|
const searchTerm = ref("");
|
|
43
|
+
let fetchRequest = 0;
|
|
43
44
|
async function fetchOptions() {
|
|
45
|
+
const request = ++fetchRequest;
|
|
44
46
|
loading.value = true;
|
|
45
47
|
try {
|
|
46
48
|
const term = searchTerm.value.trim();
|
|
47
49
|
const page = await $fetch(endpoint, {
|
|
48
50
|
query: { light: "true", limit: 25, ...term ? { search: term } : {} }
|
|
49
51
|
});
|
|
52
|
+
if (request !== fetchRequest) return;
|
|
50
53
|
fetched.value = page.items;
|
|
51
54
|
} catch (err) {
|
|
55
|
+
if (request !== fetchRequest) return;
|
|
52
56
|
toast.add({
|
|
53
57
|
title: "Loading failed",
|
|
54
58
|
description: errorMessage(err),
|
|
55
59
|
color: "error"
|
|
56
60
|
});
|
|
57
61
|
} finally {
|
|
58
|
-
loading.value = false;
|
|
62
|
+
if (request === fetchRequest) loading.value = false;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
let searchTimer;
|
|
@@ -63,6 +67,7 @@ watch(searchTerm, () => {
|
|
|
63
67
|
clearTimeout(searchTimer);
|
|
64
68
|
searchTimer = setTimeout(() => void fetchOptions(), 300);
|
|
65
69
|
});
|
|
70
|
+
onBeforeUnmount(() => clearTimeout(searchTimer));
|
|
66
71
|
const selectedIds = computed(() => {
|
|
67
72
|
if (props.multiple) return model.value ?? [];
|
|
68
73
|
return model.value ? [model.value] : [];
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="root" class="relative w-full">
|
|
3
|
-
<div
|
|
4
|
-
class="cms-field flex flex-wrap items-center gap-1"
|
|
5
|
-
:class="`cms-field-${size ?? 'md'}`"
|
|
6
|
-
@click="focusInput"
|
|
7
|
-
>
|
|
3
|
+
<div class="cms-field cms-field-md flex flex-wrap items-center gap-1" @click="focusInput">
|
|
8
4
|
<template v-if="multiple">
|
|
9
5
|
<span v-for="value in modelArray" :key="value" class="cms-tag">
|
|
10
6
|
{{ labelFor(value) }}
|
|
@@ -25,11 +21,9 @@
|
|
|
25
21
|
@input="onInput"
|
|
26
22
|
@focus="onFocus"
|
|
27
23
|
/>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class="cms-selectmenu-affix ml-auto size-4 animate-spin"
|
|
32
|
-
/>
|
|
24
|
+
<span v-if="loading" class="cms-selectmenu-affix ml-auto flex">
|
|
25
|
+
<CmsIcon name="arrow-path" class="size-4 animate-spin" />
|
|
26
|
+
</span>
|
|
33
27
|
<button
|
|
34
28
|
v-else
|
|
35
29
|
type="button"
|
|
@@ -72,7 +66,6 @@ const props = defineProps({
|
|
|
72
66
|
multiple: { type: Boolean, required: false },
|
|
73
67
|
ignoreFilter: { type: Boolean, required: false },
|
|
74
68
|
loading: { type: Boolean, required: false },
|
|
75
|
-
size: { type: String, required: false },
|
|
76
69
|
placeholder: { type: String, required: false }
|
|
77
70
|
});
|
|
78
71
|
const model = defineModel({ type: [String, Array, null] });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cms-settings-entry">
|
|
3
|
+
<div class="cms-settings-entry-header">
|
|
4
|
+
<div class="cms-settings-heading">
|
|
5
|
+
<h2 class="cms-title cms-title-sm">Account</h2>
|
|
6
|
+
<p class="cms-settings-hint">Your profile and your password.</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="cms-account-card">
|
|
11
|
+
<span class="cms-avatar is-lg">{{ initial }}</span>
|
|
12
|
+
<div class="cms-account-text">
|
|
13
|
+
<span class="cms-account-name">{{ displayName }}</span>
|
|
14
|
+
<span class="cms-account-email">{{ email }}</span>
|
|
15
|
+
</div>
|
|
16
|
+
<span class="cms-badge is-muted">{{ isSuperAdmin ? "Super admin" : "Admin" }}</span>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<CmsAlert v-if="isSuperAdmin" color="neutral" title="Environment account">
|
|
20
|
+
This account signs in with the credentials of the environment variables
|
|
21
|
+
(NUXT_CMS_ADMIN_EMAIL and NUXT_CMS_ADMIN_PASSWORD). Change them there. Only this account
|
|
22
|
+
can manage users.
|
|
23
|
+
</CmsAlert>
|
|
24
|
+
|
|
25
|
+
<template v-else>
|
|
26
|
+
<div class="cms-settings-group">
|
|
27
|
+
<div class="cms-settings-heading">
|
|
28
|
+
<p class="cms-settings-label">Profile</p>
|
|
29
|
+
<p class="cms-settings-hint">The name shows in the sidebar.</p>
|
|
30
|
+
</div>
|
|
31
|
+
<CmsForm :state="profile" @submit="saveProfile">
|
|
32
|
+
<div class="cms-form-row" style="--cms-row-cols: 2">
|
|
33
|
+
<CmsFormField label="Name" name="name">
|
|
34
|
+
<CmsInput v-model="profile.name" placeholder="Your name" autocomplete="name" />
|
|
35
|
+
</CmsFormField>
|
|
36
|
+
<CmsFormField label="Email" name="email">
|
|
37
|
+
<CmsInput :model-value="email" disabled />
|
|
38
|
+
</CmsFormField>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="cms-actions is-end">
|
|
41
|
+
<CmsButton
|
|
42
|
+
type="submit"
|
|
43
|
+
label="Save profile"
|
|
44
|
+
size="sm"
|
|
45
|
+
:loading="savingProfile"
|
|
46
|
+
:disabled="profile.name === (user?.name ?? '')"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</CmsForm>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div class="cms-settings-group">
|
|
53
|
+
<div class="cms-settings-heading">
|
|
54
|
+
<p class="cms-settings-label">Password</p>
|
|
55
|
+
<p class="cms-settings-hint">
|
|
56
|
+
At least {{ MIN_PASSWORD_LENGTH }} characters. Use the sparkle button to generate
|
|
57
|
+
one.
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
<CmsForm :state="password" @submit="savePassword">
|
|
61
|
+
<CmsAlert v-if="passwordError" color="error" :title="passwordError" />
|
|
62
|
+
<CmsFormField label="Current password" name="current">
|
|
63
|
+
<CmsPasswordInput
|
|
64
|
+
v-model="password.current"
|
|
65
|
+
autocomplete="current-password"
|
|
66
|
+
placeholder="••••••••"
|
|
67
|
+
/>
|
|
68
|
+
</CmsFormField>
|
|
69
|
+
<CmsFormField label="New password" name="next">
|
|
70
|
+
<CmsPasswordInput v-model="password.next" generate copy />
|
|
71
|
+
</CmsFormField>
|
|
72
|
+
<div class="cms-actions is-end">
|
|
73
|
+
<CmsButton
|
|
74
|
+
type="submit"
|
|
75
|
+
label="Change password"
|
|
76
|
+
size="sm"
|
|
77
|
+
:loading="savingPassword"
|
|
78
|
+
:disabled="!password.current || password.next.length < MIN_PASSWORD_LENGTH"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</CmsForm>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup>
|
|
88
|
+
import { MIN_PASSWORD_LENGTH } from "#nuxt-cms";
|
|
89
|
+
import { ref, watch } from "#imports";
|
|
90
|
+
import { useCmsAccount } from "../../composables/cms-account";
|
|
91
|
+
import { useCmsToast } from "../../composables/cms-toast";
|
|
92
|
+
import { cmsApi } from "../../utils/api";
|
|
93
|
+
import { errorMessage } from "../../utils/ui";
|
|
94
|
+
const { user, email, isSuperAdmin, displayName, initial, refresh } = useCmsAccount();
|
|
95
|
+
const toast = useCmsToast();
|
|
96
|
+
const profile = ref({ name: user.value?.name ?? "" });
|
|
97
|
+
watch(
|
|
98
|
+
() => user.value?.name,
|
|
99
|
+
(name) => {
|
|
100
|
+
profile.value.name = name ?? "";
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
const savingProfile = ref(false);
|
|
104
|
+
async function saveProfile() {
|
|
105
|
+
savingProfile.value = true;
|
|
106
|
+
try {
|
|
107
|
+
await cmsApi("/api/cms/account", {
|
|
108
|
+
method: "PUT",
|
|
109
|
+
body: { name: profile.value.name || null }
|
|
110
|
+
});
|
|
111
|
+
await refresh();
|
|
112
|
+
toast.add({ title: "Profile saved", color: "success" });
|
|
113
|
+
} catch (error) {
|
|
114
|
+
toast.add({ title: "Profile not saved", description: errorMessage(error), color: "error" });
|
|
115
|
+
} finally {
|
|
116
|
+
savingProfile.value = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const password = ref({ current: "", next: "" });
|
|
120
|
+
const passwordError = ref(null);
|
|
121
|
+
const savingPassword = ref(false);
|
|
122
|
+
async function savePassword() {
|
|
123
|
+
savingPassword.value = true;
|
|
124
|
+
passwordError.value = null;
|
|
125
|
+
try {
|
|
126
|
+
await cmsApi("/api/cms/account/password", {
|
|
127
|
+
method: "PUT",
|
|
128
|
+
body: { currentPassword: password.value.current, newPassword: password.value.next }
|
|
129
|
+
});
|
|
130
|
+
password.value = { current: "", next: "" };
|
|
131
|
+
toast.add({ title: "Password changed", color: "success" });
|
|
132
|
+
} catch (error) {
|
|
133
|
+
passwordError.value = errorMessage(error) ?? "Password not changed.";
|
|
134
|
+
} finally {
|
|
135
|
+
savingPassword.value = false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</script>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FieldConfig } from '#nuxt-cms';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
fields: Record<string, FieldConfig>;
|
|
4
|
+
extra: string[];
|
|
5
|
+
};
|
|
6
|
+
type __VLS_ModelProps = {
|
|
7
|
+
modelValue: string[];
|
|
8
|
+
};
|
|
9
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
"update:modelValue": (value: string[]) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
13
|
+
"onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cms-settings-columns">
|
|
3
|
+
<p class="cms-settings-hint">
|
|
4
|
+
Choose the columns of the table. Drag the visible columns to change their order.
|
|
5
|
+
</p>
|
|
6
|
+
<ul class="cms-settings-list">
|
|
7
|
+
<li
|
|
8
|
+
v-for="(key, index) in model"
|
|
9
|
+
:key="key"
|
|
10
|
+
class="cms-settings-item is-draggable"
|
|
11
|
+
:class="{
|
|
12
|
+
'is-dragging': dragging === key,
|
|
13
|
+
'is-drop-before': dropIndex === index && dragging !== key
|
|
14
|
+
}"
|
|
15
|
+
draggable="true"
|
|
16
|
+
@dragstart="onDragStart($event, key)"
|
|
17
|
+
@dragover.prevent="dropIndex = index"
|
|
18
|
+
@drop.prevent="onDrop(index)"
|
|
19
|
+
@dragend="onDragEnd"
|
|
20
|
+
>
|
|
21
|
+
<CmsIcon name="bars-2" class="cms-settings-grip size-4" />
|
|
22
|
+
<CmsIcon :name="iconOf(key)" class="cms-settings-item-icon size-4" />
|
|
23
|
+
<span class="cms-settings-item-label">{{ labelOf(key) }}</span>
|
|
24
|
+
<CmsSwitch
|
|
25
|
+
:model-value="true"
|
|
26
|
+
:aria-label="`Hide ${labelOf(key)}`"
|
|
27
|
+
:disabled="model.length === 1"
|
|
28
|
+
@update:model-value="hide(key)"
|
|
29
|
+
/>
|
|
30
|
+
</li>
|
|
31
|
+
<li
|
|
32
|
+
v-if="dragging"
|
|
33
|
+
class="cms-settings-drop-end"
|
|
34
|
+
:class="{ 'is-over': dropIndex === model.length }"
|
|
35
|
+
@dragover.prevent="dropIndex = model.length"
|
|
36
|
+
@drop.prevent="onDrop(model.length)"
|
|
37
|
+
/>
|
|
38
|
+
</ul>
|
|
39
|
+
|
|
40
|
+
<template v-if="hidden.length">
|
|
41
|
+
<p class="cms-settings-subtitle">Hidden</p>
|
|
42
|
+
<ul class="cms-settings-list">
|
|
43
|
+
<li v-for="key in hidden" :key="key" class="cms-settings-item is-muted">
|
|
44
|
+
<CmsIcon :name="iconOf(key)" class="cms-settings-item-icon size-4" />
|
|
45
|
+
<span class="cms-settings-item-label">{{ labelOf(key) }}</span>
|
|
46
|
+
<CmsSwitch
|
|
47
|
+
:model-value="false"
|
|
48
|
+
:aria-label="`Show ${labelOf(key)}`"
|
|
49
|
+
@update:model-value="show(key)"
|
|
50
|
+
/>
|
|
51
|
+
</li>
|
|
52
|
+
</ul>
|
|
53
|
+
</template>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script setup>
|
|
58
|
+
import { computed, ref } from "#imports";
|
|
59
|
+
import { fieldIcon } from "../../utils/ui";
|
|
60
|
+
const props = defineProps({
|
|
61
|
+
fields: { type: Object, required: true },
|
|
62
|
+
extra: { type: Array, required: true }
|
|
63
|
+
});
|
|
64
|
+
const model = defineModel({ type: Array, ...{ required: true } });
|
|
65
|
+
const available = computed(() => [...Object.keys(props.fields), ...props.extra]);
|
|
66
|
+
const hidden = computed(() => available.value.filter((key) => !model.value.includes(key)));
|
|
67
|
+
function labelOf(key) {
|
|
68
|
+
return props.fields[key]?.label ?? (key === "status" ? "Status" : key);
|
|
69
|
+
}
|
|
70
|
+
function iconOf(key) {
|
|
71
|
+
const field = props.fields[key];
|
|
72
|
+
return field ? fieldIcon(field) : "check-circle";
|
|
73
|
+
}
|
|
74
|
+
function hide(key) {
|
|
75
|
+
if (model.value.length === 1) return;
|
|
76
|
+
model.value = model.value.filter((k) => k !== key);
|
|
77
|
+
}
|
|
78
|
+
function show(key) {
|
|
79
|
+
model.value = [...model.value, key];
|
|
80
|
+
}
|
|
81
|
+
const dragging = ref(null);
|
|
82
|
+
const dropIndex = ref(null);
|
|
83
|
+
function onDragStart(event, key) {
|
|
84
|
+
dragging.value = key;
|
|
85
|
+
event.dataTransfer?.setData("text/plain", key);
|
|
86
|
+
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
|
|
87
|
+
}
|
|
88
|
+
function onDrop(index) {
|
|
89
|
+
const key = dragging.value;
|
|
90
|
+
if (key) {
|
|
91
|
+
const next = model.value.filter((k) => k !== key);
|
|
92
|
+
const from = model.value.indexOf(key);
|
|
93
|
+
next.splice(from < index ? index - 1 : index, 0, key);
|
|
94
|
+
model.value = next;
|
|
95
|
+
}
|
|
96
|
+
onDragEnd();
|
|
97
|
+
}
|
|
98
|
+
function onDragEnd() {
|
|
99
|
+
dragging.value = null;
|
|
100
|
+
dropIndex.value = null;
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FieldConfig } from '#nuxt-cms';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
fields: Record<string, FieldConfig>;
|
|
4
|
+
extra: string[];
|
|
5
|
+
};
|
|
6
|
+
type __VLS_ModelProps = {
|
|
7
|
+
modelValue: string[];
|
|
8
|
+
};
|
|
9
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
"update:modelValue": (value: string[]) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
13
|
+
"onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
name: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|