nuxt-users 1.31.1 → 1.32.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
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.32.0
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.31.2...v1.32.0)
|
|
7
|
+
|
|
8
|
+
### 🚀 Enhancements
|
|
9
|
+
|
|
10
|
+
- Extends NUsersList component with function filters ([be9a730](https://github.com/rrd108/nuxt-users/commit/be9a730))
|
|
11
|
+
|
|
12
|
+
### 🩹 Fixes
|
|
13
|
+
|
|
14
|
+
- Usercard shows action buttons by default ([d824b1e](https://github.com/rrd108/nuxt-users/commit/d824b1e))
|
|
15
|
+
|
|
16
|
+
### 💅 Refactors
|
|
17
|
+
|
|
18
|
+
- Remove unused code ([cbff5a0](https://github.com/rrd108/nuxt-users/commit/cbff5a0))
|
|
19
|
+
|
|
20
|
+
### 🏡 Chore
|
|
21
|
+
|
|
22
|
+
- **release:** V1.31.2 ([8136322](https://github.com/rrd108/nuxt-users/commit/8136322))
|
|
23
|
+
|
|
24
|
+
### ❤️ Contributors
|
|
25
|
+
|
|
26
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
27
|
+
|
|
28
|
+
## v1.31.2
|
|
29
|
+
|
|
30
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.31.1...v1.31.2)
|
|
31
|
+
|
|
32
|
+
### 🩹 Fixes
|
|
33
|
+
|
|
34
|
+
- Usercard shows action buttons by default ([d824b1e](https://github.com/rrd108/nuxt-users/commit/d824b1e))
|
|
35
|
+
|
|
36
|
+
### 🏡 Chore
|
|
37
|
+
|
|
38
|
+
- **release:** V1.31.1 ([da02db7](https://github.com/rrd108/nuxt-users/commit/da02db7))
|
|
39
|
+
|
|
40
|
+
### ❤️ Contributors
|
|
41
|
+
|
|
42
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
43
|
+
|
|
4
44
|
## v1.31.1
|
|
5
45
|
|
|
6
46
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.31.0...v1.31.1)
|
package/dist/module.json
CHANGED
|
@@ -5,7 +5,7 @@ import { defaultDisplayFields, defaultFieldLabels } from "nuxt-users/utils";
|
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
displayFields: { type: Array, required: false, default: () => defaultDisplayFields },
|
|
7
7
|
fieldLabels: { type: Object, required: false, default: () => defaultFieldLabels },
|
|
8
|
-
filter: { type: Object, required: false, default: () => ({}) }
|
|
8
|
+
filter: { type: [Object, Function], required: false, default: () => ({}) }
|
|
9
9
|
});
|
|
10
10
|
const emit = defineEmits(["editClick", "delete"]);
|
|
11
11
|
const usersComposable = ref(null);
|
|
@@ -14,7 +14,13 @@ const pagination = computed(() => usersComposable.value?.pagination ?? null);
|
|
|
14
14
|
const loading = computed(() => usersComposable.value?.loading ?? false);
|
|
15
15
|
const error = computed(() => usersComposable.value?.error ?? null);
|
|
16
16
|
const users = computed(() => {
|
|
17
|
-
if (!props.filter
|
|
17
|
+
if (!props.filter) {
|
|
18
|
+
return allUsers.value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof props.filter === "function") {
|
|
21
|
+
return allUsers.value.filter(props.filter);
|
|
22
|
+
}
|
|
23
|
+
if (Object.keys(props.filter).length === 0) {
|
|
18
24
|
return allUsers.value;
|
|
19
25
|
}
|
|
20
26
|
return allUsers.value.filter((user) => {
|
|
@@ -92,55 +98,108 @@ const handleFetchUsers = (page, limit) => {
|
|
|
92
98
|
v-for="(user, index) in users"
|
|
93
99
|
:key="user.id"
|
|
94
100
|
>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:index="index"
|
|
99
|
-
:edit-user="() => $emit('editClick', user)"
|
|
100
|
-
:delete-user="() => handleDelete(user)"
|
|
101
|
-
>
|
|
102
|
-
<NUsersUserCard
|
|
101
|
+
<div class="n-users-user-wrapper">
|
|
102
|
+
<slot
|
|
103
|
+
name="user"
|
|
103
104
|
:user="user"
|
|
104
105
|
:index="index"
|
|
105
|
-
:
|
|
106
|
-
:
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
:edit-user="() => $emit('editClick', user)"
|
|
107
|
+
:delete-user="() => handleDelete(user)"
|
|
108
|
+
>
|
|
109
|
+
<NUsersUserCard
|
|
110
|
+
:user="user"
|
|
111
|
+
:index="index"
|
|
112
|
+
:display-fields="displayFields"
|
|
113
|
+
:field-labels="fieldLabels"
|
|
114
|
+
@edit-click="$emit('editClick', user)"
|
|
115
|
+
@delete="handleDelete(user)"
|
|
116
|
+
>
|
|
117
|
+
<template #editButton="{ canEdit, editUser: editUserFn, user: userData }">
|
|
118
|
+
<slot
|
|
119
|
+
name="editButton"
|
|
120
|
+
:can-edit="canEdit"
|
|
121
|
+
:edit-user="editUserFn"
|
|
122
|
+
:user="userData"
|
|
123
|
+
>
|
|
124
|
+
<button
|
|
125
|
+
v-if="canEdit"
|
|
126
|
+
class="n-users-edit-btn"
|
|
127
|
+
@click="editUserFn"
|
|
128
|
+
>
|
|
129
|
+
Edit
|
|
130
|
+
</button>
|
|
131
|
+
</slot>
|
|
132
|
+
</template>
|
|
133
|
+
<template #deleteButton="{ canDelete, deleteUser: deleteUserFn, user: userData }">
|
|
134
|
+
<slot
|
|
135
|
+
name="deleteButton"
|
|
136
|
+
:can-delete="canDelete"
|
|
137
|
+
:delete-user="deleteUserFn"
|
|
138
|
+
:user="userData"
|
|
139
|
+
>
|
|
140
|
+
<button
|
|
141
|
+
v-if="canDelete"
|
|
142
|
+
class="n-users-delete-btn"
|
|
143
|
+
@click="deleteUserFn"
|
|
144
|
+
>
|
|
145
|
+
Delete
|
|
146
|
+
</button>
|
|
147
|
+
</slot>
|
|
148
|
+
</template>
|
|
149
|
+
</NUsersUserCard>
|
|
150
|
+
</slot>
|
|
151
|
+
|
|
152
|
+
<!-- Always show action buttons when using custom user slot -->
|
|
153
|
+
<div
|
|
154
|
+
v-if="$slots.user"
|
|
155
|
+
class="n-users-user-card-actions"
|
|
109
156
|
>
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
<NUsersUserCard
|
|
158
|
+
:user="user"
|
|
159
|
+
:index="index"
|
|
160
|
+
:display-fields="[]"
|
|
161
|
+
:field-labels="{}"
|
|
162
|
+
@edit-click="$emit('editClick', user)"
|
|
163
|
+
@delete="handleDelete(user)"
|
|
164
|
+
>
|
|
165
|
+
<template #userCard>
|
|
166
|
+
<!-- Empty slot to hide the default card content -->
|
|
167
|
+
</template>
|
|
168
|
+
<template #editButton="{ canEdit, editUser: editUserFn, user: userData }">
|
|
169
|
+
<slot
|
|
170
|
+
name="editButton"
|
|
171
|
+
:can-edit="canEdit"
|
|
172
|
+
:edit-user="editUserFn"
|
|
173
|
+
:user="userData"
|
|
121
174
|
>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
175
|
+
<button
|
|
176
|
+
v-if="canEdit"
|
|
177
|
+
class="n-users-edit-btn"
|
|
178
|
+
@click="editUserFn"
|
|
179
|
+
>
|
|
180
|
+
Edit
|
|
181
|
+
</button>
|
|
182
|
+
</slot>
|
|
183
|
+
</template>
|
|
184
|
+
<template #deleteButton="{ canDelete, deleteUser: deleteUserFn, user: userData }">
|
|
185
|
+
<slot
|
|
186
|
+
name="deleteButton"
|
|
187
|
+
:can-delete="canDelete"
|
|
188
|
+
:delete-user="deleteUserFn"
|
|
189
|
+
:user="userData"
|
|
137
190
|
>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
191
|
+
<button
|
|
192
|
+
v-if="canDelete"
|
|
193
|
+
class="n-users-delete-btn"
|
|
194
|
+
@click="deleteUserFn"
|
|
195
|
+
>
|
|
196
|
+
Delete
|
|
197
|
+
</button>
|
|
198
|
+
</slot>
|
|
199
|
+
</template>
|
|
200
|
+
</NUsersUserCard>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
144
203
|
</li>
|
|
145
204
|
</TransitionGroup>
|
|
146
205
|
</slot>
|
|
@@ -17,13 +17,10 @@ onMounted(async () => {
|
|
|
17
17
|
authComposable.value = useAuthentication();
|
|
18
18
|
});
|
|
19
19
|
const canEdit = computed(() => {
|
|
20
|
-
console.log("canEdit", currentUser.value);
|
|
21
20
|
if (!currentUser.value) return false;
|
|
22
21
|
if (nuxtUsers.auth?.permissions) {
|
|
23
22
|
const userPermissions = nuxtUsers.auth.permissions[currentUser.value.role] || [];
|
|
24
23
|
const apiBasePath = nuxtUsers.apiBasePath;
|
|
25
|
-
console.log("userPermissions", userPermissions);
|
|
26
|
-
console.log("apiBasePath", apiBasePath);
|
|
27
24
|
return userPermissions.some(
|
|
28
25
|
(permission) => permission === "*" || permission === `${apiBasePath}/*` || permission === `${apiBasePath}/[id].put` || permission === `${apiBasePath}/[id].patch`
|
|
29
26
|
);
|
package/package.json
CHANGED