@tager/admin-administrators 0.2.7 → 1.0.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/dist/constants/paths.d.ts +6 -6
- package/dist/constants/routes.d.ts +5 -5
- package/dist/dev/App.vue.d.ts +5 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/index.mjs +875 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +40 -41
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -3
- package/dist/services/requests.d.ts +32 -32
- package/dist/style.css +1 -0
- package/dist/typings/model.d.ts +25 -25
- package/dist/utils/paths.d.ts +8 -8
- package/dist/views/AdminForm/AdminForm.helpers.d.ts +14 -14
- package/dist/views/AdminForm/AdminForm.vue.d.ts +26 -61
- package/dist/views/AdminForm/index.d.ts +1 -1
- package/dist/views/AdminList/AdminList.vue.d.ts +14 -33
- package/dist/views/AdminList/index.d.ts +1 -1
- package/dist/views/RoleForm/RoleForm.helpers.d.ts +13 -13
- package/dist/views/RoleForm/RoleForm.vue.d.ts +24 -59
- package/dist/views/RoleForm/index.d.ts +1 -1
- package/dist/views/RoleList/RoleList.vue.d.ts +20 -46
- package/dist/views/RoleList/index.d.ts +1 -1
- package/package.json +51 -50
- package/src/constants/routes.ts +19 -19
- package/src/dev/App.vue +57 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +46 -0
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +1 -3
- package/src/locales/ru.ts +40 -42
- package/src/main.ts +5 -9
- package/src/views/AdminForm/AdminForm.vue +99 -96
- package/src/views/AdminList/AdminList.vue +54 -49
- package/src/views/RoleForm/RoleForm.vue +82 -79
- package/src/views/RoleList/RoleList.vue +78 -64
- package/CHANGELOG.md +0 -0
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -1350
- package/dist/index.umd.js +0 -1373
- package/src/config/config.json +0 -20
- package/src/dev.ts +0 -51
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/views/App.vue +0 -52
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
import { i18n, request, useI18n, useResourceDelete, createId, useToast, useResource, navigateBack, convertRequestErrorToMap } from "@tager/admin-services";
|
|
2
|
+
import { defineComponent, onMounted, resolveComponent, openBlock, createBlock, withCtx, createVNode, createElementVNode, createElementBlock, Fragment, renderList, toDisplayString, createCommentVNode, computed, ref, watch, withModifiers } from "vue";
|
|
3
|
+
import { DataTable, BaseButton, DeleteIcon, EditIcon, useDataTable, FormFooter, FormField, FormFieldMultiSelect } from "@tager/admin-ui";
|
|
4
|
+
import { compile } from "path-to-regexp";
|
|
5
|
+
import { Page } from "@tager/admin-layout";
|
|
6
|
+
import { useRoute, useRouter } from "vue-router";
|
|
7
|
+
const EN = {
|
|
8
|
+
home: "Home",
|
|
9
|
+
administrators: "Administrators",
|
|
10
|
+
role: "Role",
|
|
11
|
+
roles: "Roles",
|
|
12
|
+
admin: "Admin",
|
|
13
|
+
admins: "Admins",
|
|
14
|
+
createRole: "Create role",
|
|
15
|
+
createAdmin: "Create admin",
|
|
16
|
+
createAdministrator: "Create administrator",
|
|
17
|
+
edit: "Edit",
|
|
18
|
+
delete: "Delete",
|
|
19
|
+
email: "Email",
|
|
20
|
+
actions: "Actions",
|
|
21
|
+
updateRole: "Update role",
|
|
22
|
+
updateAdmin: "Update admin",
|
|
23
|
+
password: "Password",
|
|
24
|
+
newPassword: "New password",
|
|
25
|
+
name: "Name",
|
|
26
|
+
success: "Success",
|
|
27
|
+
adminSuccessfullyCreated: "Admin successfully created",
|
|
28
|
+
adminSuccessfullyUpdated: "Admin successfully updated",
|
|
29
|
+
error: "Error",
|
|
30
|
+
adminCreationError: "Admin creation error",
|
|
31
|
+
adminUpdateError: "Admin update error",
|
|
32
|
+
listOfRoles: "List of roles",
|
|
33
|
+
addRole: "Add role",
|
|
34
|
+
noPrivileges: "No privileges",
|
|
35
|
+
privileges: "Privileges",
|
|
36
|
+
all: "All",
|
|
37
|
+
roleSuccessfullyCreated: "Role successfully created",
|
|
38
|
+
roleSuccessfullyUpdate: "Role successfully update",
|
|
39
|
+
roleCreationError: "Role creation error",
|
|
40
|
+
roleUpdateError: "Role update error",
|
|
41
|
+
adminList: "Admin List",
|
|
42
|
+
adminForm: "Admin form",
|
|
43
|
+
roleList: "Role List",
|
|
44
|
+
roleForm: "Role form",
|
|
45
|
+
andMorePrivilege: "and more {{count}} privilege..."
|
|
46
|
+
};
|
|
47
|
+
const RU = {
|
|
48
|
+
home: "\u0413\u043B\u0430\u0432\u043D\u0430\u044F",
|
|
49
|
+
administrators: "\u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u044B",
|
|
50
|
+
role: "\u0420\u043E\u043B\u044C",
|
|
51
|
+
roles: "\u0420\u043E\u043B\u0438",
|
|
52
|
+
admin: "\u0410\u0434\u043C\u0438\u043D",
|
|
53
|
+
admins: "\u0410\u0434\u043C\u0438\u043D\u044B",
|
|
54
|
+
createRole: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0440\u043E\u043B\u044C",
|
|
55
|
+
createAdmin: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0430",
|
|
56
|
+
createAdministrator: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
57
|
+
edit: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
|
|
58
|
+
delete: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
|
|
59
|
+
email: "\u042D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u0430\u044F \u043F\u043E\u0447\u0442\u0430",
|
|
60
|
+
actions: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
|
|
61
|
+
updateRole: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0440\u043E\u043B\u044C",
|
|
62
|
+
updateAdmin: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
63
|
+
password: "\u041F\u0430\u0440\u043E\u043B\u044C",
|
|
64
|
+
newPassword: "\u041D\u043E\u0432\u044B\u0439 \u043F\u0430\u0440\u043E\u043B\u044C",
|
|
65
|
+
name: "\u0418\u043C\u044F",
|
|
66
|
+
success: "\u0423\u0441\u043F\u0435\u0445",
|
|
67
|
+
adminSuccessfullyCreated: "\u0410\u0434\u043C\u0438\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D",
|
|
68
|
+
adminSuccessfullyUpdated: "\u0410\u0434\u043C\u0438\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D",
|
|
69
|
+
error: "\u041E\u0448\u0438\u0431\u043A\u0430",
|
|
70
|
+
adminCreationError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
71
|
+
adminUpdateError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
72
|
+
listOfRoles: "\u0421\u043F\u0438\u0441\u043E\u043A \u0440\u043E\u043B\u0435\u0439",
|
|
73
|
+
addRole: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u043E\u043B\u044C",
|
|
74
|
+
noPrivileges: "\u0411\u0435\u0437 \u043F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0439",
|
|
75
|
+
privileges: "\u041F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0438",
|
|
76
|
+
all: "\u0412\u0441\u0435",
|
|
77
|
+
roleSuccessfullyCreated: "\u0420\u043E\u043B\u044C \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430",
|
|
78
|
+
roleSuccessfullyUpdate: "\u0420\u043E\u043B\u044C \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0430",
|
|
79
|
+
roleCreationError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0440\u043E\u043B\u0438",
|
|
80
|
+
roleUpdateError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u0440\u043E\u043B\u0438",
|
|
81
|
+
adminList: "\u0421\u043F\u0438\u0441\u043E\u043A \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u043E\u0432",
|
|
82
|
+
adminForm: "\u0424\u043E\u0440\u043C\u0430 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
83
|
+
roleList: "\u0421\u043F\u0438\u0441\u043E\u043A \u0440\u043E\u043B\u0435\u0439",
|
|
84
|
+
roleForm: "\u0424\u043E\u0440\u043C\u0430 \u0440\u043E\u043B\u0438",
|
|
85
|
+
andMorePrivilege: "\u0438 \u0435\u0449\u0435 {{count}} \u043F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0439..."
|
|
86
|
+
};
|
|
87
|
+
function applyTranslations() {
|
|
88
|
+
i18n.addTranslations("en", "administrators", EN);
|
|
89
|
+
i18n.addTranslations("ru", "administrators", RU);
|
|
90
|
+
}
|
|
91
|
+
function getRoleList() {
|
|
92
|
+
return request.get({ path: "/admin/rbac/roles" });
|
|
93
|
+
}
|
|
94
|
+
function getRole(roleId) {
|
|
95
|
+
return request.get({ path: `/admin/rbac/roles/${roleId}` });
|
|
96
|
+
}
|
|
97
|
+
function createRole(payload) {
|
|
98
|
+
return request.post({ path: "/admin/rbac/roles", body: payload });
|
|
99
|
+
}
|
|
100
|
+
function updateRole(roleId, payload) {
|
|
101
|
+
return request.put({ path: `/admin/rbac/roles/${roleId}`, body: payload });
|
|
102
|
+
}
|
|
103
|
+
function deleteRole(roleId) {
|
|
104
|
+
return request.delete({ path: `/admin/rbac/roles/${roleId}` });
|
|
105
|
+
}
|
|
106
|
+
function getScopes() {
|
|
107
|
+
return request.get({ path: "/admin/rbac/scopes" });
|
|
108
|
+
}
|
|
109
|
+
function getAdminList() {
|
|
110
|
+
return request.get({ path: "/admin/admins" });
|
|
111
|
+
}
|
|
112
|
+
function getAdmin(adminId) {
|
|
113
|
+
return request.get({ path: `/admin/admins/${adminId}` });
|
|
114
|
+
}
|
|
115
|
+
function createAdmin(payload) {
|
|
116
|
+
return request.post({ path: "/admin/admins", body: payload });
|
|
117
|
+
}
|
|
118
|
+
function updateAdmin(adminId, payload) {
|
|
119
|
+
return request.put({ path: `/admin/admins/${adminId}`, body: payload });
|
|
120
|
+
}
|
|
121
|
+
function deleteAdmin(adminId) {
|
|
122
|
+
return request.delete({ path: `/admin/admins/${adminId}` });
|
|
123
|
+
}
|
|
124
|
+
const ADMINISTRATOR_ROUTE_PATHS = {
|
|
125
|
+
ROLE_LIST: "/roles",
|
|
126
|
+
ROLE_FORM: "/roles/:roleId",
|
|
127
|
+
ADMIN_LIST: "/admins",
|
|
128
|
+
ADMIN_FORM: "/admins/:adminId"
|
|
129
|
+
};
|
|
130
|
+
function getRoleListUrl() {
|
|
131
|
+
return ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST;
|
|
132
|
+
}
|
|
133
|
+
function getRoleFormUrl(params) {
|
|
134
|
+
return compile(ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM)(params);
|
|
135
|
+
}
|
|
136
|
+
function getAdminListUrl() {
|
|
137
|
+
return ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST;
|
|
138
|
+
}
|
|
139
|
+
function getAdminFormUrl(params) {
|
|
140
|
+
return compile(ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM)(params);
|
|
141
|
+
}
|
|
142
|
+
var _export_sfc = (sfc, props) => {
|
|
143
|
+
const target = sfc.__vccOpts || sfc;
|
|
144
|
+
for (const [key, val] of props) {
|
|
145
|
+
target[key] = val;
|
|
146
|
+
}
|
|
147
|
+
return target;
|
|
148
|
+
};
|
|
149
|
+
const _sfc_main$3 = defineComponent({
|
|
150
|
+
name: "AdminList",
|
|
151
|
+
components: {
|
|
152
|
+
Page,
|
|
153
|
+
DataTable,
|
|
154
|
+
BaseButton,
|
|
155
|
+
DeleteIcon,
|
|
156
|
+
EditIcon
|
|
157
|
+
},
|
|
158
|
+
setup() {
|
|
159
|
+
const { t } = useI18n();
|
|
160
|
+
const {
|
|
161
|
+
fetchEntityList: fetchAdminList,
|
|
162
|
+
isLoading: isAdminListLoading,
|
|
163
|
+
rowData: adminList,
|
|
164
|
+
errorMessage: error
|
|
165
|
+
} = useDataTable({
|
|
166
|
+
fetchEntityList: () => getAdminList(),
|
|
167
|
+
initialValue: [],
|
|
168
|
+
resourceName: "Admin list",
|
|
169
|
+
pageSize: 100
|
|
170
|
+
});
|
|
171
|
+
onMounted(() => {
|
|
172
|
+
fetchAdminList();
|
|
173
|
+
});
|
|
174
|
+
const {
|
|
175
|
+
handleResourceDelete: handleAdminDelete,
|
|
176
|
+
isDeleting
|
|
177
|
+
} = useResourceDelete({
|
|
178
|
+
deleteResource: deleteAdmin,
|
|
179
|
+
resourceName: "Admin",
|
|
180
|
+
onSuccess: fetchAdminList
|
|
181
|
+
});
|
|
182
|
+
function isBusy(adminId) {
|
|
183
|
+
return isDeleting(adminId) || isAdminListLoading.value;
|
|
184
|
+
}
|
|
185
|
+
const columnDefs = [
|
|
186
|
+
{
|
|
187
|
+
id: 1,
|
|
188
|
+
name: t("administrators:admin"),
|
|
189
|
+
field: "name"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: 2,
|
|
193
|
+
name: t("administrators:email"),
|
|
194
|
+
field: "email"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: 3,
|
|
198
|
+
name: t("administrators:roles"),
|
|
199
|
+
field: "roles"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 4,
|
|
203
|
+
name: t("administrators:actions"),
|
|
204
|
+
field: "actions",
|
|
205
|
+
style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
|
|
206
|
+
headStyle: { width: "180px", textAlign: "center" }
|
|
207
|
+
}
|
|
208
|
+
];
|
|
209
|
+
return {
|
|
210
|
+
t,
|
|
211
|
+
columnDefs,
|
|
212
|
+
rowData: adminList,
|
|
213
|
+
isRowDataLoading: isAdminListLoading,
|
|
214
|
+
errorMessage: error,
|
|
215
|
+
isBusy,
|
|
216
|
+
handleAdminDelete,
|
|
217
|
+
getAdminFormUrl
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
222
|
+
const _component_EditIcon = resolveComponent("EditIcon");
|
|
223
|
+
const _component_BaseButton = resolveComponent("BaseButton");
|
|
224
|
+
const _component_DeleteIcon = resolveComponent("DeleteIcon");
|
|
225
|
+
const _component_DataTable = resolveComponent("DataTable");
|
|
226
|
+
const _component_Page = resolveComponent("Page");
|
|
227
|
+
return openBlock(), createBlock(_component_Page, {
|
|
228
|
+
title: _ctx.$i18n.t("administrators:administrators"),
|
|
229
|
+
"header-buttons": [
|
|
230
|
+
{
|
|
231
|
+
text: _ctx.$i18n.t("administrators:createAdministrator"),
|
|
232
|
+
href: _ctx.getAdminFormUrl({ adminId: "create" })
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}, {
|
|
236
|
+
default: withCtx(() => [
|
|
237
|
+
createVNode(_component_DataTable, {
|
|
238
|
+
"column-defs": _ctx.columnDefs,
|
|
239
|
+
"row-data": _ctx.rowData,
|
|
240
|
+
loading: _ctx.isRowDataLoading,
|
|
241
|
+
"error-message": _ctx.errorMessage
|
|
242
|
+
}, {
|
|
243
|
+
"cell(roles)": withCtx(({ row }) => [
|
|
244
|
+
createElementVNode("ul", null, [
|
|
245
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(row.roles, (role) => {
|
|
246
|
+
return openBlock(), createElementBlock("li", {
|
|
247
|
+
key: role.id
|
|
248
|
+
}, toDisplayString(role.name), 1);
|
|
249
|
+
}), 128))
|
|
250
|
+
])
|
|
251
|
+
]),
|
|
252
|
+
"cell(actions)": withCtx(({ row }) => [
|
|
253
|
+
!row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
|
|
254
|
+
key: 0,
|
|
255
|
+
variant: "icon",
|
|
256
|
+
title: _ctx.$i18n.t("administrators:edit"),
|
|
257
|
+
disabled: _ctx.isBusy(row.id),
|
|
258
|
+
href: _ctx.getAdminFormUrl({ adminId: row.id })
|
|
259
|
+
}, {
|
|
260
|
+
default: withCtx(() => [
|
|
261
|
+
createVNode(_component_EditIcon)
|
|
262
|
+
]),
|
|
263
|
+
_: 2
|
|
264
|
+
}, 1032, ["title", "disabled", "href"])) : createCommentVNode("", true),
|
|
265
|
+
!row.isSuperAdmin || !row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
|
|
266
|
+
key: 1,
|
|
267
|
+
variant: "icon",
|
|
268
|
+
title: _ctx.$i18n.t("administrators:delete"),
|
|
269
|
+
disabled: _ctx.isBusy(row.id),
|
|
270
|
+
onClick: ($event) => _ctx.handleAdminDelete(row.id)
|
|
271
|
+
}, {
|
|
272
|
+
default: withCtx(() => [
|
|
273
|
+
createVNode(_component_DeleteIcon)
|
|
274
|
+
]),
|
|
275
|
+
_: 2
|
|
276
|
+
}, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
|
|
277
|
+
]),
|
|
278
|
+
_: 1
|
|
279
|
+
}, 8, ["column-defs", "row-data", "loading", "error-message"])
|
|
280
|
+
]),
|
|
281
|
+
_: 1
|
|
282
|
+
}, 8, ["title", "header-buttons"]);
|
|
283
|
+
}
|
|
284
|
+
var AdminList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
285
|
+
function convertAdminToFormValues(admin, roleOptionList) {
|
|
286
|
+
if (!admin) {
|
|
287
|
+
return {
|
|
288
|
+
name: "",
|
|
289
|
+
email: "",
|
|
290
|
+
password: createId(),
|
|
291
|
+
roles: []
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const currentRoleOptionList = roleOptionList.filter((role) => admin.roles.some((roles) => roles.id === role.value));
|
|
295
|
+
return {
|
|
296
|
+
name: admin.name,
|
|
297
|
+
email: admin.email,
|
|
298
|
+
password: "",
|
|
299
|
+
roles: currentRoleOptionList
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function convertFormValuesToAdminUpdatePayload(values) {
|
|
303
|
+
return {
|
|
304
|
+
name: values.name,
|
|
305
|
+
email: values.email,
|
|
306
|
+
roles: values.roles.map((role) => role.value),
|
|
307
|
+
password: values.password
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function convertFormValuesToAdminCreationPayload(values) {
|
|
311
|
+
return {
|
|
312
|
+
...convertFormValuesToAdminUpdatePayload(values)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function convertRoleListToOptions(roleList) {
|
|
316
|
+
return roleList.map((role) => ({
|
|
317
|
+
value: role.id,
|
|
318
|
+
label: role.name
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
const _sfc_main$2 = defineComponent({
|
|
322
|
+
name: "AdminForm",
|
|
323
|
+
components: { Page, FormFooter, FormField, FormFieldMultiSelect },
|
|
324
|
+
setup() {
|
|
325
|
+
const { t } = useI18n();
|
|
326
|
+
const route = useRoute();
|
|
327
|
+
const router = useRouter();
|
|
328
|
+
const toast = useToast();
|
|
329
|
+
const adminId = computed(() => route.params.adminId);
|
|
330
|
+
const isCreation = computed(() => adminId.value === "create");
|
|
331
|
+
const [fetchAdmin, { data: admin, loading: isAdminLoading }] = useResource({
|
|
332
|
+
fetchResource: () => getAdmin(adminId.value),
|
|
333
|
+
initialValue: null,
|
|
334
|
+
resourceName: "Admin"
|
|
335
|
+
});
|
|
336
|
+
const [
|
|
337
|
+
fetchRoleList,
|
|
338
|
+
{ data: roleList, loading: isRoleListLoading }
|
|
339
|
+
] = useResource({
|
|
340
|
+
fetchResource: getRoleList,
|
|
341
|
+
initialValue: [],
|
|
342
|
+
resourceName: "Role list"
|
|
343
|
+
});
|
|
344
|
+
onMounted(() => {
|
|
345
|
+
fetchRoleList();
|
|
346
|
+
if (isCreation.value)
|
|
347
|
+
return;
|
|
348
|
+
fetchAdmin();
|
|
349
|
+
});
|
|
350
|
+
const roleOptionList = computed(() => convertRoleListToOptions(roleList.value));
|
|
351
|
+
const values = ref(convertAdminToFormValues(admin.value, roleOptionList.value));
|
|
352
|
+
const errors = ref({});
|
|
353
|
+
const isSubmitting = ref(false);
|
|
354
|
+
watch([admin, roleOptionList], () => {
|
|
355
|
+
values.value = convertAdminToFormValues(admin.value, roleOptionList.value);
|
|
356
|
+
});
|
|
357
|
+
function submitForm(event) {
|
|
358
|
+
if (admin.value && admin.value.isSelf)
|
|
359
|
+
return;
|
|
360
|
+
const creationBody = convertFormValuesToAdminCreationPayload(values.value);
|
|
361
|
+
const updateBody = convertFormValuesToAdminUpdatePayload(values.value);
|
|
362
|
+
const requestPromise = isCreation.value ? createAdmin(creationBody) : updateAdmin(adminId.value, updateBody);
|
|
363
|
+
requestPromise.then(({ data }) => {
|
|
364
|
+
errors.value = {};
|
|
365
|
+
if (event.type === "create") {
|
|
366
|
+
router.push(getAdminFormUrl({ adminId: data.id }));
|
|
367
|
+
}
|
|
368
|
+
if (event.type === "create_exit" || event.type === "save_exit") {
|
|
369
|
+
navigateBack(router, getAdminListUrl());
|
|
370
|
+
}
|
|
371
|
+
if (event.type === "create_create-another") {
|
|
372
|
+
values.value = convertAdminToFormValues(null, roleOptionList.value);
|
|
373
|
+
}
|
|
374
|
+
toast.show({
|
|
375
|
+
variant: "success",
|
|
376
|
+
title: t("administrators:success"),
|
|
377
|
+
body: isCreation.value ? t("administrators:adminSuccessfullyCreated") : t("administrators:adminSuccessfullyUpdated")
|
|
378
|
+
});
|
|
379
|
+
}).catch((error) => {
|
|
380
|
+
console.error(error);
|
|
381
|
+
errors.value = convertRequestErrorToMap(error);
|
|
382
|
+
toast.show({
|
|
383
|
+
variant: "danger",
|
|
384
|
+
title: t("administrators:error"),
|
|
385
|
+
body: isCreation.value ? t("administrators:adminCreationError") : t("administrators:adminUpdateError")
|
|
386
|
+
});
|
|
387
|
+
}).finally(() => {
|
|
388
|
+
isSubmitting.value = false;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
const pageTitle = computed(() => {
|
|
392
|
+
return isCreation.value ? t("administrators:createAdmin") : `${t("administrators:updateAdmin")} "${values.value.name}"`;
|
|
393
|
+
});
|
|
394
|
+
const isContentLoading = computed(() => isAdminLoading.value || isRoleListLoading.value);
|
|
395
|
+
return {
|
|
396
|
+
t,
|
|
397
|
+
backButtonUrl: getAdminListUrl(),
|
|
398
|
+
values,
|
|
399
|
+
errors,
|
|
400
|
+
isSubmitting,
|
|
401
|
+
submitForm,
|
|
402
|
+
isContentLoading,
|
|
403
|
+
admin,
|
|
404
|
+
pageTitle,
|
|
405
|
+
isCreation,
|
|
406
|
+
roleOptionList
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
411
|
+
const _component_FormField = resolveComponent("FormField");
|
|
412
|
+
const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
|
|
413
|
+
const _component_FormFooter = resolveComponent("FormFooter");
|
|
414
|
+
const _component_Page = resolveComponent("Page");
|
|
415
|
+
return openBlock(), createBlock(_component_Page, {
|
|
416
|
+
title: _ctx.pageTitle,
|
|
417
|
+
"is-content-loading": _ctx.isContentLoading
|
|
418
|
+
}, {
|
|
419
|
+
footer: withCtx(() => [
|
|
420
|
+
createVNode(_component_FormFooter, {
|
|
421
|
+
"back-href": _ctx.backButtonUrl,
|
|
422
|
+
onSubmit: _ctx.submitForm,
|
|
423
|
+
"is-submitting": _ctx.isSubmitting,
|
|
424
|
+
"is-creation": _ctx.isCreation,
|
|
425
|
+
"can-create-another": _ctx.isCreation
|
|
426
|
+
}, null, 8, ["back-href", "onSubmit", "is-submitting", "is-creation", "can-create-another"])
|
|
427
|
+
]),
|
|
428
|
+
default: withCtx(() => [
|
|
429
|
+
createElementVNode("form", {
|
|
430
|
+
novalidate: "",
|
|
431
|
+
onSubmit: _cache[4] || (_cache[4] = withModifiers(() => {
|
|
432
|
+
}, ["prevent"]))
|
|
433
|
+
}, [
|
|
434
|
+
createVNode(_component_FormField, {
|
|
435
|
+
value: _ctx.values.name,
|
|
436
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.values.name = $event),
|
|
437
|
+
name: "name",
|
|
438
|
+
error: _ctx.errors.name,
|
|
439
|
+
label: _ctx.$i18n.t("administrators:name")
|
|
440
|
+
}, null, 8, ["value", "error", "label"]),
|
|
441
|
+
createVNode(_component_FormField, {
|
|
442
|
+
value: _ctx.values.email,
|
|
443
|
+
"onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.values.email = $event),
|
|
444
|
+
name: "email",
|
|
445
|
+
error: _ctx.errors.email,
|
|
446
|
+
label: _ctx.$i18n.t("administrators:email")
|
|
447
|
+
}, null, 8, ["value", "error", "label"]),
|
|
448
|
+
createVNode(_component_FormFieldMultiSelect, {
|
|
449
|
+
"selected-options": _ctx.values.roles,
|
|
450
|
+
"onUpdate:selected-options": _cache[2] || (_cache[2] = ($event) => _ctx.values.roles = $event),
|
|
451
|
+
name: "roles",
|
|
452
|
+
label: _ctx.$i18n.t("administrators:roles"),
|
|
453
|
+
options: _ctx.roleOptionList,
|
|
454
|
+
error: _ctx.errors.roles
|
|
455
|
+
}, null, 8, ["selected-options", "label", "options", "error"]),
|
|
456
|
+
createVNode(_component_FormField, {
|
|
457
|
+
value: _ctx.values.password,
|
|
458
|
+
"onUpdate:value": _cache[3] || (_cache[3] = ($event) => _ctx.values.password = $event),
|
|
459
|
+
name: "password",
|
|
460
|
+
error: _ctx.errors.password,
|
|
461
|
+
label: _ctx.isCreation ? _ctx.$i18n.t("administrators:password") : _ctx.$i18n.t("administrators:newPassword")
|
|
462
|
+
}, null, 8, ["value", "error", "label"])
|
|
463
|
+
], 32)
|
|
464
|
+
]),
|
|
465
|
+
_: 1
|
|
466
|
+
}, 8, ["title", "is-content-loading"]);
|
|
467
|
+
}
|
|
468
|
+
var AdminForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
469
|
+
var RoleList_vue_vue_type_style_index_0_lang = "";
|
|
470
|
+
const _sfc_main$1 = defineComponent({
|
|
471
|
+
name: "RoleList",
|
|
472
|
+
components: {
|
|
473
|
+
Page,
|
|
474
|
+
DeleteIcon,
|
|
475
|
+
EditIcon,
|
|
476
|
+
DataTable,
|
|
477
|
+
BaseButton
|
|
478
|
+
},
|
|
479
|
+
setup() {
|
|
480
|
+
const { t } = useI18n();
|
|
481
|
+
const {
|
|
482
|
+
fetchEntityList: fetchRoleList,
|
|
483
|
+
isLoading: isRoleListLoading,
|
|
484
|
+
rowData: roleList,
|
|
485
|
+
errorMessage: error
|
|
486
|
+
} = useDataTable({
|
|
487
|
+
fetchEntityList: (params) => getRoleList(),
|
|
488
|
+
initialValue: [],
|
|
489
|
+
resourceName: "Role list",
|
|
490
|
+
pageSize: 100
|
|
491
|
+
});
|
|
492
|
+
onMounted(() => {
|
|
493
|
+
fetchRoleList();
|
|
494
|
+
});
|
|
495
|
+
const {
|
|
496
|
+
handleResourceDelete: handleRoleDelete,
|
|
497
|
+
isDeleting
|
|
498
|
+
} = useResourceDelete({
|
|
499
|
+
deleteResource: deleteRole,
|
|
500
|
+
resourceName: "Role",
|
|
501
|
+
onSuccess: fetchRoleList
|
|
502
|
+
});
|
|
503
|
+
function isBusy(roleId) {
|
|
504
|
+
return isDeleting(roleId) || isRoleListLoading.value;
|
|
505
|
+
}
|
|
506
|
+
function getScopeGroupList(scopes) {
|
|
507
|
+
const map = /* @__PURE__ */ new Map();
|
|
508
|
+
scopes.forEach((scope) => {
|
|
509
|
+
var _a;
|
|
510
|
+
const key = scope.module;
|
|
511
|
+
const value = (_a = map.get(key)) != null ? _a : [];
|
|
512
|
+
value.push(scope);
|
|
513
|
+
map.set(key, value);
|
|
514
|
+
});
|
|
515
|
+
return Array.from(map.entries()).map(([key, value]) => ({
|
|
516
|
+
module: key,
|
|
517
|
+
scopes: value
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
function getRestScopesText(restPrivilegesCount) {
|
|
521
|
+
if (restPrivilegesCount === 1) {
|
|
522
|
+
return t("administrators:andMorePrivilege", { count: 1 });
|
|
523
|
+
}
|
|
524
|
+
if (restPrivilegesCount > 1) {
|
|
525
|
+
return t("administrators:andMorePrivilege", {
|
|
526
|
+
count: restPrivilegesCount
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
return "";
|
|
530
|
+
}
|
|
531
|
+
const columnDefs = [
|
|
532
|
+
{
|
|
533
|
+
id: 1,
|
|
534
|
+
name: t("administrators:role"),
|
|
535
|
+
field: "name"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
id: 2,
|
|
539
|
+
name: t("administrators:privileges"),
|
|
540
|
+
field: "scope"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: 3,
|
|
544
|
+
name: t("administrators:actions"),
|
|
545
|
+
field: "actions",
|
|
546
|
+
style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
|
|
547
|
+
headStyle: { width: "180px", textAlign: "center" }
|
|
548
|
+
}
|
|
549
|
+
];
|
|
550
|
+
return {
|
|
551
|
+
columnDefs,
|
|
552
|
+
rowData: roleList,
|
|
553
|
+
isRowDataLoading: isRoleListLoading,
|
|
554
|
+
errorMessage: error,
|
|
555
|
+
isBusy,
|
|
556
|
+
handleRoleDelete,
|
|
557
|
+
getRoleFormUrl,
|
|
558
|
+
getScopeGroupList,
|
|
559
|
+
getRestScopesText,
|
|
560
|
+
scopesPerModuleCount: 3
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
const _hoisted_1 = {
|
|
565
|
+
key: 0,
|
|
566
|
+
class: "no-scopes"
|
|
567
|
+
};
|
|
568
|
+
const _hoisted_2 = { key: 1 };
|
|
569
|
+
const _hoisted_3 = { class: "module-name" };
|
|
570
|
+
const _hoisted_4 = { class: "scope-list" };
|
|
571
|
+
const _hoisted_5 = {
|
|
572
|
+
key: 0,
|
|
573
|
+
class: "rest-scopes-text"
|
|
574
|
+
};
|
|
575
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
576
|
+
const _component_EditIcon = resolveComponent("EditIcon");
|
|
577
|
+
const _component_BaseButton = resolveComponent("BaseButton");
|
|
578
|
+
const _component_DeleteIcon = resolveComponent("DeleteIcon");
|
|
579
|
+
const _component_DataTable = resolveComponent("DataTable");
|
|
580
|
+
const _component_Page = resolveComponent("Page");
|
|
581
|
+
return openBlock(), createBlock(_component_Page, {
|
|
582
|
+
title: _ctx.$i18n.t("administrators:listOfRoles"),
|
|
583
|
+
"header-buttons": [
|
|
584
|
+
{
|
|
585
|
+
text: _ctx.$i18n.t("administrators:addRole"),
|
|
586
|
+
href: _ctx.getRoleFormUrl({ roleId: "create" })
|
|
587
|
+
}
|
|
588
|
+
]
|
|
589
|
+
}, {
|
|
590
|
+
default: withCtx(() => [
|
|
591
|
+
createVNode(_component_DataTable, {
|
|
592
|
+
"column-defs": _ctx.columnDefs,
|
|
593
|
+
"row-data": _ctx.rowData,
|
|
594
|
+
loading: _ctx.isRowDataLoading,
|
|
595
|
+
"error-message": _ctx.errorMessage
|
|
596
|
+
}, {
|
|
597
|
+
"cell(scope)": withCtx(({ row }) => [
|
|
598
|
+
row.scopes.length === 0 ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(_ctx.$i18n.t("administrators:noPrivileges")), 1)) : createCommentVNode("", true),
|
|
599
|
+
row.isSuperAdmin ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(_ctx.$i18n.t("administrators:all")), 1)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.getScopeGroupList(row.scopes), (scopeGroup) => {
|
|
600
|
+
return openBlock(), createElementBlock("div", {
|
|
601
|
+
key: scopeGroup.module,
|
|
602
|
+
class: "scope-group"
|
|
603
|
+
}, [
|
|
604
|
+
createElementVNode("span", _hoisted_3, toDisplayString(scopeGroup.module), 1),
|
|
605
|
+
createElementVNode("ul", _hoisted_4, [
|
|
606
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(scopeGroup.scopes.slice(0, _ctx.scopesPerModuleCount), (scope) => {
|
|
607
|
+
return openBlock(), createElementBlock("li", {
|
|
608
|
+
key: scope.value
|
|
609
|
+
}, [
|
|
610
|
+
createElementVNode("span", null, "\u2014 " + toDisplayString(scope.label), 1)
|
|
611
|
+
]);
|
|
612
|
+
}), 128))
|
|
613
|
+
]),
|
|
614
|
+
scopeGroup.scopes.length > _ctx.scopesPerModuleCount ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(_ctx.getRestScopesText(scopeGroup.scopes.length - _ctx.scopesPerModuleCount)), 1)) : createCommentVNode("", true)
|
|
615
|
+
]);
|
|
616
|
+
}), 128))
|
|
617
|
+
]),
|
|
618
|
+
"cell(actions)": withCtx(({ row }) => [
|
|
619
|
+
createVNode(_component_BaseButton, {
|
|
620
|
+
variant: "icon",
|
|
621
|
+
title: _ctx.$i18n.t("administrators:edit"),
|
|
622
|
+
disabled: _ctx.isBusy(row.id),
|
|
623
|
+
href: _ctx.getRoleFormUrl({ roleId: row.id })
|
|
624
|
+
}, {
|
|
625
|
+
default: withCtx(() => [
|
|
626
|
+
createVNode(_component_EditIcon)
|
|
627
|
+
]),
|
|
628
|
+
_: 2
|
|
629
|
+
}, 1032, ["title", "disabled", "href"]),
|
|
630
|
+
!row.isSuperAdmin ? (openBlock(), createBlock(_component_BaseButton, {
|
|
631
|
+
key: 0,
|
|
632
|
+
variant: "icon",
|
|
633
|
+
title: _ctx.$i18n.t("administrators:delete"),
|
|
634
|
+
disabled: _ctx.isBusy(row.id),
|
|
635
|
+
onClick: ($event) => _ctx.handleRoleDelete(row.id)
|
|
636
|
+
}, {
|
|
637
|
+
default: withCtx(() => [
|
|
638
|
+
createVNode(_component_DeleteIcon)
|
|
639
|
+
]),
|
|
640
|
+
_: 2
|
|
641
|
+
}, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
|
|
642
|
+
]),
|
|
643
|
+
_: 1
|
|
644
|
+
}, 8, ["column-defs", "row-data", "loading", "error-message"])
|
|
645
|
+
]),
|
|
646
|
+
_: 1
|
|
647
|
+
}, 8, ["title", "header-buttons"]);
|
|
648
|
+
}
|
|
649
|
+
var RoleList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
650
|
+
function convertRoleToFormValues(role) {
|
|
651
|
+
if (!role) {
|
|
652
|
+
return {
|
|
653
|
+
name: "",
|
|
654
|
+
scopes: [],
|
|
655
|
+
isSuperAdmin: false
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
name: role.name,
|
|
660
|
+
scopes: role.scopes,
|
|
661
|
+
isSuperAdmin: role.isSuperAdmin
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function convertFormValuesToRoleCreationPayload(values) {
|
|
665
|
+
return {
|
|
666
|
+
name: values.name,
|
|
667
|
+
scopes: values.scopes.map((scope) => scope.value)
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
function convertFormValuesToRoleUpdatePayload(values) {
|
|
671
|
+
return {
|
|
672
|
+
...convertFormValuesToRoleCreationPayload(values)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function convertScopeDataToOptions(scopeData) {
|
|
676
|
+
if (!scopeData)
|
|
677
|
+
return [];
|
|
678
|
+
return scopeData.groups.map((group) => group.scopes.map((scope) => ({
|
|
679
|
+
value: scope.value,
|
|
680
|
+
label: `${group.name}: ${scope.label}`
|
|
681
|
+
}))).flat();
|
|
682
|
+
}
|
|
683
|
+
var RoleForm_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
684
|
+
const _sfc_main = defineComponent({
|
|
685
|
+
name: "RoleForm",
|
|
686
|
+
components: { Page, FormFooter, FormField, FormFieldMultiSelect },
|
|
687
|
+
setup() {
|
|
688
|
+
const { t } = useI18n();
|
|
689
|
+
const route = useRoute();
|
|
690
|
+
const router = useRouter();
|
|
691
|
+
const toast = useToast();
|
|
692
|
+
const roleId = computed(() => route.params.roleId);
|
|
693
|
+
const isCreation = computed(() => roleId.value === "create");
|
|
694
|
+
const [fetchRole, { data: role, loading: isRoleLoading }] = useResource({
|
|
695
|
+
fetchResource: () => getRole(roleId.value),
|
|
696
|
+
initialValue: null,
|
|
697
|
+
resourceName: "Role"
|
|
698
|
+
});
|
|
699
|
+
const [
|
|
700
|
+
fetchScopeData,
|
|
701
|
+
{ data: scopeData, loading: isScopeDataLoading }
|
|
702
|
+
] = useResource({
|
|
703
|
+
fetchResource: getScopes,
|
|
704
|
+
initialValue: null,
|
|
705
|
+
resourceName: "Scope list"
|
|
706
|
+
});
|
|
707
|
+
onMounted(() => {
|
|
708
|
+
fetchScopeData();
|
|
709
|
+
if (isCreation.value)
|
|
710
|
+
return;
|
|
711
|
+
fetchRole();
|
|
712
|
+
});
|
|
713
|
+
const scopeOptionList = computed(() => convertScopeDataToOptions(scopeData.value));
|
|
714
|
+
const values = ref(convertRoleToFormValues(role.value));
|
|
715
|
+
const errors = ref({});
|
|
716
|
+
const isSubmitting = ref(false);
|
|
717
|
+
watch(role, () => {
|
|
718
|
+
values.value = convertRoleToFormValues(role.value);
|
|
719
|
+
});
|
|
720
|
+
function submitForm(event) {
|
|
721
|
+
const creationBody = convertFormValuesToRoleCreationPayload(values.value);
|
|
722
|
+
const updateBody = convertFormValuesToRoleUpdatePayload(values.value);
|
|
723
|
+
const requestPromise = isCreation.value ? createRole(creationBody) : updateRole(roleId.value, updateBody);
|
|
724
|
+
requestPromise.then(({ data }) => {
|
|
725
|
+
errors.value = {};
|
|
726
|
+
if (event.type === "create") {
|
|
727
|
+
router.push(getRoleFormUrl({ roleId: data.id }));
|
|
728
|
+
}
|
|
729
|
+
if (event.type === "create_exit" || event.type === "save_exit") {
|
|
730
|
+
navigateBack(router, getRoleListUrl());
|
|
731
|
+
}
|
|
732
|
+
if (event.type === "create_create-another") {
|
|
733
|
+
values.value = convertRoleToFormValues(null);
|
|
734
|
+
}
|
|
735
|
+
toast.show({
|
|
736
|
+
variant: "success",
|
|
737
|
+
title: t("administrators:success"),
|
|
738
|
+
body: isCreation.value ? t("administrators:roleSuccessfullyCreated") : t("administrators:roleSuccessfullyUpdate")
|
|
739
|
+
});
|
|
740
|
+
}).catch((error) => {
|
|
741
|
+
console.error(error);
|
|
742
|
+
errors.value = convertRequestErrorToMap(error);
|
|
743
|
+
toast.show({
|
|
744
|
+
variant: "danger",
|
|
745
|
+
title: t("administrators:error"),
|
|
746
|
+
body: isCreation.value ? t("administrators:roleCreationError") : t("administrators:roleUpdateError")
|
|
747
|
+
});
|
|
748
|
+
}).finally(() => {
|
|
749
|
+
isSubmitting.value = false;
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
const pageTitle = computed(() => {
|
|
753
|
+
return isCreation.value ? t("administrators:createRole") : `${t("administrators:updateRole")} "${values.value.name}"`;
|
|
754
|
+
});
|
|
755
|
+
const isContentLoading = computed(() => isRoleLoading.value || isScopeDataLoading.value);
|
|
756
|
+
return {
|
|
757
|
+
backButtonUrl: getRoleListUrl(),
|
|
758
|
+
values,
|
|
759
|
+
errors,
|
|
760
|
+
isSubmitting,
|
|
761
|
+
submitForm,
|
|
762
|
+
isContentLoading,
|
|
763
|
+
role,
|
|
764
|
+
pageTitle,
|
|
765
|
+
isCreation,
|
|
766
|
+
scopeOptionList
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
771
|
+
const _component_FormField = resolveComponent("FormField");
|
|
772
|
+
const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
|
|
773
|
+
const _component_FormFooter = resolveComponent("FormFooter");
|
|
774
|
+
const _component_Page = resolveComponent("Page");
|
|
775
|
+
return openBlock(), createBlock(_component_Page, {
|
|
776
|
+
title: _ctx.pageTitle,
|
|
777
|
+
"is-content-loading": _ctx.isContentLoading
|
|
778
|
+
}, {
|
|
779
|
+
footer: withCtx(() => [
|
|
780
|
+
createVNode(_component_FormFooter, {
|
|
781
|
+
"back-href": _ctx.backButtonUrl,
|
|
782
|
+
onSubmit: _ctx.submitForm,
|
|
783
|
+
"is-submitting": _ctx.isSubmitting,
|
|
784
|
+
"is-creation": _ctx.isCreation,
|
|
785
|
+
"can-create-another": _ctx.isCreation
|
|
786
|
+
}, null, 8, ["back-href", "onSubmit", "is-submitting", "is-creation", "can-create-another"])
|
|
787
|
+
]),
|
|
788
|
+
default: withCtx(() => [
|
|
789
|
+
createElementVNode("form", {
|
|
790
|
+
novalidate: "",
|
|
791
|
+
onSubmit: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
792
|
+
}, ["prevent"]))
|
|
793
|
+
}, [
|
|
794
|
+
createVNode(_component_FormField, {
|
|
795
|
+
value: _ctx.values.name,
|
|
796
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.values.name = $event),
|
|
797
|
+
name: "name",
|
|
798
|
+
error: _ctx.errors.name,
|
|
799
|
+
label: _ctx.$i18n.t("administrators:name")
|
|
800
|
+
}, null, 8, ["value", "error", "label"]),
|
|
801
|
+
!_ctx.values.isSuperAdmin ? (openBlock(), createBlock(_component_FormFieldMultiSelect, {
|
|
802
|
+
key: 0,
|
|
803
|
+
"selected-options": _ctx.values.scopes,
|
|
804
|
+
"onUpdate:selected-options": _cache[1] || (_cache[1] = ($event) => _ctx.values.scopes = $event),
|
|
805
|
+
name: "scopes",
|
|
806
|
+
label: _ctx.$i18n.t("administrators:privileges"),
|
|
807
|
+
options: _ctx.scopeOptionList,
|
|
808
|
+
error: _ctx.errors.scopes
|
|
809
|
+
}, null, 8, ["selected-options", "label", "options", "error"])) : createCommentVNode("", true)
|
|
810
|
+
], 32)
|
|
811
|
+
]),
|
|
812
|
+
_: 1
|
|
813
|
+
}, 8, ["title", "is-content-loading"]);
|
|
814
|
+
}
|
|
815
|
+
var RoleForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-501ddc14"]]);
|
|
816
|
+
const ADMIN_LIST_ROUTE = {
|
|
817
|
+
path: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
|
|
818
|
+
component: AdminList,
|
|
819
|
+
name: "AdminList",
|
|
820
|
+
meta: {
|
|
821
|
+
getBreadcrumbs: (route, i18n2) => [
|
|
822
|
+
{ url: "/", text: i18n2.t("administrators:home") },
|
|
823
|
+
{
|
|
824
|
+
url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
|
|
825
|
+
text: i18n2.t("administrators:adminList")
|
|
826
|
+
}
|
|
827
|
+
]
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
const ADMIN_FORM_ROUTE = {
|
|
831
|
+
path: ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM,
|
|
832
|
+
component: AdminForm,
|
|
833
|
+
name: "AdminForm",
|
|
834
|
+
meta: {
|
|
835
|
+
getBreadcrumbs: (route, i18n2) => [
|
|
836
|
+
{ url: "/", text: i18n2.t("administrators:home") },
|
|
837
|
+
{
|
|
838
|
+
url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
|
|
839
|
+
text: i18n2.t("administrators:adminList")
|
|
840
|
+
},
|
|
841
|
+
{ url: route.path, text: i18n2.t("administrators:adminForm") }
|
|
842
|
+
]
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
const ROLE_LIST_ROUTE = {
|
|
846
|
+
path: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
|
|
847
|
+
component: RoleList,
|
|
848
|
+
name: "RoleList",
|
|
849
|
+
meta: {
|
|
850
|
+
getBreadcrumbs: (route, i18n2) => [
|
|
851
|
+
{ url: "/", text: i18n2.t("administrators:home") },
|
|
852
|
+
{
|
|
853
|
+
url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
|
|
854
|
+
text: i18n2.t("administrators:roleList")
|
|
855
|
+
}
|
|
856
|
+
]
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
const ROLE_FORM_ROUTE = {
|
|
860
|
+
path: ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM,
|
|
861
|
+
component: RoleForm,
|
|
862
|
+
name: "RoleForm",
|
|
863
|
+
meta: {
|
|
864
|
+
getBreadcrumbs: (route, i18n2) => [
|
|
865
|
+
{ url: "/", text: i18n2.t("administrators:home") },
|
|
866
|
+
{
|
|
867
|
+
url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
|
|
868
|
+
text: i18n2.t("administrators:roleList")
|
|
869
|
+
},
|
|
870
|
+
{ url: route.path, text: i18n2.t("administrators:roleForm") }
|
|
871
|
+
]
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
applyTranslations();
|
|
875
|
+
export { ADMIN_FORM_ROUTE, ADMIN_LIST_ROUTE, ROLE_FORM_ROUTE, ROLE_LIST_ROUTE, createAdmin, createRole, deleteAdmin, deleteRole, getAdmin, getAdminFormUrl, getAdminList, getAdminListUrl, getRole, getRoleFormUrl, getRoleList, getRoleListUrl, getScopes, updateAdmin, updateRole };
|