@drax/identity-vue 0.5.5 → 0.5.10

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.5.5",
6
+ "version": "0.5.10",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -27,7 +27,7 @@
27
27
  "@drax/common-front": "^0.5.5",
28
28
  "@drax/common-vue": "^0.5.5",
29
29
  "@drax/crud-front": "^0.5.3",
30
- "@drax/crud-share": "^0.5.5",
30
+ "@drax/crud-share": "^0.5.9",
31
31
  "@drax/identity-share": "^0.5.1"
32
32
  },
33
33
  "peerDependencies": {
@@ -65,5 +65,5 @@
65
65
  "vue-tsc": "^2.1.6",
66
66
  "vuetify": "^3.7.1"
67
67
  },
68
- "gitHead": "c89751dd8eb2ede7d565b596f698c2b83e0c2fed"
68
+ "gitHead": "0320d2a3e3b4461ceca923cf47c54080f7d5c5e1"
69
69
  }
package/src/index.ts CHANGED
@@ -3,7 +3,6 @@ import IdentityProfileAvatar from "./components/IdentityProfileAvatar/IdentityPr
3
3
  import IdentityProfileDrawer from "./components/IdentityProfileDrawer/IdentityProfileDrawer.vue";
4
4
  import IdentityProfileView from "./components/IdentityProfileView/IdentityProfileView.vue";
5
5
 
6
- import UserCrud from "./cruds/user-crud/UserCrud.vue";
7
6
  import UserCrudPage from "./pages/crud/UserCrudPage.vue";
8
7
  import UserForm from "./cruds/user-crud/UserForm.vue";
9
8
  import UserView from "./views/UserView.vue";
@@ -16,7 +15,6 @@ import LoginPage from "./pages/LoginPage.vue";
16
15
  import ProfilePage from "./pages/ProfilePage.vue";
17
16
  import PasswordPage from "./pages/PasswordPage.vue";
18
17
 
19
-
20
18
  import TenantView from "./views/TenantView.vue";
21
19
  import TenantCrudPage from "./pages/crud/TenantCrudPage.vue";
22
20
 
@@ -33,6 +31,11 @@ import {useRole} from "./composables/useRole.js";
33
31
  import {useTenant} from "./composables/useTenant.js";
34
32
  import {useUserApiKey} from "./composables/useUserApiKey.js";
35
33
 
34
+ import TenantCrud from "./cruds/tenant-crud/TenantCrud"
35
+ import UserCrud from "./cruds/user-crud/UserCrud"
36
+ import RoleCrud from "./cruds/role-crud/RoleCrud"
37
+
38
+
36
39
 
37
40
  import {useAuthStore} from "./stores/auth/AuthStore.js";
38
41
 
@@ -40,6 +43,11 @@ import IdentityRoutes from "./routes/IdentityRoutes.js";
40
43
 
