nuxt-users 1.27.0 → 1.28.0
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/CHANGELOG.md +20 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/NUsersList.vue +19 -14
- package/dist/runtime/components/NUsersLogoutLink.vue +10 -3
- package/dist/runtime/components/NUsersLogoutLink.vue.d.ts +2 -2
- package/dist/runtime/components/NUsersProfileInfo.vue +6 -1
- package/dist/runtime/components/NUsersUserCard.vue +7 -2
- package/dist/runtime/components/NUsersUserForm.vue.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.28.0
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.27.0...v1.28.0)
|
|
7
|
+
|
|
8
|
+
### 🚀 Enhancements
|
|
9
|
+
|
|
10
|
+
- Expose useUsers composable ([485d81c](https://github.com/rrd108/nuxt-users/commit/485d81c))
|
|
11
|
+
|
|
12
|
+
### 🩹 Fixes
|
|
13
|
+
|
|
14
|
+
- Composables are initialized on mount ([b25eb95](https://github.com/rrd108/nuxt-users/commit/b25eb95))
|
|
15
|
+
|
|
16
|
+
### 🏡 Chore
|
|
17
|
+
|
|
18
|
+
- **release:** V1.27.0 ([195a5b7](https://github.com/rrd108/nuxt-users/commit/195a5b7))
|
|
19
|
+
|
|
20
|
+
### ❤️ Contributors
|
|
21
|
+
|
|
22
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
23
|
+
|
|
4
24
|
## v1.27.0
|
|
5
25
|
|
|
6
26
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.26.0...v1.27.0)
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { onMounted } from "vue";
|
|
2
|
+
import { onMounted, computed } from "vue";
|
|
3
3
|
import { useUsers } from "../composables/useUsers";
|
|
4
4
|
import { defaultDisplayFields, defaultFieldLabels } from "nuxt-users/utils";
|
|
5
5
|
defineProps({
|
|
@@ -7,23 +7,28 @@ defineProps({
|
|
|
7
7
|
fieldLabels: { type: Object, required: false, default: () => defaultFieldLabels }
|
|
8
8
|
});
|
|
9
9
|
const emit = defineEmits(["editClick", "delete"]);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fetchUsers,
|
|
16
|
-
removeUser
|
|
17
|
-
} = useUsers();
|
|
10
|
+
let usersComposable = null;
|
|
11
|
+
const users = computed(() => usersComposable?.users.value ?? []);
|
|
12
|
+
const pagination = computed(() => usersComposable?.pagination.value ?? null);
|
|
13
|
+
const loading = computed(() => usersComposable?.loading.value ?? false);
|
|
14
|
+
const error = computed(() => usersComposable?.error.value ?? null);
|
|
18
15
|
onMounted(() => {
|
|
16
|
+
usersComposable = useUsers();
|
|
19
17
|
if (users.value.length === 0) {
|
|
20
|
-
fetchUsers();
|
|
18
|
+
usersComposable.fetchUsers();
|
|
21
19
|
}
|
|
22
20
|
});
|
|
23
21
|
const handleDelete = (user) => {
|
|
24
|
-
|
|
22
|
+
if (usersComposable) {
|
|
23
|
+
usersComposable.removeUser(user.id);
|
|
24
|
+
}
|
|
25
25
|
emit("delete", user);
|
|
26
26
|
};
|
|
27
|
+
const handleFetchUsers = (page, limit) => {
|
|
28
|
+
if (usersComposable) {
|
|
29
|
+
usersComposable.fetchUsers(page, limit);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
27
32
|
</script>
|
|
28
33
|
|
|
29
34
|
<template>
|
|
@@ -102,7 +107,7 @@ const handleDelete = (user) => {
|
|
|
102
107
|
<slot
|
|
103
108
|
name="pagination"
|
|
104
109
|
:pagination="pagination"
|
|
105
|
-
:fetch-users="
|
|
110
|
+
:fetch-users="handleFetchUsers"
|
|
106
111
|
:loading="loading"
|
|
107
112
|
>
|
|
108
113
|
<div v-if="pagination && pagination.totalPages > 1">
|
|
@@ -110,7 +115,7 @@ const handleDelete = (user) => {
|
|
|
110
115
|
<button
|
|
111
116
|
v-if="pagination.hasPrev"
|
|
112
117
|
:disabled="loading"
|
|
113
|
-
@click="
|
|
118
|
+
@click="handleFetchUsers(pagination.page - 1)"
|
|
114
119
|
>
|
|
115
120
|
Previous
|
|
116
121
|
</button>
|
|
@@ -118,7 +123,7 @@ const handleDelete = (user) => {
|
|
|
118
123
|
<button
|
|
119
124
|
v-if="pagination.hasNext"
|
|
120
125
|
:disabled="loading"
|
|
121
|
-
@click="
|
|
126
|
+
@click="handleFetchUsers(pagination.page + 1)"
|
|
122
127
|
>
|
|
123
128
|
Next
|
|
124
129
|
</button>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref } from "vue";
|
|
2
|
+
import { ref, onMounted } from "vue";
|
|
3
3
|
import { navigateTo } from "#app";
|
|
4
4
|
import { useAuthentication } from "../composables/useAuthentication";
|
|
5
5
|
const props = defineProps({
|
|
@@ -16,19 +16,26 @@ const props = defineProps({
|
|
|
16
16
|
containerStyle: { type: [String, Object], required: false }
|
|
17
17
|
});
|
|
18
18
|
const emit = defineEmits(["success", "click", "error"]);
|
|
19
|
-
|
|
19
|
+
let authComposable = null;
|
|
20
20
|
const isLoading = ref(false);
|
|
21
21
|
const error = ref("");
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
authComposable = useAuthentication();
|
|
24
|
+
});
|
|
22
25
|
const handleLogout = async (event) => {
|
|
23
26
|
event.preventDefault();
|
|
24
27
|
if (!confirm(props.confirmMessage)) {
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
30
|
+
if (!authComposable) {
|
|
31
|
+
error.value = "Authentication not initialized";
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
27
34
|
isLoading.value = true;
|
|
28
35
|
error.value = "";
|
|
29
36
|
try {
|
|
30
37
|
emit("click");
|
|
31
|
-
await logout();
|
|
38
|
+
await authComposable.logout();
|
|
32
39
|
emit("success");
|
|
33
40
|
if (props.redirectTo) {
|
|
34
41
|
await navigateTo(props.redirectTo);
|
|
@@ -16,12 +16,12 @@ type __VLS_Slots = {} & {
|
|
|
16
16
|
default?: (props: typeof __VLS_1) => any;
|
|
17
17
|
};
|
|
18
18
|
declare const __VLS_component: import("vue").DefineComponent<LogoutLinkProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
19
|
-
error: (error: string) => any;
|
|
20
19
|
click: () => any;
|
|
20
|
+
error: (error: string) => any;
|
|
21
21
|
success: () => any;
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<LogoutLinkProps> & Readonly<{
|
|
23
|
-
onError?: ((error: string) => any) | undefined;
|
|
24
23
|
onClick?: (() => any) | undefined;
|
|
24
|
+
onError?: ((error: string) => any) | undefined;
|
|
25
25
|
onSuccess?: (() => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
27
|
redirectTo: string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { computed, onMounted } from "vue";
|
|
2
3
|
import { useAuthentication } from "../composables/useAuthentication";
|
|
3
|
-
|
|
4
|
+
let authComposable = null;
|
|
5
|
+
const user = computed(() => authComposable?.user.value ?? null);
|
|
6
|
+
onMounted(() => {
|
|
7
|
+
authComposable = useAuthentication();
|
|
8
|
+
});
|
|
4
9
|
</script>
|
|
5
10
|
|
|
6
11
|
<template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "vue";
|
|
2
|
+
import { computed, onMounted } from "vue";
|
|
3
3
|
import { useAuthentication } from "../composables/useAuthentication";
|
|
4
4
|
import { useRuntimeConfig } from "#imports";
|
|
5
5
|
import { defaultDisplayFields, defaultFieldLabels } from "nuxt-users/utils";
|
|
@@ -10,8 +10,12 @@ const props = defineProps({
|
|
|
10
10
|
fieldLabels: { type: Object, required: false, default: () => defaultFieldLabels }
|
|
11
11
|
});
|
|
12
12
|
const emit = defineEmits(["delete", "editClick"]);
|
|
13
|
-
const { user: currentUser } = useAuthentication();
|
|
14
13
|
const { public: { nuxtUsers } } = useRuntimeConfig();
|
|
14
|
+
let authComposable = null;
|
|
15
|
+
const currentUser = computed(() => authComposable?.user.value ?? null);
|
|
16
|
+
onMounted(() => {
|
|
17
|
+
authComposable = useAuthentication();
|
|
18
|
+
});
|
|
15
19
|
const canEdit = computed(() => {
|
|
16
20
|
if (!currentUser.value) return false;
|
|
17
21
|
if (nuxtUsers.auth?.permissions) {
|
|
@@ -35,6 +39,7 @@ const canDelete = computed(() => {
|
|
|
35
39
|
return false;
|
|
36
40
|
});
|
|
37
41
|
const editUser = async (user) => {
|
|
42
|
+
console.info("The edit event is emitted. Nuxt-users does not automatically calls the API to update the user, you should do it at the upper component.");
|
|
38
43
|
emit("editClick", user);
|
|
39
44
|
};
|
|
40
45
|
const deleteUser = async (user) => {
|
|
@@ -3,12 +3,12 @@ interface Props {
|
|
|
3
3
|
user?: User | null;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
-
error: (error: unknown) => any;
|
|
7
6
|
cancel: () => any;
|
|
7
|
+
error: (error: unknown) => any;
|
|
8
8
|
submit: (userData: User) => any;
|
|
9
9
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
10
|
-
onError?: ((error: unknown) => any) | undefined;
|
|
11
10
|
onCancel?: (() => any) | undefined;
|
|
11
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
12
12
|
onSubmit?: ((userData: User) => any) | undefined;
|
|
13
13
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
14
|
export default _default;
|
package/package.json
CHANGED