@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
|
@@ -0,0 +1,274 @@
|
|
|
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">Users</h2>
|
|
6
|
+
<p class="cms-settings-hint">
|
|
7
|
+
Users can do everything in the panel, except manage users.
|
|
8
|
+
</p>
|
|
9
|
+
</div>
|
|
10
|
+
<CmsButton
|
|
11
|
+
v-if="!creating"
|
|
12
|
+
label="Add user"
|
|
13
|
+
icon="user-plus"
|
|
14
|
+
size="sm"
|
|
15
|
+
@click="startCreate"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div v-if="created" class="cms-credentials">
|
|
20
|
+
<div class="cms-settings-heading">
|
|
21
|
+
<p class="cms-settings-label">{{ created.title }}</p>
|
|
22
|
+
<p class="cms-settings-hint">
|
|
23
|
+
Share these credentials with the user. The password does not show again.
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
26
|
+
<dl class="cms-credentials-list">
|
|
27
|
+
<dt>Email</dt>
|
|
28
|
+
<dd>{{ created.email }}</dd>
|
|
29
|
+
<dt>Password</dt>
|
|
30
|
+
<dd class="cms-mono">{{ created.password }}</dd>
|
|
31
|
+
</dl>
|
|
32
|
+
<div class="cms-actions is-end">
|
|
33
|
+
<CmsButton
|
|
34
|
+
:label="copied ? 'Copied' : 'Copy credentials'"
|
|
35
|
+
:icon="copied ? 'clipboard-document-check' : 'clipboard-document'"
|
|
36
|
+
variant="soft"
|
|
37
|
+
size="sm"
|
|
38
|
+
@click="copyCredentials"
|
|
39
|
+
/>
|
|
40
|
+
<CmsButton label="Done" size="sm" @click="created = null" />
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div v-if="creating" class="cms-credentials">
|
|
45
|
+
<p class="cms-settings-label">New user</p>
|
|
46
|
+
<CmsForm :state="draft" @submit="create">
|
|
47
|
+
<CmsAlert v-if="formError" color="error" :title="formError" />
|
|
48
|
+
<div class="cms-form-row" style="--cms-row-cols: 2">
|
|
49
|
+
<CmsFormField label="Email" name="email" required>
|
|
50
|
+
<CmsInput
|
|
51
|
+
v-model="draft.email"
|
|
52
|
+
type="email"
|
|
53
|
+
icon="envelope"
|
|
54
|
+
placeholder="name@example.com"
|
|
55
|
+
autocomplete="off"
|
|
56
|
+
/>
|
|
57
|
+
</CmsFormField>
|
|
58
|
+
<CmsFormField label="Name" name="name">
|
|
59
|
+
<CmsInput v-model="draft.name" placeholder="Optional" autocomplete="off" />
|
|
60
|
+
</CmsFormField>
|
|
61
|
+
</div>
|
|
62
|
+
<CmsFormField label="Password" name="password" required>
|
|
63
|
+
<CmsPasswordInput v-model="draft.password" generate copy />
|
|
64
|
+
</CmsFormField>
|
|
65
|
+
<div class="cms-actions is-end">
|
|
66
|
+
<CmsButton
|
|
67
|
+
label="Cancel"
|
|
68
|
+
variant="ghost"
|
|
69
|
+
color="neutral"
|
|
70
|
+
size="sm"
|
|
71
|
+
@click="cancel"
|
|
72
|
+
/>
|
|
73
|
+
<CmsButton
|
|
74
|
+
type="submit"
|
|
75
|
+
label="Create user"
|
|
76
|
+
size="sm"
|
|
77
|
+
:loading="busy"
|
|
78
|
+
:disabled="!draft.email || draft.password.length < MIN_PASSWORD_LENGTH"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</CmsForm>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<CmsSpinner v-if="loading" />
|
|
85
|
+
|
|
86
|
+
<ul v-else-if="users.length" class="cms-settings-list">
|
|
87
|
+
<li v-for="account in users" :key="account.id" class="cms-user-row">
|
|
88
|
+
<div class="cms-user-main">
|
|
89
|
+
<span class="cms-avatar">{{ initialOf(account.name, account.email) }}</span>
|
|
90
|
+
<div class="cms-account-text">
|
|
91
|
+
<span class="cms-account-name">{{ account.name || account.email }}</span>
|
|
92
|
+
<span class="cms-account-email">
|
|
93
|
+
{{ account.name ? `${account.email} \xB7 ` : "" }}{{ lastLogin(account) }}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="cms-user-actions">
|
|
97
|
+
<CmsButton
|
|
98
|
+
icon="key"
|
|
99
|
+
variant="ghost"
|
|
100
|
+
color="neutral"
|
|
101
|
+
size="sm"
|
|
102
|
+
title="Set a new password"
|
|
103
|
+
aria-label="Set a new password"
|
|
104
|
+
@click="startReset(account)"
|
|
105
|
+
/>
|
|
106
|
+
<CmsButton
|
|
107
|
+
icon="trash"
|
|
108
|
+
variant="ghost"
|
|
109
|
+
color="error"
|
|
110
|
+
size="sm"
|
|
111
|
+
title="Delete user"
|
|
112
|
+
aria-label="Delete user"
|
|
113
|
+
@click="remove(account)"
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<CmsForm
|
|
118
|
+
v-if="resetting === account.id"
|
|
119
|
+
:state="reset"
|
|
120
|
+
class="cms-user-reset"
|
|
121
|
+
@submit="saveReset(account)"
|
|
122
|
+
>
|
|
123
|
+
<CmsFormField label="New password" name="password">
|
|
124
|
+
<CmsPasswordInput v-model="reset.password" generate copy />
|
|
125
|
+
</CmsFormField>
|
|
126
|
+
<div class="cms-actions is-end">
|
|
127
|
+
<CmsButton
|
|
128
|
+
label="Cancel"
|
|
129
|
+
variant="ghost"
|
|
130
|
+
color="neutral"
|
|
131
|
+
size="sm"
|
|
132
|
+
@click="resetting = null"
|
|
133
|
+
/>
|
|
134
|
+
<CmsButton
|
|
135
|
+
type="submit"
|
|
136
|
+
label="Set password"
|
|
137
|
+
size="sm"
|
|
138
|
+
:loading="busy"
|
|
139
|
+
:disabled="reset.password.length < MIN_PASSWORD_LENGTH"
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
</CmsForm>
|
|
143
|
+
</li>
|
|
144
|
+
</ul>
|
|
145
|
+
|
|
146
|
+
<CmsEmptyState
|
|
147
|
+
v-else-if="!creating"
|
|
148
|
+
icon="users"
|
|
149
|
+
title="No users yet"
|
|
150
|
+
body="Add a user to give someone access to the panel."
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<script setup>
|
|
156
|
+
import { MIN_PASSWORD_LENGTH } from "#nuxt-cms";
|
|
157
|
+
import { onMounted, ref } from "#imports";
|
|
158
|
+
import { generatePassword, initialOf } from "../../composables/cms-account";
|
|
159
|
+
import { useCmsConfirm } from "../../composables/cms-confirm";
|
|
160
|
+
import { useCmsToast } from "../../composables/cms-toast";
|
|
161
|
+
import { cmsApi } from "../../utils/api";
|
|
162
|
+
import { errorMessage } from "../../utils/ui";
|
|
163
|
+
const toast = useCmsToast();
|
|
164
|
+
const confirmAction = useCmsConfirm();
|
|
165
|
+
const users = ref([]);
|
|
166
|
+
const loading = ref(true);
|
|
167
|
+
const busy = ref(false);
|
|
168
|
+
async function load() {
|
|
169
|
+
try {
|
|
170
|
+
users.value = await cmsApi("/api/cms/users");
|
|
171
|
+
} catch (error) {
|
|
172
|
+
toast.add({ title: "Could not load users", description: errorMessage(error), color: "error" });
|
|
173
|
+
} finally {
|
|
174
|
+
loading.value = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
onMounted(load);
|
|
178
|
+
function lastLogin(account) {
|
|
179
|
+
if (!account.lastLoginAt) return "Never signed in";
|
|
180
|
+
return `Last sign-in ${new Date(account.lastLoginAt).toLocaleString(void 0, {
|
|
181
|
+
dateStyle: "medium",
|
|
182
|
+
timeStyle: "short"
|
|
183
|
+
})}`;
|
|
184
|
+
}
|
|
185
|
+
const creating = ref(false);
|
|
186
|
+
const draft = ref({ email: "", name: "", password: "" });
|
|
187
|
+
const formError = ref(null);
|
|
188
|
+
const created = ref(null);
|
|
189
|
+
const copied = ref(false);
|
|
190
|
+
function startCreate() {
|
|
191
|
+
created.value = null;
|
|
192
|
+
formError.value = null;
|
|
193
|
+
draft.value = { email: "", name: "", password: generatePassword() };
|
|
194
|
+
creating.value = true;
|
|
195
|
+
}
|
|
196
|
+
function cancel() {
|
|
197
|
+
creating.value = false;
|
|
198
|
+
}
|
|
199
|
+
async function create() {
|
|
200
|
+
busy.value = true;
|
|
201
|
+
formError.value = null;
|
|
202
|
+
try {
|
|
203
|
+
const account = await cmsApi("/api/cms/users", {
|
|
204
|
+
method: "POST",
|
|
205
|
+
body: {
|
|
206
|
+
email: draft.value.email,
|
|
207
|
+
name: draft.value.name || null,
|
|
208
|
+
password: draft.value.password
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
users.value = [...users.value, account];
|
|
212
|
+
created.value = {
|
|
213
|
+
title: "User created",
|
|
214
|
+
email: account.email,
|
|
215
|
+
password: draft.value.password
|
|
216
|
+
};
|
|
217
|
+
copied.value = false;
|
|
218
|
+
creating.value = false;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
formError.value = errorMessage(error) ?? "User not created.";
|
|
221
|
+
} finally {
|
|
222
|
+
busy.value = false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function copyCredentials() {
|
|
226
|
+
if (!created.value) return;
|
|
227
|
+
try {
|
|
228
|
+
await navigator.clipboard.writeText(
|
|
229
|
+
`Email: ${created.value.email}
|
|
230
|
+
Password: ${created.value.password}`
|
|
231
|
+
);
|
|
232
|
+
copied.value = true;
|
|
233
|
+
} catch {
|
|
234
|
+
copied.value = false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const resetting = ref(null);
|
|
238
|
+
const reset = ref({ password: "" });
|
|
239
|
+
function startReset(account) {
|
|
240
|
+
reset.value = { password: generatePassword() };
|
|
241
|
+
resetting.value = resetting.value === account.id ? null : account.id;
|
|
242
|
+
}
|
|
243
|
+
async function saveReset(account) {
|
|
244
|
+
busy.value = true;
|
|
245
|
+
try {
|
|
246
|
+
const updated = await cmsApi(`/api/cms/users/${account.id}`, {
|
|
247
|
+
method: "PUT",
|
|
248
|
+
body: { password: reset.value.password }
|
|
249
|
+
});
|
|
250
|
+
users.value = users.value.map((u) => u.id === updated.id ? updated : u);
|
|
251
|
+
created.value = {
|
|
252
|
+
title: "Password changed",
|
|
253
|
+
email: account.email,
|
|
254
|
+
password: reset.value.password
|
|
255
|
+
};
|
|
256
|
+
copied.value = false;
|
|
257
|
+
resetting.value = null;
|
|
258
|
+
} catch (error) {
|
|
259
|
+
toast.add({ title: "Password not changed", description: errorMessage(error), color: "error" });
|
|
260
|
+
} finally {
|
|
261
|
+
busy.value = false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
async function remove(account) {
|
|
265
|
+
if (!await confirmAction(`Delete ${account.email}? They lose access to the panel.`)) return;
|
|
266
|
+
try {
|
|
267
|
+
await cmsApi(`/api/cms/users/${account.id}`, { method: "DELETE" });
|
|
268
|
+
users.value = users.value.filter((u) => u.id !== account.id);
|
|
269
|
+
toast.add({ title: "User deleted", color: "success" });
|
|
270
|
+
} catch (error) {
|
|
271
|
+
toast.add({ title: "User not deleted", description: errorMessage(error), color: "error" });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
</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;
|
|
@@ -4,7 +4,6 @@ interface Column {
|
|
|
4
4
|
accessorKey?: string;
|
|
5
5
|
accessorFn?: (row: Row) => unknown;
|
|
6
6
|
header?: string;
|
|
7
|
-
reorderable?: boolean;
|
|
8
7
|
sortable?: boolean;
|
|
9
8
|
}
|
|
10
9
|
interface TableSort {
|
|
@@ -14,33 +13,32 @@ interface TableSort {
|
|
|
14
13
|
type __VLS_Props = {
|
|
15
14
|
data: Row[];
|
|
16
15
|
columns: Column[];
|
|
16
|
+
selectable?: boolean;
|
|
17
17
|
};
|
|
18
18
|
type __VLS_ModelProps = {
|
|
19
|
-
'
|
|
19
|
+
'selected'?: string[];
|
|
20
20
|
'sort'?: TableSort | null;
|
|
21
21
|
};
|
|
22
22
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
23
|
-
declare var
|
|
23
|
+
declare var __VLS_21: `${string}-cell`, __VLS_22: {
|
|
24
24
|
row: {
|
|
25
25
|
original: Row;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
type __VLS_Slots = {} & {
|
|
29
|
-
[K in NonNullable<typeof
|
|
29
|
+
[K in NonNullable<typeof __VLS_21>]?: (props: typeof __VLS_22) => any;
|
|
30
30
|
};
|
|
31
31
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
32
|
select: (event: Event, row: {
|
|
33
33
|
original: Row;
|
|
34
34
|
}) => any;
|
|
35
|
-
|
|
36
|
-
"update:columnVisibility": (value: Record<string, boolean>) => any;
|
|
35
|
+
"update:selected": (value: string[]) => any;
|
|
37
36
|
"update:sort": (value: TableSort | null) => any;
|
|
38
37
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
39
38
|
onSelect?: ((event: Event, row: {
|
|
40
39
|
original: Row;
|
|
41
40
|
}) => any) | undefined;
|
|
42
|
-
|
|
43
|
-
"onUpdate:columnVisibility"?: ((value: Record<string, boolean>) => any) | undefined;
|
|
41
|
+
"onUpdate:selected"?: ((value: string[]) => any) | undefined;
|
|
44
42
|
"onUpdate:sort"?: ((value: TableSort | null) => any) | undefined;
|
|
45
43
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
46
44
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
<table class="cms-table">
|
|
5
5
|
<thead>
|
|
6
6
|
<tr>
|
|
7
|
+
<th v-if="selectable" class="cms-table-check-cell">
|
|
8
|
+
<CmsCheckbox
|
|
9
|
+
:checked="allSelected"
|
|
10
|
+
:indeterminate="someSelected"
|
|
11
|
+
aria-label="Select all rows"
|
|
12
|
+
@toggle="toggleAll"
|
|
13
|
+
/>
|
|
14
|
+
</th>
|
|
7
15
|
<th
|
|
8
|
-
v-for="column in
|
|
16
|
+
v-for="column in columns"
|
|
9
17
|
:key="columnId(column)"
|
|
10
18
|
:class="{
|
|
11
|
-
'is-dragging': draggingId === columnId(column),
|
|
12
|
-
'is-drop-target': dropTargetId === columnId(column),
|
|
13
19
|
'is-sortable': column.sortable,
|
|
14
20
|
'is-sorted': sort?.key === columnId(column)
|
|
15
21
|
}"
|
|
16
|
-
:draggable="column.reorderable || void 0"
|
|
17
22
|
:aria-sort="ariaSort(column)"
|
|
18
23
|
@click="toggleSort(column)"
|
|
19
|
-
@dragstart="onDragStart($event, column)"
|
|
20
|
-
@dragover="onDragOver($event, column)"
|
|
21
|
-
@dragleave="onDragLeave(column)"
|
|
22
|
-
@drop="onDrop($event, column)"
|
|
23
|
-
@dragend="resetDrag"
|
|
24
24
|
>
|
|
25
25
|
<span class="cms-th-label">
|
|
26
26
|
{{ column.header }}
|
|
@@ -36,11 +36,20 @@
|
|
|
36
36
|
<tbody>
|
|
37
37
|
<tr
|
|
38
38
|
v-for="(row, index) in data"
|
|
39
|
-
:key="
|
|
39
|
+
:key="keyOf(row)"
|
|
40
40
|
class="__clickable"
|
|
41
|
+
:class="{ 'is-selected': isSelected(row) }"
|
|
42
|
+
:style="{ '--cms-row-delay': `${Math.min(index, 14) * 24}ms` }"
|
|
41
43
|
@click="emit('select', $event, { original: row })"
|
|
42
44
|
>
|
|
43
|
-
<td v-
|
|
45
|
+
<td v-if="selectable" class="cms-table-check-cell" @click.stop="toggleRow(row)">
|
|
46
|
+
<CmsCheckbox
|
|
47
|
+
:checked="isSelected(row)"
|
|
48
|
+
aria-label="Select row"
|
|
49
|
+
@toggle="toggleRow(row)"
|
|
50
|
+
/>
|
|
51
|
+
</td>
|
|
52
|
+
<td v-for="column in columns" :key="columnId(column)">
|
|
44
53
|
<slot :name="`${columnId(column)}-cell`" :row="{ original: row }">
|
|
45
54
|
{{ cellValue(column, row) }}
|
|
46
55
|
</slot>
|
|
@@ -53,14 +62,32 @@
|
|
|
53
62
|
</template>
|
|
54
63
|
|
|
55
64
|
<script setup>
|
|
56
|
-
import { computed
|
|
65
|
+
import { computed } from "#imports";
|
|
57
66
|
const props = defineProps({
|
|
58
67
|
data: { type: Array, required: true },
|
|
59
|
-
columns: { type: Array, required: true }
|
|
68
|
+
columns: { type: Array, required: true },
|
|
69
|
+
selectable: { type: Boolean, required: false }
|
|
60
70
|
});
|
|
61
|
-
const
|
|
71
|
+
const selected = defineModel("selected", { type: Array, ...{ default: () => [] } });
|
|
72
|
+
function keyOf(row) {
|
|
73
|
+
return String(row.id);
|
|
74
|
+
}
|
|
75
|
+
function isSelected(row) {
|
|
76
|
+
return selected.value.includes(keyOf(row));
|
|
77
|
+
}
|
|
78
|
+
function toggleRow(row) {
|
|
79
|
+
const key = keyOf(row);
|
|
80
|
+
selected.value = isSelected(row) ? selected.value.filter((k) => k !== key) : [...selected.value, key];
|
|
81
|
+
}
|
|
82
|
+
const allSelected = computed(
|
|
83
|
+
() => props.data.length > 0 && props.data.every((row) => isSelected(row))
|
|
84
|
+
);
|
|
85
|
+
const someSelected = computed(() => !allSelected.value && selected.value.length > 0);
|
|
86
|
+
function toggleAll() {
|
|
87
|
+
selected.value = allSelected.value ? [] : props.data.map(keyOf);
|
|
88
|
+
}
|
|
62
89
|
const sort = defineModel("sort", { type: [Object, null], ...{ default: null } });
|
|
63
|
-
const emit = defineEmits(["select"
|
|
90
|
+
const emit = defineEmits(["select"]);
|
|
64
91
|
function columnId(column) {
|
|
65
92
|
return column.id ?? column.accessorKey ?? "";
|
|
66
93
|
}
|
|
@@ -80,38 +107,6 @@ function ariaSort(column) {
|
|
|
80
107
|
if (sort.value?.key !== columnId(column)) return "none";
|
|
81
108
|
return sort.value.order === "asc" ? "ascending" : "descending";
|
|
82
109
|
}
|
|
83
|
-
const draggingId = ref(null);
|
|
84
|
-
const dropTargetId = ref(null);
|
|
85
|
-
function resetDrag() {
|
|
86
|
-
draggingId.value = null;
|
|
87
|
-
dropTargetId.value = null;
|
|
88
|
-
}
|
|
89
|
-
function onDragStart(event, column) {
|
|
90
|
-
if (!column.reorderable) return;
|
|
91
|
-
draggingId.value = columnId(column);
|
|
92
|
-
event.dataTransfer?.setData("text/plain", columnId(column));
|
|
93
|
-
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
|
|
94
|
-
}
|
|
95
|
-
function onDragOver(event, column) {
|
|
96
|
-
if (!draggingId.value || !column.reorderable) return;
|
|
97
|
-
event.preventDefault();
|
|
98
|
-
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
|
99
|
-
dropTargetId.value = columnId(column);
|
|
100
|
-
}
|
|
101
|
-
function onDragLeave(column) {
|
|
102
|
-
if (dropTargetId.value === columnId(column)) dropTargetId.value = null;
|
|
103
|
-
}
|
|
104
|
-
function onDrop(event, column) {
|
|
105
|
-
if (!draggingId.value || !column.reorderable) return;
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
const from = draggingId.value;
|
|
108
|
-
const to = columnId(column);
|
|
109
|
-
resetDrag();
|
|
110
|
-
if (from !== to) emit("reorder", from, to);
|
|
111
|
-
}
|
|
112
|
-
const visibleColumns = computed(
|
|
113
|
-
() => props.columns.filter((column) => visibility.value[columnId(column)] !== false)
|
|
114
|
-
);
|
|
115
110
|
function cellValue(column, row) {
|
|
116
111
|
if (column.accessorFn) return column.accessorFn(row);
|
|
117
112
|
if (column.accessorKey) return row[column.accessorKey];
|
|
@@ -4,7 +4,6 @@ interface Column {
|
|
|
4
4
|
accessorKey?: string;
|
|
5
5
|
accessorFn?: (row: Row) => unknown;
|
|
6
6
|
header?: string;
|
|
7
|
-
reorderable?: boolean;
|
|
8
7
|
sortable?: boolean;
|
|
9
8
|
}
|
|
10
9
|
interface TableSort {
|
|
@@ -14,33 +13,32 @@ interface TableSort {
|
|
|
14
13
|
type __VLS_Props = {
|
|
15
14
|
data: Row[];
|
|
16
15
|
columns: Column[];
|
|
16
|
+
selectable?: boolean;
|
|
17
17
|
};
|
|
18
18
|
type __VLS_ModelProps = {
|
|
19
|
-
'
|
|
19
|
+
'selected'?: string[];
|
|
20
20
|
'sort'?: TableSort | null;
|
|
21
21
|
};
|
|
22
22
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
23
|
-
declare var
|
|
23
|
+
declare var __VLS_21: `${string}-cell`, __VLS_22: {
|
|
24
24
|
row: {
|
|
25
25
|
original: Row;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
type __VLS_Slots = {} & {
|
|
29
|
-
[K in NonNullable<typeof
|
|
29
|
+
[K in NonNullable<typeof __VLS_21>]?: (props: typeof __VLS_22) => any;
|
|
30
30
|
};
|
|
31
31
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
32
|
select: (event: Event, row: {
|
|
33
33
|
original: Row;
|
|
34
34
|
}) => any;
|
|
35
|
-
|
|
36
|
-
"update:columnVisibility": (value: Record<string, boolean>) => any;
|
|
35
|
+
"update:selected": (value: string[]) => any;
|
|
37
36
|
"update:sort": (value: TableSort | null) => any;
|
|
38
37
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
39
38
|
onSelect?: ((event: Event, row: {
|
|
40
39
|
original: Row;
|
|
41
40
|
}) => any) | undefined;
|
|
42
|
-
|
|
43
|
-
"onUpdate:columnVisibility"?: ((value: Record<string, boolean>) => any) | undefined;
|
|
41
|
+
"onUpdate:selected"?: ((value: string[]) => any) | undefined;
|
|
44
42
|
"onUpdate:sort"?: ((value: TableSort | null) => any) | undefined;
|
|
45
43
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
46
44
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<textarea
|
|
3
3
|
:rows="rows ?? 3"
|
|
4
4
|
:value="model ?? ''"
|
|
5
|
-
:class="['cms-field',
|
|
5
|
+
:class="['cms-field', 'cms-field-md', { 'is-error': color === 'error' }]"
|
|
6
6
|
@input="model = $event.target.value"
|
|
7
7
|
/>
|
|
8
8
|
</template>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
<script setup>
|
|
11
11
|
defineProps({
|
|
12
12
|
rows: { type: Number, required: false },
|
|
13
|
-
size: { type: String, required: false },
|
|
14
13
|
color: { type: String, required: false }
|
|
15
14
|
});
|
|
16
15
|
const model = defineModel({ type: [String, 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,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CmsModal :open="open" size="sm" title="Welcome to nuxt-cms" @update:open="(v) => !v && keep()">
|
|
3
|
+
<template #body>
|
|
4
|
+
<CmsForm :state="state" @submit="save">
|
|
5
|
+
<p class="cms-settings-hint">
|
|
6
|
+
You signed in with a password that someone shared with you. Set your own password
|
|
7
|
+
now, or keep this one. You can change it later in Settings, Account.
|
|
8
|
+
</p>
|
|
9
|
+
<CmsAlert v-if="error" color="error" :title="error" />
|
|
10
|
+
<CmsFormField label="New password" name="password">
|
|
11
|
+
<CmsPasswordInput v-model="state.password" generate copy />
|
|
12
|
+
</CmsFormField>
|
|
13
|
+
<div class="cms-actions is-end">
|
|
14
|
+
<CmsButton
|
|
15
|
+
label="Keep current password"
|
|
16
|
+
variant="ghost"
|
|
17
|
+
color="neutral"
|
|
18
|
+
:disabled="busy"
|
|
19
|
+
@click="keep"
|
|
20
|
+
/>
|
|
21
|
+
<CmsButton
|
|
22
|
+
type="submit"
|
|
23
|
+
label="Set password"
|
|
24
|
+
:loading="busy"
|
|
25
|
+
:disabled="state.password.length < MIN_PASSWORD_LENGTH"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
</CmsForm>
|
|
29
|
+
</template>
|
|
30
|
+
</CmsModal>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup>
|
|
34
|
+
import { MIN_PASSWORD_LENGTH } from "#nuxt-cms";
|
|
35
|
+
import { computed, ref } from "#imports";
|
|
36
|
+
import { useCmsAccount } from "../../composables/cms-account";
|
|
37
|
+
import { useCmsToast } from "../../composables/cms-toast";
|
|
38
|
+
import { cmsApi } from "../../utils/api";
|
|
39
|
+
import { errorMessage } from "../../utils/ui";
|
|
40
|
+
const { user, refresh } = useCmsAccount();
|
|
41
|
+
const toast = useCmsToast();
|
|
42
|
+
const dismissed = ref(false);
|
|
43
|
+
const open = computed(() => !!user.value?.firstLogin && !dismissed.value);
|
|
44
|
+
const state = ref({ password: "" });
|
|
45
|
+
const error = ref(null);
|
|
46
|
+
const busy = ref(false);
|
|
47
|
+
async function keep() {
|
|
48
|
+
dismissed.value = true;
|
|
49
|
+
await cmsApi("/api/cms/account/welcome", { method: "POST" }).catch(() => void 0);
|
|
50
|
+
await refresh();
|
|
51
|
+
}
|
|
52
|
+
async function save() {
|
|
53
|
+
busy.value = true;
|
|
54
|
+
error.value = null;
|
|
55
|
+
try {
|
|
56
|
+
await cmsApi("/api/cms/account/password", {
|
|
57
|
+
method: "PUT",
|
|
58
|
+
body: { newPassword: state.value.password }
|
|
59
|
+
});
|
|
60
|
+
dismissed.value = true;
|
|
61
|
+
await refresh();
|
|
62
|
+
toast.add({ title: "Password set", color: "success" });
|
|
63
|
+
} catch (e) {
|
|
64
|
+
error.value = errorMessage(e) ?? "Password not set.";
|
|
65
|
+
} finally {
|
|
66
|
+
busy.value = false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</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,11 @@
|
|
|
1
|
+
import type { CmsSessionUser } from '#nuxt-cms';
|
|
2
|
+
export declare function generatePassword(length?: number): string;
|
|
3
|
+
export declare function initialOf(name: string | null | undefined, email: string): string;
|
|
4
|
+
export declare function useCmsAccount(): {
|
|
5
|
+
user: import("vue").ComputedRef<CmsSessionUser | null>;
|
|
6
|
+
email: import("vue").ComputedRef<string>;
|
|
7
|
+
isSuperAdmin: import("vue").ComputedRef<boolean>;
|
|
8
|
+
displayName: import("vue").ComputedRef<string>;
|
|
9
|
+
initial: import("vue").ComputedRef<string>;
|
|
10
|
+
refresh: () => Promise<void>;
|
|
11
|
+
};
|