41
44
  export {
42
45
 
46
+ //Cruds
47
+ TenantCrud,
48
+ UserCrud,
49
+ RoleCrud,
50
+
43
51
  //Vue Components
44
52
  IdentityLogin,
45
53
  IdentityProfileAvatar,
@@ -54,7 +62,6 @@ export {
54
62
  //User
55
63
  UserView,
56
64
  UserForm,
57
- UserCrud,
58
65
  UserCrudPage,
59
66
  useAuth,
60
67
  useUser,
@@ -1,221 +0,0 @@
1
- <script setup lang="ts">
2
- import {computed, ref} from 'vue'
3
- import {useUser} from "../../composables/useUser";
4
- import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
5
- import type {IUserPassword} from "@drax/identity-front";
6
- import UserCreateForm from "./UserForm.vue";
7
- import UserPasswordForm from "./UserPasswordForm.vue";
8
- import UserView from "../../views/UserView.vue";
9
- import {useI18n} from "vue-i18n";
10
-
11
- const {t} = useI18n()
12
-
13
- const {createUser, editUser, changeUserPassword, deleteUser, loading, userError, inputErrors} = useUser()
14
-
15
- interface UserList {
16
- loadItems: () => void;
17
- items: IUser[];
18
- }
19
-
20
- type DialogMode = 'create' | 'edit' | 'delete' | 'changePassword' | null;
21
-
22
-
23
- let dialog = ref(false);
24
- let dialogMode = ref<DialogMode>(null);
25
- let dialogTitle = ref('');
26
- const userList = ref<UserList | null>(null);
27
- let createForm = ref<IUserCreate>({name: "", username: "", password: "", email: "", phone: "", role: "", tenant: "", active: true})
28
- let editForm = ref<IUserUpdate>({name: "", username: "", email: "", phone: "", role: "", tenant: "", active: true})
29
- let passwordForm = ref<IUserPassword>({newPassword: "", confirmPassword: ""})
30
- let passwordChanged = ref(false);
31
- let target = ref<IUser>();
32
- let targetId = ref<string>('');
33
- let actionButtonEnable = ref(true);
34
- let filterEnable = ref(false);
35
-
36
- function cancel() {
37
- dialog.value = false
38
- inputErrors.value = {}
39
- userError.value = '';
40
- dialogMode.value = null
41
- dialogTitle.value = ''
42
- targetId.value = ''
43
- target.value = undefined
44
- actionButtonEnable.value = true
45
- }
46
-
47
- async function save() {
48
-
49
- try {
50
- if (dialogMode.value === 'create') {
51
- await createUser(createForm.value)
52
- } else if (dialogMode.value === 'edit') {
53
- await editUser(targetId.value, editForm.value)
54
- } else if (dialogMode.value === 'changePassword') {
55
- if (passwordForm.value.newPassword === passwordForm.value.confirmPassword) {
56
- passwordChanged.value = await changeUserPassword(targetId.value, passwordForm.value.newPassword)
57
- actionButtonEnable.value = false
58
- return
59
- } else {
60
- return
61
- }
62
- } else if (dialogMode.value === 'delete') {
63
- await deleteUser(targetId.value)
64
- }
65
- dialog.value = false
66
- inputErrors.value = {}
67
- userError.value = '';
68
- if (userList.value !== null) {
69
- userList.value.loadItems()
70
- }
71
- } catch (e) {
72
- console.error(e)
73
- if (e instanceof Error) {
74
- userError.value = e.message
75
- }
76
- }
77
- }
78
-
79
- let buttonText = computed(() => {
80
- switch (dialogMode.value) {
81
- case 'create':
82
- return 'action.create'
83
- case 'edit':
84
- return 'action.update'
85
- case 'delete':
86
- return 'action.delete'
87
- default:
88
- return 'action.sent'
89
- }
90
- })
91
-
92
- function toCreate() {
93
- actionButtonEnable.value = true
94
- dialogMode.value = 'create';
95
- dialogTitle.value = 'user.creating';
96
- createForm.value = {name: "", username: "", password: "", email: "", phone: "", role: "", tenant: "", active: true}
97
- dialog.value = true;
98
- }
99
-
100
- function toEdit(item: IUser) {
101
- actionButtonEnable.value = true
102
- dialogMode.value = 'edit';
103
- dialogTitle.value = 'user.updating';
104
- targetId.value = item.id;
105
- editForm.value = {
106
- name: item.name,
107
- username: item.username,
108
- email: item.email,
109
- phone: item.phone,
110
- role: item.role.id,
111
- tenant: item?.tenant?.id,
112
- active: item.active
113
- };
114
- dialog.value = true;
115
- }
116
-
117
- function toDelete(item: IUser) {
118
- actionButtonEnable.value = true
119
- dialogMode.value = 'delete';
120
- dialogTitle.value = 'user.deleting';
121
- target.value = item
122
- const {id} = item;
123
- targetId.value = id;
124
- dialog.value = true;
125
- }
126
-
127
- function toChangePassword(item: IUser) {
128
- actionButtonEnable.value = true
129
- dialogMode.value = 'changePassword';
130
- dialogTitle.value = 'user.changingPassword';
131
- target.value = item
132
- const {id} = item;
133
- targetId.value = id;
134
- dialog.value = true;
135
- }
136
-
137
-
138
- </script>
139
-
140
- <template>
141
- <v-container fluid>
142
-
143
- <v-card border rounded>
144
- <v-toolbar class="bg-toolbar">
145
- <v-toolbar-title>{{ t('user.managing') }}</v-toolbar-title>
146
- <v-spacer></v-spacer>
147
- <v-btn icon @click="filterEnable = !filterEnable">
148
- <v-icon>{{ filterEnable ? 'mdi-filter' : 'mdi-filter-off' }}</v-icon>
149
- </v-btn>
150
- <v-btn color="primary" @click="toCreate">
151
- {{t('action.create') }}
152
- </v-btn>
153
- </v-toolbar>
154
- <v-theme-provider with-background class="pa-2 rounded-b">
155
-
156
- </v-theme-provider>
157
- </v-card>
158
-
159
- <v-dialog v-model="dialog" max-width="800">
160
- <v-sheet border>
161
- <v-toolbar>
162
- <v-toolbar-title>{{ dialogTitle ? t(dialogTitle) : '-' }}</v-toolbar-title>
163
- </v-toolbar>
164
- <v-card class="pa-10">
165
- <v-card-text v-if="userError">
166
- <v-alert type="error">{{ userError }}</v-alert>
167
- </v-card-text>
168
- <v-card-text>
169
- <UserCreateForm
170
- v-if="dialogMode === 'create'"
171
- v-model="createForm"
172
- :inputErrors="inputErrors"
173
- @formSubmit="save"
174
- />
175
-
176
-
177
-
178
- <UserView v-if="dialogMode === 'delete'
179
- && target" :user="target"
180
- />
181
-
182
-
183
- <UserPasswordForm
184
- v-if="dialogMode === 'changePassword'&& target"
185
- v-model="passwordForm"
186
- :inputErrors="inputErrors"
187
- :passwordChanged="passwordChanged"
188
- @formSubmit="save"
189
- />
190
-
191
-
192
- </v-card-text>
193
- <v-card-actions>
194
- <v-spacer></v-spacer>
195
- <v-btn
196
- variant="text"
197
- @click="cancel"
198
- :loading="loading">
199
- {{ actionButtonEnable ? t('action.cancel') : t('action.close') }}
200
- </v-btn>
201
- <v-btn
202
- v-if="actionButtonEnable"
203
- variant="flat"
204
- :color="dialogMode==='delete' ? 'red' : 'primary'"
205
- @click="save"
206
- :loading="loading"
207
- >
208
- {{ t(buttonText) }}
209
- </v-btn>
210
- </v-card-actions>
211
-
212
- </v-card>
213
- </v-sheet>
214
- </v-dialog>
215
-
216
- </v-container>
217
- </template>
218
-
219
- <style scoped>
220
-
221
- </style>