@tager/admin-administrators 1.0.1 → 1.0.2

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/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { i18n, request, useI18n, useResourceDelete, createId, useToast, useResource, notEmpty, 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, TabList, FormFooter, FormField, FormFieldMultiSelect } from "@tager/admin-ui";
4
- import { universalFieldUtils, DynamicField } from "@tager/admin-dynamic-field";
5
- import { compile } from "path-to-regexp";
6
- import { Page } from "@tager/admin-layout";
7
- import { useRoute, useRouter } from "vue-router";
8
- const EN = {
1
+ import { i18n as te, request as h, useI18n as q, useResourceDelete as ne, createId as Ie, useToast as re, useResource as P, notEmpty as $e, navigateBack as se, convertRequestErrorToMap as ie } from "@tager/admin-services";
2
+ import { defineComponent as z, onMounted as H, resolveComponent as l, openBlock as i, createBlock as S, withCtx as b, createVNode as g, createCommentVNode as I, createElementVNode as C, createElementBlock as F, Fragment as k, renderList as V, toDisplayString as w, computed as R, ref as D, watch as Z, withModifiers as le } from "vue";
3
+ import { EditIcon as de, DeleteIcon as ue, BaseButton as me, DataTable as ce, useDataTable as pe, FormFieldMultiSelect as fe, FormField as ge, FormFooter as ve, TabList as Ee } from "@tager/admin-ui";
4
+ import { Page as j } from "@tager/admin-layout";
5
+ import { universalFieldUtils as be, DynamicField as Me } from "@tager/admin-dynamic-field";
6
+ import { compile as Re } from "path-to-regexp";
7
+ import { useRoute as Le, useRouter as he } from "vue-router";
8
+ const Ue = {
9
9
  home: "Home",
10
10
  administrators: "Administrators",
11
11
  role: "Role",
@@ -48,244 +48,233 @@ const EN = {
48
48
  general: "General",
49
49
  params: "Template"
50
50
  }
51
- };
52
- const RU = {
53
- home: "\u0413\u043B\u0430\u0432\u043D\u0430\u044F",
54
- administrators: "\u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u044B",
55
- role: "\u0420\u043E\u043B\u044C",
56
- roles: "\u0420\u043E\u043B\u0438",
57
- admin: "\u0410\u0434\u043C\u0438\u043D",
58
- admins: "\u0410\u0434\u043C\u0438\u043D\u044B",
59
- createRole: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0440\u043E\u043B\u044C",
60
- createAdmin: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0430",
61
- createAdministrator: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
62
- edit: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
63
- delete: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
64
- email: "\u042D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u0430\u044F \u043F\u043E\u0447\u0442\u0430",
65
- actions: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
66
- updateRole: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0440\u043E\u043B\u044C",
67
- updateAdmin: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
68
- password: "\u041F\u0430\u0440\u043E\u043B\u044C",
69
- newPassword: "\u041D\u043E\u0432\u044B\u0439 \u043F\u0430\u0440\u043E\u043B\u044C",
70
- name: "\u0418\u043C\u044F",
71
- success: "\u0423\u0441\u043F\u0435\u0445",
72
- adminSuccessfullyCreated: "\u0410\u0434\u043C\u0438\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D",
73
- adminSuccessfullyUpdated: "\u0410\u0434\u043C\u0438\u043D \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D",
74
- error: "\u041E\u0448\u0438\u0431\u043A\u0430",
75
- 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",
76
- 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",
77
- listOfRoles: "\u0421\u043F\u0438\u0441\u043E\u043A \u0440\u043E\u043B\u0435\u0439",
78
- addRole: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u043E\u043B\u044C",
79
- noPrivileges: "\u0411\u0435\u0437 \u043F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0439",
80
- privileges: "\u041F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0438",
81
- all: "\u0412\u0441\u0435",
82
- roleSuccessfullyCreated: "\u0420\u043E\u043B\u044C \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430",
83
- roleSuccessfullyUpdate: "\u0420\u043E\u043B\u044C \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0430",
84
- roleCreationError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0440\u043E\u043B\u0438",
85
- roleUpdateError: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u0440\u043E\u043B\u0438",
86
- adminList: "\u0421\u043F\u0438\u0441\u043E\u043A \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u043E\u0432",
87
- adminForm: "\u0424\u043E\u0440\u043C\u0430 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
88
- roleList: "\u0421\u043F\u0438\u0441\u043E\u043A \u0440\u043E\u043B\u0435\u0439",
89
- roleForm: "\u0424\u043E\u0440\u043C\u0430 \u0440\u043E\u043B\u0438",
90
- andMorePrivilege: "\u0438 \u0435\u0449\u0435 {{count}} \u043F\u0440\u0438\u0432\u0438\u043B\u0435\u0433\u0438\u0439...",
51
+ }, we = {
52
+ home: "Главная",
53
+ administrators: "Администраторы",
54
+ role: "Роль",
55
+ roles: "Роли",
56
+ admin: "Админ",
57
+ admins: "Админы",
58
+ createRole: "Создать роль",
59
+ createAdmin: "Создать админа",
60
+ createAdministrator: "Создать администратора",
61
+ edit: "Редактировать",
62
+ delete: "Удалить",
63
+ email: "Электронная почта",
64
+ actions: "Действия",
65
+ updateRole: "Обновить роль",
66
+ updateAdmin: "Обновить администратора",
67
+ password: "Пароль",
68
+ newPassword: "Новый пароль",
69
+ name: "Имя",
70
+ success: "Успех",
71
+ adminSuccessfullyCreated: "Админ успешно создан",
72
+ adminSuccessfullyUpdated: "Админ успешно обновлен",
73
+ error: "Ошибка",
74
+ adminCreationError: "Ошибка создания администратора",
75
+ adminUpdateError: "Ошибка обновления администратора",
76
+ listOfRoles: "Список ролей",
77
+ addRole: "Добавить роль",
78
+ noPrivileges: "Без привилегий",
79
+ privileges: "Привилегии",
80
+ all: "Все",
81
+ roleSuccessfullyCreated: "Роль успешно создана",
82
+ roleSuccessfullyUpdate: "Роль успешно обновлена",
83
+ roleCreationError: "Ошибка создания роли",
84
+ roleUpdateError: "Ошибка обновления роли",
85
+ adminList: "Список администраторов",
86
+ adminForm: "Форма администратора",
87
+ roleList: "Список ролей",
88
+ roleForm: "Форма роли",
89
+ andMorePrivilege: "и еще {{count}} привилегий...",
91
90
  tabs: {
92
- general: "\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0435",
93
- params: "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B"
91
+ general: "Основное",
92
+ params: "Параметры"
94
93
  }
95
94
  };
96
- function applyTranslations() {
97
- i18n.addTranslations("en", "administrators", EN);
98
- i18n.addTranslations("ru", "administrators", RU);
95
+ function Ce() {
96
+ te.addTranslations("en", "administrators", Ue), te.addTranslations("ru", "administrators", we);
99
97
  }
100
- function getFieldList() {
101
- return request.get({ path: "/admin/admins/fields" });
98
+ function Oe() {
99
+ return h.get({ path: "/admin/admins/fields" });
102
100
  }
103
- function getRoleList() {
104
- return request.get({ path: "/admin/rbac/roles" });
101
+ function ye() {
102
+ return h.get({ path: "/admin/rbac/roles" });
105
103
  }
106
- function getRole(roleId) {
107
- return request.get({ path: `/admin/rbac/roles/${roleId}` });
104
+ function Pe(e) {
105
+ return h.get({ path: `/admin/rbac/roles/${e}` });
108
106
  }
109
- function createRole(payload) {
110
- return request.post({ path: "/admin/rbac/roles", body: payload });
107
+ function ke(e) {
108
+ return h.post({ path: "/admin/rbac/roles", body: e });
111
109
  }
112
- function updateRole(roleId, payload) {
113
- return request.put({ path: `/admin/rbac/roles/${roleId}`, body: payload });
110
+ function Be(e, t) {
111
+ return h.put({ path: `/admin/rbac/roles/${e}`, body: t });
114
112
  }
115
- function deleteRole(roleId) {
116
- return request.delete({ path: `/admin/rbac/roles/${roleId}` });
113
+ function Ne(e) {
114
+ return h.delete({ path: `/admin/rbac/roles/${e}` });
117
115
  }
118
- function getScopes() {
119
- return request.get({ path: "/admin/rbac/scopes" });
116
+ function _e() {
117
+ return h.get({ path: "/admin/rbac/scopes" });
120
118
  }
121
- function getAdminList() {
122
- return request.get({ path: "/admin/admins" });
119
+ function Ve() {
120
+ return h.get({ path: "/admin/admins" });
123
121
  }
124
- function getAdmin(adminId) {
125
- return request.get({ path: `/admin/admins/${adminId}` });
122
+ function qe(e) {
123
+ return h.get({ path: `/admin/admins/${e}` });
126
124
  }
127
- function createAdmin(payload) {
128
- return request.post({ path: "/admin/admins", body: payload });
125
+ function ze(e) {
126
+ return h.post({ path: "/admin/admins", body: e });
129
127
  }
130
- function updateAdmin(adminId, payload) {
131
- return request.put({ path: `/admin/admins/${adminId}`, body: payload });
128
+ function He(e, t) {
129
+ return h.put({ path: `/admin/admins/${e}`, body: t });
132
130
  }
133
- function deleteAdmin(adminId) {
134
- return request.delete({ path: `/admin/admins/${adminId}` });
131
+ function je(e) {
132
+ return h.delete({ path: `/admin/admins/${e}` });
135
133
  }
136
- const ADMINISTRATOR_ROUTE_PATHS = {
134
+ const L = {
137
135
  ROLE_LIST: "/roles",
138
136
  ROLE_FORM: "/roles/:roleId",
139
137
  ADMIN_LIST: "/admins",
140
138
  ADMIN_FORM: "/admins/:adminId"
141
139
  };
142
- function getRoleListUrl() {
143
- return ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST;
140
+ function ae() {
141
+ return L.ROLE_LIST;
144
142
  }
145
- function getRoleFormUrl(params) {
146
- return compile(ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM)(params);
143
+ function Fe(e) {
144
+ return Re(L.ROLE_FORM)(e);
147
145
  }
148
- function getAdminListUrl() {
149
- return ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST;
146
+ function oe() {
147
+ return L.ADMIN_LIST;
150
148
  }
151
- function getAdminFormUrl(params) {
152
- return compile(ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM)(params);
149
+ function Ae(e) {
150
+ return Re(L.ADMIN_FORM)(e);
153
151
  }
154
- var _export_sfc = (sfc, props) => {
155
- const target = sfc.__vccOpts || sfc;
156
- for (const [key, val] of props) {
157
- target[key] = val;
158
- }
159
- return target;
160
- };
161
- const _sfc_main$3 = defineComponent({
152
+ const Je = z({
162
153
  name: "AdminList",
163
154
  components: {
164
- Page,
165
- DataTable,
166
- BaseButton,
167
- DeleteIcon,
168
- EditIcon
155
+ Page: j,
156
+ DataTable: ce,
157
+ BaseButton: me,
158
+ DeleteIcon: ue,
159
+ EditIcon: de
169
160
  },
170
161
  setup() {
171
- const { t } = useI18n();
172
- const {
173
- fetchEntityList: fetchAdminList,
174
- isLoading: isAdminListLoading,
175
- rowData: adminList,
176
- errorMessage: error
177
- } = useDataTable({
178
- fetchEntityList: () => getAdminList(),
162
+ const { t: e } = q(), {
163
+ fetchEntityList: t,
164
+ isLoading: r,
165
+ rowData: m,
166
+ errorMessage: d
167
+ } = pe({
168
+ fetchEntityList: () => Ve(),
179
169
  initialValue: [],
180
170
  resourceName: "Admin list",
181
171
  pageSize: 100
182
172
  });
183
- onMounted(() => {
184
- fetchAdminList();
173
+ H(() => {
174
+ t();
185
175
  });
186
176
  const {
187
- handleResourceDelete: handleAdminDelete,
188
- isDeleting
189
- } = useResourceDelete({
190
- deleteResource: deleteAdmin,
177
+ handleResourceDelete: s,
178
+ isDeleting: c
179
+ } = ne({
180
+ deleteResource: je,
191
181
  resourceName: "Admin",
192
- onSuccess: fetchAdminList
182
+ onSuccess: t
193
183
  });
194
- function isBusy(adminId) {
195
- return isDeleting(adminId) || isAdminListLoading.value;
184
+ function n(f) {
185
+ return c(f) || r.value;
196
186
  }
197
- const columnDefs = [
187
+ const p = [
198
188
  {
199
189
  id: 1,
200
- name: t("administrators:admin"),
190
+ name: e("administrators:admin"),
201
191
  field: "name"
202
192
  },
203
193
  {
204
194
  id: 2,
205
- name: t("administrators:email"),
195
+ name: e("administrators:email"),
206
196
  field: "email"
207
197
  },
208
198
  {
209
199
  id: 3,
210
- name: t("administrators:roles"),
200
+ name: e("administrators:roles"),
211
201
  field: "roles"
212
202
  },
213
203
  {
214
204
  id: 4,
215
- name: t("administrators:actions"),
205
+ name: e("administrators:actions"),
216
206
  field: "actions",
217
207
  style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
218
208
  headStyle: { width: "180px", textAlign: "center" }
219
209
  }
220
210
  ];
221
211
  return {
222
- t,
223
- columnDefs,
224
- rowData: adminList,
225
- isRowDataLoading: isAdminListLoading,
226
- errorMessage: error,
227
- isBusy,
228
- handleAdminDelete,
229
- getAdminFormUrl
212
+ t: e,
213
+ columnDefs: p,
214
+ rowData: m,
215
+ isRowDataLoading: r,
216
+ errorMessage: d,
217
+ isBusy: n,
218
+ handleAdminDelete: s,
219
+ getAdminFormUrl: Ae
230
220
  };
231
221
  }
232
- });
233
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
234
- const _component_EditIcon = resolveComponent("EditIcon");
235
- const _component_BaseButton = resolveComponent("BaseButton");
236
- const _component_DeleteIcon = resolveComponent("DeleteIcon");
237
- const _component_DataTable = resolveComponent("DataTable");
238
- const _component_Page = resolveComponent("Page");
239
- return openBlock(), createBlock(_component_Page, {
240
- title: _ctx.$i18n.t("administrators:administrators"),
222
+ }), J = (e, t) => {
223
+ const r = e.__vccOpts || e;
224
+ for (const [m, d] of t)
225
+ r[m] = d;
226
+ return r;
227
+ };
228
+ function Ke(e, t, r, m, d, s) {
229
+ const c = l("EditIcon"), n = l("BaseButton"), p = l("DeleteIcon"), f = l("DataTable"), v = l("Page");
230
+ return i(), S(v, {
231
+ title: e.$i18n.t("administrators:administrators"),
241
232
  "header-buttons": [
242
233
  {
243
- text: _ctx.$i18n.t("administrators:createAdministrator"),
244
- href: _ctx.getAdminFormUrl({ adminId: "create" })
234
+ text: e.$i18n.t("administrators:createAdministrator"),
235
+ href: e.getAdminFormUrl({ adminId: "create" })
245
236
  }
246
237
  ]
247
238
  }, {
248
- default: withCtx(() => [
249
- createVNode(_component_DataTable, {
250
- "column-defs": _ctx.columnDefs,
251
- "row-data": _ctx.rowData,
252
- loading: _ctx.isRowDataLoading,
253
- "error-message": _ctx.errorMessage
239
+ default: b(() => [
240
+ g(f, {
241
+ "column-defs": e.columnDefs,
242
+ "row-data": e.rowData,
243
+ loading: e.isRowDataLoading,
244
+ "error-message": e.errorMessage
254
245
  }, {
255
- "cell(roles)": withCtx(({ row }) => [
256
- createElementVNode("ul", null, [
257
- (openBlock(true), createElementBlock(Fragment, null, renderList(row.roles, (role) => {
258
- return openBlock(), createElementBlock("li", {
259
- key: role.id
260
- }, toDisplayString(role.name), 1);
261
- }), 128))
246
+ "cell(roles)": b(({ row: a }) => [
247
+ C("ul", null, [
248
+ (i(!0), F(k, null, V(a.roles, (o) => (i(), F("li", {
249
+ key: o.id
250
+ }, w(o.name), 1))), 128))
262
251
  ])
263
252
  ]),
264
- "cell(actions)": withCtx(({ row }) => [
265
- !row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
253
+ "cell(actions)": b(({ row: a }) => [
254
+ a.isSelf ? I("", !0) : (i(), S(n, {
266
255
  key: 0,
267
256
  variant: "icon",
268
- title: _ctx.$i18n.t("administrators:edit"),
269
- disabled: _ctx.isBusy(row.id),
270
- href: _ctx.getAdminFormUrl({ adminId: row.id })
257
+ title: e.$i18n.t("administrators:edit"),
258
+ disabled: e.isBusy(a.id),
259
+ href: e.getAdminFormUrl({ adminId: a.id })
271
260
  }, {
272
- default: withCtx(() => [
273
- createVNode(_component_EditIcon)
261
+ default: b(() => [
262
+ g(c)
274
263
  ]),
275
264
  _: 2
276
- }, 1032, ["title", "disabled", "href"])) : createCommentVNode("", true),
277
- !row.isSuperAdmin || !row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
265
+ }, 1032, ["title", "disabled", "href"])),
266
+ !a.isSuperAdmin || !a.isSelf ? (i(), S(n, {
278
267
  key: 1,
279
268
  variant: "icon",
280
- title: _ctx.$i18n.t("administrators:delete"),
281
- disabled: _ctx.isBusy(row.id),
282
- onClick: ($event) => _ctx.handleAdminDelete(row.id)
269
+ title: e.$i18n.t("administrators:delete"),
270
+ disabled: e.isBusy(a.id),
271
+ onClick: (o) => e.handleAdminDelete(a.id)
283
272
  }, {
284
- default: withCtx(() => [
285
- createVNode(_component_DeleteIcon)
273
+ default: b(() => [
274
+ g(p)
286
275
  ]),
287
276
  _: 2
288
- }, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
277
+ }, 1032, ["title", "disabled", "onClick"])) : I("", !0)
289
278
  ]),
290
279
  _: 1
291
280
  }, 8, ["column-defs", "row-data", "loading", "error-message"])
@@ -293,417 +282,370 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
293
282
  _: 1
294
283
  }, 8, ["title", "header-buttons"]);
295
284
  }
296
- var AdminList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
297
- function convertAdminToFormValues(admin, roleOptionList) {
298
- if (!admin) {
285
+ const Qe = /* @__PURE__ */ J(Je, [["render", Ke]]);
286
+ function X(e, t) {
287
+ if (!e)
299
288
  return {
300
289
  name: "",
301
290
  email: "",
302
- password: createId(),
291
+ password: Ie(),
303
292
  roles: []
304
293
  };
305
- }
306
- const currentRoleOptionList = roleOptionList.filter((role) => admin.roles.some((roles) => roles.id === role.value));
294
+ const r = t.filter(
295
+ (m) => e.roles.some((d) => d.id === m.value)
296
+ );
307
297
  return {
308
- name: admin.name,
309
- email: admin.email,
298
+ name: e.name,
299
+ email: e.email,
310
300
  password: "",
311
- roles: currentRoleOptionList
301
+ roles: r
312
302
  };
313
303
  }
314
- function convertFormValuesToAdminUpdatePayload(values, paramsValues = []) {
304
+ function Se(e, t = []) {
315
305
  return {
316
- name: values.name,
317
- email: values.email,
318
- roles: values.roles.map((role) => role.value),
319
- password: values.password,
320
- params: paramsValues.map((field) => ({
321
- value: universalFieldUtils.getOutgoingValue(field),
322
- name: field.config.name
306
+ name: e.name,
307
+ email: e.email,
308
+ roles: e.roles.map((r) => r.value),
309
+ password: e.password,
310
+ params: t.map((r) => ({
311
+ value: be.getOutgoingValue(r),
312
+ name: r.config.name
323
313
  }))
324
314
  };
325
315
  }
326
- function convertFormValuesToAdminCreationPayload(values, paramsValues = []) {
316
+ function We(e, t = []) {
327
317
  return {
328
- ...convertFormValuesToAdminUpdatePayload(values, paramsValues)
318
+ ...Se(e, t)
329
319
  };
330
320
  }
331
- function convertRoleListToOptions(roleList) {
332
- return roleList.map((role) => ({
333
- value: role.id,
334
- label: role.name
321
+ function Xe(e) {
322
+ return e.map((t) => ({
323
+ value: t.id,
324
+ label: t.name
335
325
  }));
336
326
  }
337
- const _sfc_main$2 = defineComponent({
327
+ const Ye = z({
338
328
  name: "AdminForm",
339
329
  components: {
340
- DynamicField,
341
- TabList,
342
- Page,
343
- FormFooter,
344
- FormField,
345
- FormFieldMultiSelect
330
+ DynamicField: Me,
331
+ TabList: Ee,
332
+ Page: j,
333
+ FormFooter: ve,
334
+ FormField: ge,
335
+ FormFieldMultiSelect: fe
346
336
  },
347
337
  setup() {
348
- const { t } = useI18n();
349
- const route = useRoute();
350
- const router = useRouter();
351
- const toast = useToast();
352
- const adminId = computed(() => route.params.adminId);
353
- const isCreation = computed(() => adminId.value === "create");
354
- const [fetchAdmin, { data: admin, loading: isAdminLoading }] = useResource({
355
- fetchResource: () => getAdmin(adminId.value),
338
+ const { t: e } = q(), t = Le(), r = he(), m = re(), d = R(() => t.params.adminId), s = R(() => d.value === "create"), [c, { data: n, loading: p }] = P({
339
+ fetchResource: () => qe(d.value),
356
340
  initialValue: null,
357
341
  resourceName: "Admin"
358
- });
359
- const [fetchRoleList, { data: roleList, loading: isRoleListLoading }] = useResource({
360
- fetchResource: getRoleList,
342
+ }), [f, { data: v, loading: a }] = P({
343
+ fetchResource: ye,
361
344
  initialValue: [],
362
345
  resourceName: "Role List"
363
- });
364
- const [fetchFieldList, { data: fieldList, loading: isFieldListLoading }] = useResource({
365
- fetchResource: getFieldList,
346
+ }), [o, { data: u, loading: A }] = P({
347
+ fetchResource: Oe,
366
348
  initialValue: [],
367
349
  resourceName: "Field List"
368
350
  });
369
- onMounted(() => {
370
- fetchRoleList();
371
- fetchFieldList();
372
- updateTemplateValues();
373
- if (isCreation.value)
374
- return;
375
- fetchAdmin();
351
+ H(() => {
352
+ f(), o(), x(), !s.value && c();
376
353
  });
377
- const roleOptionList = computed(() => convertRoleListToOptions(roleList.value));
378
- const values = ref(convertAdminToFormValues(admin.value, roleOptionList.value));
379
- const errors = ref({});
380
- const isSubmitting = ref(false);
381
- watch([admin, roleOptionList], () => {
382
- values.value = convertAdminToFormValues(admin.value, roleOptionList.value);
354
+ const y = R(
355
+ () => Xe(v.value)
356
+ ), T = D(
357
+ X(n.value, y.value)
358
+ ), O = D({}), B = D(!1);
359
+ Z([n, y], () => {
360
+ T.value = X(
361
+ n.value,
362
+ y.value
363
+ );
383
364
  });
384
- function submitForm(event) {
385
- if (admin.value && admin.value.isSelf)
386
- return;
387
- const creationBody = convertFormValuesToAdminCreationPayload(values.value, templateValues.value);
388
- const updateBody = convertFormValuesToAdminUpdatePayload(values.value, templateValues.value);
389
- const requestPromise = isCreation.value ? createAdmin(creationBody) : updateAdmin(adminId.value, updateBody);
390
- requestPromise.then(({ data }) => {
391
- errors.value = {};
392
- if (event.type === "create") {
393
- router.push(getAdminFormUrl({ adminId: data.id }));
394
- }
395
- if (event.type === "create_exit" || event.type === "save_exit") {
396
- navigateBack(router, getAdminListUrl());
397
- }
398
- if (event.type === "create_create-another") {
399
- values.value = convertAdminToFormValues(null, roleOptionList.value);
400
- }
401
- toast.show({
365
+ function M(U) {
366
+ if (n.value && n.value.isSelf) return;
367
+ const _ = We(
368
+ T.value,
369
+ N.value
370
+ ), W = Se(
371
+ T.value,
372
+ N.value
373
+ );
374
+ (s.value ? ze(_) : He(d.value, W)).then(({ data: E }) => {
375
+ O.value = {}, U.type === "create" && r.push(Ae({ adminId: E.id })), (U.type === "create_exit" || U.type === "save_exit") && se(r, oe()), U.type === "create_create-another" && (T.value = X(null, y.value)), m.show({
402
376
  variant: "success",
403
- title: t("administrators:success"),
404
- body: isCreation.value ? t("administrators:adminSuccessfullyCreated") : t("administrators:adminSuccessfullyUpdated")
377
+ title: e("administrators:success"),
378
+ body: s.value ? e("administrators:adminSuccessfullyCreated") : e("administrators:adminSuccessfullyUpdated")
405
379
  });
406
- }).catch((error) => {
407
- console.error(error);
408
- errors.value = convertRequestErrorToMap(error);
409
- toast.show({
380
+ }).catch((E) => {
381
+ console.error(E), O.value = ie(E), m.show({
410
382
  variant: "danger",
411
- title: t("administrators:error"),
412
- body: isCreation.value ? t("administrators:adminCreationError") : t("administrators:adminUpdateError")
383
+ title: e("administrators:error"),
384
+ body: s.value ? e("administrators:adminCreationError") : e("administrators:adminUpdateError")
413
385
  });
414
386
  }).finally(() => {
415
- isSubmitting.value = false;
387
+ B.value = !1;
416
388
  });
417
389
  }
418
- const pageTitle = computed(() => {
419
- return isCreation.value ? t("administrators:createAdmin") : `${t("administrators:updateAdmin")} "${values.value.name}"`;
420
- });
421
- const isContentLoading = computed(() => isAdminLoading.value || isRoleListLoading.value || isFieldListLoading.value);
422
- const shouldDisplayParamsTab = computed(() => fieldList.value.length > 0);
423
- const tabList = computed(() => {
424
- return [
425
- { id: "general", label: t("administrators:tabs.general") },
426
- shouldDisplayParamsTab.value ? { id: "params", label: t("administrators:tabs.params") } : null
427
- ].filter(notEmpty);
428
- });
429
- const selectedTabId = ref(tabList.value[0].id);
430
- const templateValues = ref([]);
431
- function updateTemplateValues() {
432
- var _a, _b;
433
- const incomingFieldList = (_b = (_a = admin.value) == null ? void 0 : _a.params) != null ? _b : [];
434
- templateValues.value = fieldList.value.map((fieldConfig, index) => {
435
- var _a2;
436
- return universalFieldUtils.createFormField(fieldConfig, (_a2 = incomingFieldList[index]) == null ? void 0 : _a2.value);
437
- });
390
+ const K = R(() => s.value ? e("administrators:createAdmin") : `${e("administrators:updateAdmin")} "${T.value.name}"`), Q = R(
391
+ () => p.value || a.value || A.value
392
+ ), G = R(
393
+ () => u.value.length > 0
394
+ ), $ = R(() => [
395
+ { id: "general", label: e("administrators:tabs.general") },
396
+ G.value ? { id: "params", label: e("administrators:tabs.params") } : null
397
+ ].filter($e)), De = D($.value[0].id), N = D([]);
398
+ function x() {
399
+ var _;
400
+ const U = ((_ = n.value) == null ? void 0 : _.params) ?? [];
401
+ N.value = u.value.map(
402
+ (W, ee) => {
403
+ var E;
404
+ return be.createFormField(
405
+ W,
406
+ (E = U[ee]) == null ? void 0 : E.value
407
+ );
408
+ }
409
+ );
438
410
  }
439
- watch([admin, fieldList], () => {
440
- updateTemplateValues();
441
- });
442
- return {
443
- t,
444
- backButtonUrl: getAdminListUrl(),
445
- values,
446
- errors,
447
- isSubmitting,
448
- submitForm,
449
- isContentLoading,
450
- admin,
451
- pageTitle,
452
- isCreation,
453
- roleOptionList,
454
- tabList,
455
- selectedTabId,
456
- templateValues
411
+ return Z([n, u], () => {
412
+ x();
413
+ }), {
414
+ t: e,
415
+ backButtonUrl: oe(),
416
+ values: T,
417
+ errors: O,
418
+ isSubmitting: B,
419
+ submitForm: M,
420
+ isContentLoading: Q,
421
+ admin: n,
422
+ pageTitle: K,
423
+ isCreation: s,
424
+ roleOptionList: y,
425
+ tabList: $,
426
+ selectedTabId: De,
427
+ templateValues: N
457
428
  };
458
429
  }
459
430
  });
460
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
461
- const _component_TabList = resolveComponent("TabList");
462
- const _component_FormField = resolveComponent("FormField");
463
- const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
464
- const _component_DynamicField = resolveComponent("DynamicField");
465
- const _component_FormFooter = resolveComponent("FormFooter");
466
- const _component_Page = resolveComponent("Page");
467
- return openBlock(), createBlock(_component_Page, {
468
- title: _ctx.pageTitle,
469
- "is-content-loading": _ctx.isContentLoading
431
+ function Ze(e, t, r, m, d, s) {
432
+ const c = l("TabList"), n = l("FormField"), p = l("FormFieldMultiSelect"), f = l("DynamicField"), v = l("FormFooter"), a = l("Page");
433
+ return i(), S(a, {
434
+ title: e.pageTitle,
435
+ "is-content-loading": e.isContentLoading
470
436
  }, {
471
- footer: withCtx(() => [
472
- createVNode(_component_FormFooter, {
473
- "back-href": _ctx.backButtonUrl,
474
- "is-submitting": _ctx.isSubmitting,
475
- "is-creation": _ctx.isCreation,
476
- "can-create-another": _ctx.isCreation,
477
- onSubmit: _ctx.submitForm
437
+ footer: b(() => [
438
+ g(v, {
439
+ "back-href": e.backButtonUrl,
440
+ "is-submitting": e.isSubmitting,
441
+ "is-creation": e.isCreation,
442
+ "can-create-another": e.isCreation,
443
+ onSubmit: e.submitForm
478
444
  }, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
479
445
  ]),
480
- default: withCtx(() => [
481
- createElementVNode("form", {
446
+ default: b(() => [
447
+ C("form", {
482
448
  novalidate: "",
483
- onSubmit: _cache[5] || (_cache[5] = withModifiers(() => {
449
+ onSubmit: t[5] || (t[5] = le(() => {
484
450
  }, ["prevent"]))
485
451
  }, [
486
- createVNode(_component_TabList, {
487
- "tab-id": _ctx.selectedTabId,
488
- "onUpdate:tab-id": _cache[0] || (_cache[0] = ($event) => _ctx.selectedTabId = $event),
489
- "tab-list": _ctx.tabList
452
+ g(c, {
453
+ "tab-id": e.selectedTabId,
454
+ "onUpdate:tab-id": t[0] || (t[0] = (o) => e.selectedTabId = o),
455
+ "tab-list": e.tabList
490
456
  }, null, 8, ["tab-id", "tab-list"]),
491
- _ctx.selectedTabId === "general" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
492
- createVNode(_component_FormField, {
493
- value: _ctx.values.name,
494
- "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.values.name = $event),
457
+ e.selectedTabId === "general" ? (i(), F(k, { key: 0 }, [
458
+ g(n, {
459
+ value: e.values.name,
460
+ "onUpdate:value": t[1] || (t[1] = (o) => e.values.name = o),
495
461
  name: "name",
496
- error: _ctx.errors.name,
497
- label: _ctx.$i18n.t("administrators:name")
462
+ error: e.errors.name,
463
+ label: e.$i18n.t("administrators:name")
498
464
  }, null, 8, ["value", "error", "label"]),
499
- createVNode(_component_FormField, {
500
- value: _ctx.values.email,
501
- "onUpdate:value": _cache[2] || (_cache[2] = ($event) => _ctx.values.email = $event),
465
+ g(n, {
466
+ value: e.values.email,
467
+ "onUpdate:value": t[2] || (t[2] = (o) => e.values.email = o),
502
468
  name: "email",
503
- error: _ctx.errors.email,
504
- label: _ctx.$i18n.t("administrators:email")
469
+ error: e.errors.email,
470
+ label: e.$i18n.t("administrators:email")
505
471
  }, null, 8, ["value", "error", "label"]),
506
- createVNode(_component_FormFieldMultiSelect, {
507
- "selected-options": _ctx.values.roles,
508
- "onUpdate:selected-options": _cache[3] || (_cache[3] = ($event) => _ctx.values.roles = $event),
472
+ g(p, {
473
+ "selected-options": e.values.roles,
474
+ "onUpdate:selected-options": t[3] || (t[3] = (o) => e.values.roles = o),
509
475
  name: "roles",
510
- label: _ctx.$i18n.t("administrators:roles"),
511
- options: _ctx.roleOptionList,
512
- error: _ctx.errors.roles
476
+ label: e.$i18n.t("administrators:roles"),
477
+ options: e.roleOptionList,
478
+ error: e.errors.roles
513
479
  }, null, 8, ["selected-options", "label", "options", "error"]),
514
- createVNode(_component_FormField, {
515
- value: _ctx.values.password,
516
- "onUpdate:value": _cache[4] || (_cache[4] = ($event) => _ctx.values.password = $event),
480
+ g(n, {
481
+ value: e.values.password,
482
+ "onUpdate:value": t[4] || (t[4] = (o) => e.values.password = o),
517
483
  name: "password",
518
- error: _ctx.errors.password,
519
- label: _ctx.isCreation ? _ctx.$i18n.t("administrators:password") : _ctx.$i18n.t("administrators:newPassword")
484
+ error: e.errors.password,
485
+ label: e.isCreation ? e.$i18n.t("administrators:password") : e.$i18n.t("administrators:newPassword")
520
486
  }, null, 8, ["value", "error", "label"])
521
- ], 64)) : createCommentVNode("", true),
522
- _ctx.selectedTabId === "params" ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.templateValues, (field) => {
523
- return openBlock(), createBlock(_component_DynamicField, {
524
- key: field.config.name,
525
- field
526
- }, null, 8, ["field"]);
527
- }), 128)) : createCommentVNode("", true)
487
+ ], 64)) : I("", !0),
488
+ e.selectedTabId === "params" ? (i(!0), F(k, { key: 1 }, V(e.templateValues, (o) => (i(), S(f, {
489
+ key: o.config.name,
490
+ field: o
491
+ }, null, 8, ["field"]))), 128)) : I("", !0)
528
492
  ], 32)
529
493
  ]),
530
494
  _: 1
531
495
  }, 8, ["title", "is-content-loading"]);
532
496
  }
533
- var AdminForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
534
- var RoleList_vue_vue_type_style_index_0_lang = "";
535
- const _sfc_main$1 = defineComponent({
497
+ const Ge = /* @__PURE__ */ J(Ye, [["render", Ze]]), xe = z({
536
498
  name: "RoleList",
537
499
  components: {
538
- Page,
539
- DeleteIcon,
540
- EditIcon,
541
- DataTable,
542
- BaseButton
500
+ Page: j,
501
+ DeleteIcon: ue,
502
+ EditIcon: de,
503
+ DataTable: ce,
504
+ BaseButton: me
543
505
  },
544
506
  setup() {
545
- const { t } = useI18n();
546
- const {
547
- fetchEntityList: fetchRoleList,
548
- isLoading: isRoleListLoading,
549
- rowData: roleList,
550
- errorMessage: error
551
- } = useDataTable({
552
- fetchEntityList: (params) => getRoleList(),
507
+ const { t: e } = q(), {
508
+ fetchEntityList: t,
509
+ isLoading: r,
510
+ rowData: m,
511
+ errorMessage: d
512
+ } = pe({
513
+ fetchEntityList: (a) => ye(),
553
514
  initialValue: [],
554
515
  resourceName: "Role list",
555
516
  pageSize: 100
556
517
  });
557
- onMounted(() => {
558
- fetchRoleList();
518
+ H(() => {
519
+ t();
559
520
  });
560
521
  const {
561
- handleResourceDelete: handleRoleDelete,
562
- isDeleting
563
- } = useResourceDelete({
564
- deleteResource: deleteRole,
522
+ handleResourceDelete: s,
523
+ isDeleting: c
524
+ } = ne({
525
+ deleteResource: Ne,
565
526
  resourceName: "Role",
566
- onSuccess: fetchRoleList
527
+ onSuccess: t
567
528
  });
568
- function isBusy(roleId) {
569
- return isDeleting(roleId) || isRoleListLoading.value;
529
+ function n(a) {
530
+ return c(a) || r.value;
570
531
  }
571
- function getScopeGroupList(scopes) {
572
- const map = /* @__PURE__ */ new Map();
573
- scopes.forEach((scope) => {
574
- var _a;
575
- const key = scope.module;
576
- const value = (_a = map.get(key)) != null ? _a : [];
577
- value.push(scope);
578
- map.set(key, value);
579
- });
580
- return Array.from(map.entries()).map(([key, value]) => ({
581
- module: key,
582
- scopes: value
532
+ function p(a) {
533
+ const o = /* @__PURE__ */ new Map();
534
+ return a.forEach((u) => {
535
+ const A = u.module, y = o.get(A) ?? [];
536
+ y.push(u), o.set(A, y);
537
+ }), Array.from(o.entries()).map(([u, A]) => ({
538
+ module: u,
539
+ scopes: A
583
540
  }));
584
541
  }
585
- function getRestScopesText(restPrivilegesCount) {
586
- if (restPrivilegesCount === 1) {
587
- return t("administrators:andMorePrivilege", { count: 1 });
588
- }
589
- if (restPrivilegesCount > 1) {
590
- return t("administrators:andMorePrivilege", {
591
- count: restPrivilegesCount
592
- });
593
- }
594
- return "";
542
+ function f(a) {
543
+ return a === 1 ? e("administrators:andMorePrivilege", { count: 1 }) : a > 1 ? e("administrators:andMorePrivilege", {
544
+ count: a
545
+ }) : "";
595
546
  }
596
- const columnDefs = [
597
- {
598
- id: 1,
599
- name: t("administrators:role"),
600
- field: "name"
601
- },
602
- {
603
- id: 2,
604
- name: t("administrators:privileges"),
605
- field: "scope"
606
- },
607
- {
608
- id: 3,
609
- name: t("administrators:actions"),
610
- field: "actions",
611
- style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
612
- headStyle: { width: "180px", textAlign: "center" }
613
- }
614
- ];
615
547
  return {
616
- columnDefs,
617
- rowData: roleList,
618
- isRowDataLoading: isRoleListLoading,
619
- errorMessage: error,
620
- isBusy,
621
- handleRoleDelete,
622
- getRoleFormUrl,
623
- getScopeGroupList,
624
- getRestScopesText,
548
+ columnDefs: [
549
+ {
550
+ id: 1,
551
+ name: e("administrators:role"),
552
+ field: "name"
553
+ },
554
+ {
555
+ id: 2,
556
+ name: e("administrators:privileges"),
557
+ field: "scope"
558
+ },
559
+ {
560
+ id: 3,
561
+ name: e("administrators:actions"),
562
+ field: "actions",
563
+ style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
564
+ headStyle: { width: "180px", textAlign: "center" }
565
+ }
566
+ ],
567
+ rowData: m,
568
+ isRowDataLoading: r,
569
+ errorMessage: d,
570
+ isBusy: n,
571
+ handleRoleDelete: s,
572
+ getRoleFormUrl: Fe,
573
+ getScopeGroupList: p,
574
+ getRestScopesText: f,
625
575
  scopesPerModuleCount: 3
626
576
  };
627
577
  }
628
- });
629
- const _hoisted_1 = {
578
+ }), et = {
630
579
  key: 0,
631
580
  class: "no-scopes"
632
- };
633
- const _hoisted_2 = { key: 1 };
634
- const _hoisted_3 = { class: "module-name" };
635
- const _hoisted_4 = { class: "scope-list" };
636
- const _hoisted_5 = {
581
+ }, tt = { key: 1 }, at = { class: "module-name" }, ot = { class: "scope-list" }, nt = {
637
582
  key: 0,
638
583
  class: "rest-scopes-text"
639
584
  };
640
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
641
- const _component_EditIcon = resolveComponent("EditIcon");
642
- const _component_BaseButton = resolveComponent("BaseButton");
643
- const _component_DeleteIcon = resolveComponent("DeleteIcon");
644
- const _component_DataTable = resolveComponent("DataTable");
645
- const _component_Page = resolveComponent("Page");
646
- return openBlock(), createBlock(_component_Page, {
647
- title: _ctx.$i18n.t("administrators:listOfRoles"),
585
+ function rt(e, t, r, m, d, s) {
586
+ const c = l("EditIcon"), n = l("BaseButton"), p = l("DeleteIcon"), f = l("DataTable"), v = l("Page");
587
+ return i(), S(v, {
588
+ title: e.$i18n.t("administrators:listOfRoles"),
648
589
  "header-buttons": [
649
590
  {
650
- text: _ctx.$i18n.t("administrators:addRole"),
651
- href: _ctx.getRoleFormUrl({ roleId: "create" })
591
+ text: e.$i18n.t("administrators:addRole"),
592
+ href: e.getRoleFormUrl({ roleId: "create" })
652
593
  }
653
594
  ]
654
595
  }, {
655
- default: withCtx(() => [
656
- createVNode(_component_DataTable, {
657
- "column-defs": _ctx.columnDefs,
658
- "row-data": _ctx.rowData,
659
- loading: _ctx.isRowDataLoading,
660
- "error-message": _ctx.errorMessage
596
+ default: b(() => [
597
+ g(f, {
598
+ "column-defs": e.columnDefs,
599
+ "row-data": e.rowData,
600
+ loading: e.isRowDataLoading,
601
+ "error-message": e.errorMessage
661
602
  }, {
662
- "cell(scope)": withCtx(({ row }) => [
663
- row.scopes.length === 0 ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(_ctx.$i18n.t("administrators:noPrivileges")), 1)) : createCommentVNode("", true),
664
- 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) => {
665
- return openBlock(), createElementBlock("div", {
666
- key: scopeGroup.module,
667
- class: "scope-group"
668
- }, [
669
- createElementVNode("span", _hoisted_3, toDisplayString(scopeGroup.module), 1),
670
- createElementVNode("ul", _hoisted_4, [
671
- (openBlock(true), createElementBlock(Fragment, null, renderList(scopeGroup.scopes.slice(0, _ctx.scopesPerModuleCount), (scope) => {
672
- return openBlock(), createElementBlock("li", {
673
- key: scope.value
674
- }, [
675
- createElementVNode("span", null, "\u2014 " + toDisplayString(scope.label), 1)
676
- ]);
677
- }), 128))
678
- ]),
679
- scopeGroup.scopes.length > _ctx.scopesPerModuleCount ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(_ctx.getRestScopesText(scopeGroup.scopes.length - _ctx.scopesPerModuleCount)), 1)) : createCommentVNode("", true)
680
- ]);
681
- }), 128))
603
+ "cell(scope)": b(({ row: a }) => [
604
+ a.scopes.length === 0 ? (i(), F("span", et, w(e.$i18n.t("administrators:noPrivileges")), 1)) : I("", !0),
605
+ a.isSuperAdmin ? (i(), F("span", tt, w(e.$i18n.t("administrators:all")), 1)) : (i(!0), F(k, { key: 2 }, V(e.getScopeGroupList(a.scopes), (o) => (i(), F("div", {
606
+ key: o.module,
607
+ class: "scope-group"
608
+ }, [
609
+ C("span", at, w(o.module), 1),
610
+ C("ul", ot, [
611
+ (i(!0), F(k, null, V(o.scopes.slice(
612
+ 0,
613
+ e.scopesPerModuleCount
614
+ ), (u) => (i(), F("li", {
615
+ key: u.value
616
+ }, [
617
+ C("span", null, "— " + w(u.label), 1)
618
+ ]))), 128))
619
+ ]),
620
+ o.scopes.length > e.scopesPerModuleCount ? (i(), F("span", nt, w(e.getRestScopesText(
621
+ o.scopes.length - e.scopesPerModuleCount
622
+ )), 1)) : I("", !0)
623
+ ]))), 128))
682
624
  ]),
683
- "cell(actions)": withCtx(({ row }) => [
684
- createVNode(_component_BaseButton, {
625
+ "cell(actions)": b(({ row: a }) => [
626
+ g(n, {
685
627
  variant: "icon",
686
- title: _ctx.$i18n.t("administrators:edit"),
687
- disabled: _ctx.isBusy(row.id),
688
- href: _ctx.getRoleFormUrl({ roleId: row.id })
628
+ title: e.$i18n.t("administrators:edit"),
629
+ disabled: e.isBusy(a.id),
630
+ href: e.getRoleFormUrl({ roleId: a.id })
689
631
  }, {
690
- default: withCtx(() => [
691
- createVNode(_component_EditIcon)
632
+ default: b(() => [
633
+ g(c)
692
634
  ]),
693
635
  _: 2
694
636
  }, 1032, ["title", "disabled", "href"]),
695
- !row.isSuperAdmin ? (openBlock(), createBlock(_component_BaseButton, {
637
+ a.isSuperAdmin ? I("", !0) : (i(), S(n, {
696
638
  key: 0,
697
639
  variant: "icon",
698
- title: _ctx.$i18n.t("administrators:delete"),
699
- disabled: _ctx.isBusy(row.id),
700
- onClick: ($event) => _ctx.handleRoleDelete(row.id)
640
+ title: e.$i18n.t("administrators:delete"),
641
+ disabled: e.isBusy(a.id),
642
+ onClick: (o) => e.handleRoleDelete(a.id)
701
643
  }, {
702
- default: withCtx(() => [
703
- createVNode(_component_DeleteIcon)
644
+ default: b(() => [
645
+ g(p)
704
646
  ]),
705
647
  _: 2
706
- }, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
648
+ }, 1032, ["title", "disabled", "onClick"]))
707
649
  ]),
708
650
  _: 1
709
651
  }, 8, ["column-defs", "row-data", "loading", "error-message"])
@@ -711,230 +653,214 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
711
653
  _: 1
712
654
  }, 8, ["title", "header-buttons"]);
713
655
  }
714
- var RoleList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
715
- function convertRoleToFormValues(role) {
716
- if (!role) {
717
- return {
718
- name: "",
719
- scopes: [],
720
- isSuperAdmin: false
721
- };
722
- }
723
- return {
724
- name: role.name,
725
- scopes: role.scopes,
726
- isSuperAdmin: role.isSuperAdmin
656
+ const st = /* @__PURE__ */ J(xe, [["render", rt]]);
657
+ function Y(e) {
658
+ return e ? {
659
+ name: e.name,
660
+ scopes: e.scopes,
661
+ isSuperAdmin: e.isSuperAdmin
662
+ } : {
663
+ name: "",
664
+ scopes: [],
665
+ isSuperAdmin: !1
727
666
  };
728
667
  }
729
- function convertFormValuesToRoleCreationPayload(values) {
668
+ function Te(e) {
730
669
  return {
731
- name: values.name,
732
- scopes: values.scopes.map((scope) => scope.value)
670
+ name: e.name,
671
+ scopes: e.scopes.map((t) => t.value)
733
672
  };
734
673
  }
735
- function convertFormValuesToRoleUpdatePayload(values) {
674
+ function it(e) {
736
675
  return {
737
- ...convertFormValuesToRoleCreationPayload(values)
676
+ ...Te(e)
738
677
  };
739
678
  }
740
- function convertScopeDataToOptions(scopeData) {
741
- if (!scopeData)
742
- return [];
743
- return scopeData.groups.map((group) => group.scopes.map((scope) => ({
744
- value: scope.value,
745
- label: `${group.name}: ${scope.label}`
746
- }))).flat();
679
+ function lt(e) {
680
+ return e ? e.groups.map(
681
+ (t) => t.scopes.map((r) => ({
682
+ value: r.value,
683
+ label: `${t.name}: ${r.label}`
684
+ }))
685
+ ).flat() : [];
747
686
  }
748
- var RoleForm_vue_vue_type_style_index_0_scoped_true_lang = "";
749
- const _sfc_main = defineComponent({
687
+ const dt = z({
750
688
  name: "RoleForm",
751
- components: { Page, FormFooter, FormField, FormFieldMultiSelect },
689
+ components: { Page: j, FormFooter: ve, FormField: ge, FormFieldMultiSelect: fe },
752
690
  setup() {
753
- const { t } = useI18n();
754
- const route = useRoute();
755
- const router = useRouter();
756
- const toast = useToast();
757
- const roleId = computed(() => route.params.roleId);
758
- const isCreation = computed(() => roleId.value === "create");
759
- const [fetchRole, { data: role, loading: isRoleLoading }] = useResource({
760
- fetchResource: () => getRole(roleId.value),
691
+ const { t: e } = q(), t = Le(), r = he(), m = re(), d = R(() => t.params.roleId), s = R(() => d.value === "create"), [c, { data: n, loading: p }] = P({
692
+ fetchResource: () => Pe(d.value),
761
693
  initialValue: null,
762
694
  resourceName: "Role"
763
- });
764
- const [
765
- fetchScopeData,
766
- { data: scopeData, loading: isScopeDataLoading }
767
- ] = useResource({
768
- fetchResource: getScopes,
695
+ }), [
696
+ f,
697
+ { data: v, loading: a }
698
+ ] = P({
699
+ fetchResource: _e,
769
700
  initialValue: null,
770
701
  resourceName: "Scope list"
771
702
  });
772
- onMounted(() => {
773
- fetchScopeData();
774
- if (isCreation.value)
775
- return;
776
- fetchRole();
703
+ H(() => {
704
+ f(), !s.value && c();
777
705
  });
778
- const scopeOptionList = computed(() => convertScopeDataToOptions(scopeData.value));
779
- const values = ref(convertRoleToFormValues(role.value));
780
- const errors = ref({});
781
- const isSubmitting = ref(false);
782
- watch(role, () => {
783
- values.value = convertRoleToFormValues(role.value);
706
+ const o = R(
707
+ () => lt(v.value)
708
+ ), u = D(Y(n.value)), A = D({}), y = D(!1);
709
+ Z(n, () => {
710
+ u.value = Y(n.value);
784
711
  });
785
- function submitForm(event) {
786
- const creationBody = convertFormValuesToRoleCreationPayload(values.value);
787
- const updateBody = convertFormValuesToRoleUpdatePayload(values.value);
788
- const requestPromise = isCreation.value ? createRole(creationBody) : updateRole(roleId.value, updateBody);
789
- requestPromise.then(({ data }) => {
790
- errors.value = {};
791
- if (event.type === "create") {
792
- router.push(getRoleFormUrl({ roleId: data.id }));
793
- }
794
- if (event.type === "create_exit" || event.type === "save_exit") {
795
- navigateBack(router, getRoleListUrl());
796
- }
797
- if (event.type === "create_create-another") {
798
- values.value = convertRoleToFormValues(null);
799
- }
800
- toast.show({
712
+ function T(M) {
713
+ const K = Te(u.value), Q = it(u.value);
714
+ (s.value ? ke(K) : Be(d.value, Q)).then(({ data: $ }) => {
715
+ A.value = {}, M.type === "create" && r.push(Fe({ roleId: $.id })), (M.type === "create_exit" || M.type === "save_exit") && se(r, ae()), M.type === "create_create-another" && (u.value = Y(null)), m.show({
801
716
  variant: "success",
802
- title: t("administrators:success"),
803
- body: isCreation.value ? t("administrators:roleSuccessfullyCreated") : t("administrators:roleSuccessfullyUpdate")
717
+ title: e("administrators:success"),
718
+ body: s.value ? e("administrators:roleSuccessfullyCreated") : e("administrators:roleSuccessfullyUpdate")
804
719
  });
805
- }).catch((error) => {
806
- console.error(error);
807
- errors.value = convertRequestErrorToMap(error);
808
- toast.show({
720
+ }).catch(($) => {
721
+ console.error($), A.value = ie($), m.show({
809
722
  variant: "danger",
810
- title: t("administrators:error"),
811
- body: isCreation.value ? t("administrators:roleCreationError") : t("administrators:roleUpdateError")
723
+ title: e("administrators:error"),
724
+ body: s.value ? e("administrators:roleCreationError") : e("administrators:roleUpdateError")
812
725
  });
813
726
  }).finally(() => {
814
- isSubmitting.value = false;
727
+ y.value = !1;
815
728
  });
816
729
  }
817
- const pageTitle = computed(() => {
818
- return isCreation.value ? t("administrators:createRole") : `${t("administrators:updateRole")} "${values.value.name}"`;
819
- });
820
- const isContentLoading = computed(() => isRoleLoading.value || isScopeDataLoading.value);
730
+ const O = R(() => s.value ? e("administrators:createRole") : `${e("administrators:updateRole")} "${u.value.name}"`), B = R(
731
+ () => p.value || a.value
732
+ );
821
733
  return {
822
- backButtonUrl: getRoleListUrl(),
823
- values,
824
- errors,
825
- isSubmitting,
826
- submitForm,
827
- isContentLoading,
828
- role,
829
- pageTitle,
830
- isCreation,
831
- scopeOptionList
734
+ backButtonUrl: ae(),
735
+ values: u,
736
+ errors: A,
737
+ isSubmitting: y,
738
+ submitForm: T,
739
+ isContentLoading: B,
740
+ role: n,
741
+ pageTitle: O,
742
+ isCreation: s,
743
+ scopeOptionList: o
832
744
  };
833
745
  }
834
746
  });
835
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
836
- const _component_FormField = resolveComponent("FormField");
837
- const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
838
- const _component_FormFooter = resolveComponent("FormFooter");
839
- const _component_Page = resolveComponent("Page");
840
- return openBlock(), createBlock(_component_Page, {
841
- title: _ctx.pageTitle,
842
- "is-content-loading": _ctx.isContentLoading
747
+ function ut(e, t, r, m, d, s) {
748
+ const c = l("FormField"), n = l("FormFieldMultiSelect"), p = l("FormFooter"), f = l("Page");
749
+ return i(), S(f, {
750
+ title: e.pageTitle,
751
+ "is-content-loading": e.isContentLoading
843
752
  }, {
844
- footer: withCtx(() => [
845
- createVNode(_component_FormFooter, {
846
- "back-href": _ctx.backButtonUrl,
847
- onSubmit: _ctx.submitForm,
848
- "is-submitting": _ctx.isSubmitting,
849
- "is-creation": _ctx.isCreation,
850
- "can-create-another": _ctx.isCreation
851
- }, null, 8, ["back-href", "onSubmit", "is-submitting", "is-creation", "can-create-another"])
753
+ footer: b(() => [
754
+ g(p, {
755
+ "back-href": e.backButtonUrl,
756
+ "is-submitting": e.isSubmitting,
757
+ "is-creation": e.isCreation,
758
+ "can-create-another": e.isCreation,
759
+ onSubmit: e.submitForm
760
+ }, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
852
761
  ]),
853
- default: withCtx(() => [
854
- createElementVNode("form", {
762
+ default: b(() => [
763
+ C("form", {
855
764
  novalidate: "",
856
- onSubmit: _cache[2] || (_cache[2] = withModifiers(() => {
765
+ onSubmit: t[2] || (t[2] = le(() => {
857
766
  }, ["prevent"]))
858
767
  }, [
859
- createVNode(_component_FormField, {
860
- value: _ctx.values.name,
861
- "onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.values.name = $event),
768
+ g(c, {
769
+ value: e.values.name,
770
+ "onUpdate:value": t[0] || (t[0] = (v) => e.values.name = v),
862
771
  name: "name",
863
- error: _ctx.errors.name,
864
- label: _ctx.$i18n.t("administrators:name")
772
+ error: e.errors.name,
773
+ label: e.$i18n.t("administrators:name")
865
774
  }, null, 8, ["value", "error", "label"]),
866
- !_ctx.values.isSuperAdmin ? (openBlock(), createBlock(_component_FormFieldMultiSelect, {
775
+ e.values.isSuperAdmin ? I("", !0) : (i(), S(n, {
867
776
  key: 0,
868
- "selected-options": _ctx.values.scopes,
869
- "onUpdate:selected-options": _cache[1] || (_cache[1] = ($event) => _ctx.values.scopes = $event),
777
+ "selected-options": e.values.scopes,
778
+ "onUpdate:selected-options": t[1] || (t[1] = (v) => e.values.scopes = v),
870
779
  name: "scopes",
871
- label: _ctx.$i18n.t("administrators:privileges"),
872
- options: _ctx.scopeOptionList,
873
- error: _ctx.errors.scopes
874
- }, null, 8, ["selected-options", "label", "options", "error"])) : createCommentVNode("", true)
780
+ label: e.$i18n.t("administrators:privileges"),
781
+ options: e.scopeOptionList,
782
+ error: e.errors.scopes
783
+ }, null, 8, ["selected-options", "label", "options", "error"]))
875
784
  ], 32)
876
785
  ]),
877
786
  _: 1
878
787
  }, 8, ["title", "is-content-loading"]);
879
788
  }
880
- var RoleForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-501ddc14"]]);
881
- const ADMIN_LIST_ROUTE = {
882
- path: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
883
- component: AdminList,
789
+ const mt = /* @__PURE__ */ J(dt, [["render", ut], ["__scopeId", "data-v-2e498e82"]]), Lt = {
790
+ path: L.ADMIN_LIST,
791
+ component: Qe,
884
792
  name: "AdminList",
885
793
  meta: {
886
- getBreadcrumbs: (route, i18n2) => [
887
- { url: "/", text: i18n2.t("administrators:home") },
794
+ getBreadcrumbs: (e, t) => [
795
+ { url: "/", text: t.t("administrators:home") },
888
796
  {
889
- url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
890
- text: i18n2.t("administrators:adminList")
797
+ url: L.ADMIN_LIST,
798
+ text: t.t("administrators:adminList")
891
799
  }
892
800
  ]
893
801
  }
894
- };
895
- const ADMIN_FORM_ROUTE = {
896
- path: ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM,
897
- component: AdminForm,
802
+ }, ht = {
803
+ path: L.ADMIN_FORM,
804
+ component: Ge,
898
805
  name: "AdminForm",
899
806
  meta: {
900
- getBreadcrumbs: (route, i18n2) => [
901
- { url: "/", text: i18n2.t("administrators:home") },
807
+ getBreadcrumbs: (e, t) => [
808
+ { url: "/", text: t.t("administrators:home") },
902
809
  {
903
- url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
904
- text: i18n2.t("administrators:adminList")
810
+ url: L.ADMIN_LIST,
811
+ text: t.t("administrators:adminList")
905
812
  },
906
- { url: route.path, text: i18n2.t("administrators:adminForm") }
813
+ { url: e.path, text: t.t("administrators:adminForm") }
907
814
  ]
908
815
  }
909
- };
910
- const ROLE_LIST_ROUTE = {
911
- path: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
912
- component: RoleList,
816
+ }, yt = {
817
+ path: L.ROLE_LIST,
818
+ component: st,
913
819
  name: "RoleList",
914
820
  meta: {
915
- getBreadcrumbs: (route, i18n2) => [
916
- { url: "/", text: i18n2.t("administrators:home") },
821
+ getBreadcrumbs: (e, t) => [
822
+ { url: "/", text: t.t("administrators:home") },
917
823
  {
918
- url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
919
- text: i18n2.t("administrators:roleList")
824
+ url: L.ROLE_LIST,
825
+ text: t.t("administrators:roleList")
920
826
  }
921
827
  ]
922
828
  }
923
- };
924
- const ROLE_FORM_ROUTE = {
925
- path: ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM,
926
- component: RoleForm,
829
+ }, Ft = {
830
+ path: L.ROLE_FORM,
831
+ component: mt,
927
832
  name: "RoleForm",
928
833
  meta: {
929
- getBreadcrumbs: (route, i18n2) => [
930
- { url: "/", text: i18n2.t("administrators:home") },
834
+ getBreadcrumbs: (e, t) => [
835
+ { url: "/", text: t.t("administrators:home") },
931
836
  {
932
- url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
933
- text: i18n2.t("administrators:roleList")
837
+ url: L.ROLE_LIST,
838
+ text: t.t("administrators:roleList")
934
839
  },
935
- { url: route.path, text: i18n2.t("administrators:roleForm") }
840
+ { url: e.path, text: t.t("administrators:roleForm") }
936
841
  ]
937
842
  }
938
843
  };
939
- applyTranslations();
940
- export { ADMIN_FORM_ROUTE, ADMIN_LIST_ROUTE, ROLE_FORM_ROUTE, ROLE_LIST_ROUTE, createAdmin, createRole, deleteAdmin, deleteRole, getAdmin, getAdminFormUrl, getAdminList, getAdminListUrl, getFieldList, getRole, getRoleFormUrl, getRoleList, getRoleListUrl, getScopes, updateAdmin, updateRole };
844
+ Ce();
845
+ export {
846
+ ht as ADMIN_FORM_ROUTE,
847
+ Lt as ADMIN_LIST_ROUTE,
848
+ Ft as ROLE_FORM_ROUTE,
849
+ yt as ROLE_LIST_ROUTE,
850
+ ze as createAdmin,
851
+ ke as createRole,
852
+ je as deleteAdmin,
853
+ Ne as deleteRole,
854
+ qe as getAdmin,
855
+ Ae as getAdminFormUrl,
856
+ Ve as getAdminList,
857
+ oe as getAdminListUrl,
858
+ Oe as getFieldList,
859
+ Pe as getRole,
860
+ Fe as getRoleFormUrl,
861
+ ye as getRoleList,
862
+ ae as getRoleListUrl,
863
+ _e as getScopes,
864
+ He as updateAdmin,
865
+ Be as updateRole
866
+ };