@tager/admin-administrators 1.0.0 → 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,10 +1,11 @@
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 = {
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 = {
8
9
  home: "Home",
9
10
  administrators: "Administrators",
10
11
  role: "Role",
@@ -42,238 +43,238 @@ const EN = {
42
43
  adminForm: "Admin form",
43
44
  roleList: "Role List",
44
45
  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..."
46
+ andMorePrivilege: "and more {{count}} privilege...",
47
+ tabs: {
48
+ general: "General",
49
+ params: "Template"
50
+ }
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}} привилегий...",
90
+ tabs: {
91
+ general: "Основное",
92
+ params: "Параметры"
93
+ }
86
94
  };
87
- function applyTranslations() {
88
- i18n.addTranslations("en", "administrators", EN);
89
- i18n.addTranslations("ru", "administrators", RU);
95
+ function Ce() {
96
+ te.addTranslations("en", "administrators", Ue), te.addTranslations("ru", "administrators", we);
97
+ }
98
+ function Oe() {
99
+ return h.get({ path: "/admin/admins/fields" });
90
100
  }
91
- function getRoleList() {
92
- return request.get({ path: "/admin/rbac/roles" });
101
+ function ye() {
102
+ return h.get({ path: "/admin/rbac/roles" });
93
103
  }
94
- function getRole(roleId) {
95
- return request.get({ path: `/admin/rbac/roles/${roleId}` });
104
+ function Pe(e) {
105
+ return h.get({ path: `/admin/rbac/roles/${e}` });
96
106
  }
97
- function createRole(payload) {
98
- return request.post({ path: "/admin/rbac/roles", body: payload });
107
+ function ke(e) {
108
+ return h.post({ path: "/admin/rbac/roles", body: e });
99
109
  }
100
- function updateRole(roleId, payload) {
101
- 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 });
102
112
  }
103
- function deleteRole(roleId) {
104
- return request.delete({ path: `/admin/rbac/roles/${roleId}` });
113
+ function Ne(e) {
114
+ return h.delete({ path: `/admin/rbac/roles/${e}` });
105
115
  }
106
- function getScopes() {
107
- return request.get({ path: "/admin/rbac/scopes" });
116
+ function _e() {
117
+ return h.get({ path: "/admin/rbac/scopes" });
108
118
  }
109
- function getAdminList() {
110
- return request.get({ path: "/admin/admins" });
119
+ function Ve() {
120
+ return h.get({ path: "/admin/admins" });
111
121
  }
112
- function getAdmin(adminId) {
113
- return request.get({ path: `/admin/admins/${adminId}` });
122
+ function qe(e) {
123
+ return h.get({ path: `/admin/admins/${e}` });
114
124
  }
115
- function createAdmin(payload) {
116
- return request.post({ path: "/admin/admins", body: payload });
125
+ function ze(e) {
126
+ return h.post({ path: "/admin/admins", body: e });
117
127
  }
118
- function updateAdmin(adminId, payload) {
119
- return request.put({ path: `/admin/admins/${adminId}`, body: payload });
128
+ function He(e, t) {
129
+ return h.put({ path: `/admin/admins/${e}`, body: t });
120
130
  }
121
- function deleteAdmin(adminId) {
122
- return request.delete({ path: `/admin/admins/${adminId}` });
131
+ function je(e) {
132
+ return h.delete({ path: `/admin/admins/${e}` });
123
133
  }
124
- const ADMINISTRATOR_ROUTE_PATHS = {
134
+ const L = {
125
135
  ROLE_LIST: "/roles",
126
136
  ROLE_FORM: "/roles/:roleId",
127
137
  ADMIN_LIST: "/admins",
128
138
  ADMIN_FORM: "/admins/:adminId"
129
139
  };
130
- function getRoleListUrl() {
131
- return ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST;
140
+ function ae() {
141
+ return L.ROLE_LIST;
132
142
  }
133
- function getRoleFormUrl(params) {
134
- return compile(ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM)(params);
143
+ function Fe(e) {
144
+ return Re(L.ROLE_FORM)(e);
135
145
  }
136
- function getAdminListUrl() {
137
- return ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST;
146
+ function oe() {
147
+ return L.ADMIN_LIST;
138
148
  }
139
- function getAdminFormUrl(params) {
140
- return compile(ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM)(params);
149
+ function Ae(e) {
150
+ return Re(L.ADMIN_FORM)(e);
141
151
  }
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({
152
+ const Je = z({
150
153
  name: "AdminList",
151
154
  components: {
152
- Page,
153
- DataTable,
154
- BaseButton,
155
- DeleteIcon,
156
- EditIcon
155
+ Page: j,
156
+ DataTable: ce,
157
+ BaseButton: me,
158
+ DeleteIcon: ue,
159
+ EditIcon: de
157
160
  },
158
161
  setup() {
159
- const { t } = useI18n();
160
- const {
161
- fetchEntityList: fetchAdminList,
162
- isLoading: isAdminListLoading,
163
- rowData: adminList,
164
- errorMessage: error
165
- } = useDataTable({
166
- fetchEntityList: () => getAdminList(),
162
+ const { t: e } = q(), {
163
+ fetchEntityList: t,
164
+ isLoading: r,
165
+ rowData: m,
166
+ errorMessage: d
167
+ } = pe({
168
+ fetchEntityList: () => Ve(),
167
169
  initialValue: [],
168
170
  resourceName: "Admin list",
169
171
  pageSize: 100
170
172
  });
171
- onMounted(() => {
172
- fetchAdminList();
173
+ H(() => {
174
+ t();
173
175
  });
174
176
  const {
175
- handleResourceDelete: handleAdminDelete,
176
- isDeleting
177
- } = useResourceDelete({
178
- deleteResource: deleteAdmin,
177
+ handleResourceDelete: s,
178
+ isDeleting: c
179
+ } = ne({
180
+ deleteResource: je,
179
181
  resourceName: "Admin",
180
- onSuccess: fetchAdminList
182
+ onSuccess: t
181
183
  });
182
- function isBusy(adminId) {
183
- return isDeleting(adminId) || isAdminListLoading.value;
184
+ function n(f) {
185
+ return c(f) || r.value;
184
186
  }
185
- const columnDefs = [
187
+ const p = [
186
188
  {
187
189
  id: 1,
188
- name: t("administrators:admin"),
190
+ name: e("administrators:admin"),
189
191
  field: "name"
190
192
  },
191
193
  {
192
194
  id: 2,
193
- name: t("administrators:email"),
195
+ name: e("administrators:email"),
194
196
  field: "email"
195
197
  },
196
198
  {
197
199
  id: 3,
198
- name: t("administrators:roles"),
200
+ name: e("administrators:roles"),
199
201
  field: "roles"
200
202
  },
201
203
  {
202
204
  id: 4,
203
- name: t("administrators:actions"),
205
+ name: e("administrators:actions"),
204
206
  field: "actions",
205
207
  style: { width: "180px", textAlign: "center", whiteSpace: "nowrap" },
206
208
  headStyle: { width: "180px", textAlign: "center" }
207
209
  }
208
210
  ];
209
211
  return {
210
- t,
211
- columnDefs,
212
- rowData: adminList,
213
- isRowDataLoading: isAdminListLoading,
214
- errorMessage: error,
215
- isBusy,
216
- handleAdminDelete,
217
- 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
218
220
  };
219
221
  }
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"),
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"),
229
232
  "header-buttons": [
230
233
  {
231
- text: _ctx.$i18n.t("administrators:createAdministrator"),
232
- href: _ctx.getAdminFormUrl({ adminId: "create" })
234
+ text: e.$i18n.t("administrators:createAdministrator"),
235
+ href: e.getAdminFormUrl({ adminId: "create" })
233
236
  }
234
237
  ]
235
238
  }, {
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
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
242
245
  }, {
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))
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))
250
251
  ])
251
252
  ]),
252
- "cell(actions)": withCtx(({ row }) => [
253
- !row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
253
+ "cell(actions)": b(({ row: a }) => [
254
+ a.isSelf ? I("", !0) : (i(), S(n, {
254
255
  key: 0,
255
256
  variant: "icon",
256
- title: _ctx.$i18n.t("administrators:edit"),
257
- disabled: _ctx.isBusy(row.id),
258
- 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 })
259
260
  }, {
260
- default: withCtx(() => [
261
- createVNode(_component_EditIcon)
261
+ default: b(() => [
262
+ g(c)
262
263
  ]),
263
264
  _: 2
264
- }, 1032, ["title", "disabled", "href"])) : createCommentVNode("", true),
265
- !row.isSuperAdmin || !row.isSelf ? (openBlock(), createBlock(_component_BaseButton, {
265
+ }, 1032, ["title", "disabled", "href"])),
266
+ !a.isSuperAdmin || !a.isSelf ? (i(), S(n, {
266
267
  key: 1,
267
268
  variant: "icon",
268
- title: _ctx.$i18n.t("administrators:delete"),
269
- disabled: _ctx.isBusy(row.id),
270
- 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)
271
272
  }, {
272
- default: withCtx(() => [
273
- createVNode(_component_DeleteIcon)
273
+ default: b(() => [
274
+ g(p)
274
275
  ]),
275
276
  _: 2
276
- }, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
277
+ }, 1032, ["title", "disabled", "onClick"])) : I("", !0)
277
278
  ]),
278
279
  _: 1
279
280
  }, 8, ["column-defs", "row-data", "loading", "error-message"])
@@ -281,364 +282,370 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
281
282
  _: 1
282
283
  }, 8, ["title", "header-buttons"]);
283
284
  }
284
- var AdminList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
285
- function convertAdminToFormValues(admin, roleOptionList) {
286
- if (!admin) {
285
+ const Qe = /* @__PURE__ */ J(Je, [["render", Ke]]);
286
+ function X(e, t) {
287
+ if (!e)
287
288
  return {
288
289
  name: "",
289
290
  email: "",
290
- password: createId(),
291
+ password: Ie(),
291
292
  roles: []
292
293
  };
293
- }
294
- 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
+ );
295
297
  return {
296
- name: admin.name,
297
- email: admin.email,
298
+ name: e.name,
299
+ email: e.email,
298
300
  password: "",
299
- roles: currentRoleOptionList
301
+ roles: r
300
302
  };
301
303
  }
302
- function convertFormValuesToAdminUpdatePayload(values) {
304
+ function Se(e, t = []) {
303
305
  return {
304
- name: values.name,
305
- email: values.email,
306
- roles: values.roles.map((role) => role.value),
307
- password: values.password
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
313
+ }))
308
314
  };
309
315
  }
310
- function convertFormValuesToAdminCreationPayload(values) {
316
+ function We(e, t = []) {
311
317
  return {
312
- ...convertFormValuesToAdminUpdatePayload(values)
318
+ ...Se(e, t)
313
319
  };
314
320
  }
315
- function convertRoleListToOptions(roleList) {
316
- return roleList.map((role) => ({
317
- value: role.id,
318
- label: role.name
321
+ function Xe(e) {
322
+ return e.map((t) => ({
323
+ value: t.id,
324
+ label: t.name
319
325
  }));
320
326
  }
321
- const _sfc_main$2 = defineComponent({
327
+ const Ye = z({
322
328
  name: "AdminForm",
323
- components: { Page, FormFooter, FormField, FormFieldMultiSelect },
329
+ components: {
330
+ DynamicField: Me,
331
+ TabList: Ee,
332
+ Page: j,
333
+ FormFooter: ve,
334
+ FormField: ge,
335
+ FormFieldMultiSelect: fe
336
+ },
324
337
  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),
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),
333
340
  initialValue: null,
334
341
  resourceName: "Admin"
335
- });
336
- const [
337
- fetchRoleList,
338
- { data: roleList, loading: isRoleListLoading }
339
- ] = useResource({
340
- fetchResource: getRoleList,
342
+ }), [f, { data: v, loading: a }] = P({
343
+ fetchResource: ye,
344
+ initialValue: [],
345
+ resourceName: "Role List"
346
+ }), [o, { data: u, loading: A }] = P({
347
+ fetchResource: Oe,
341
348
  initialValue: [],
342
- resourceName: "Role list"
349
+ resourceName: "Field List"
343
350
  });
344
- onMounted(() => {
345
- fetchRoleList();
346
- if (isCreation.value)
347
- return;
348
- fetchAdmin();
351
+ H(() => {
352
+ f(), o(), x(), !s.value && c();
349
353
  });
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);
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
+ );
356
364
  });
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({
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({
375
376
  variant: "success",
376
- title: t("administrators:success"),
377
- body: isCreation.value ? t("administrators:adminSuccessfullyCreated") : t("administrators:adminSuccessfullyUpdated")
377
+ title: e("administrators:success"),
378
+ body: s.value ? e("administrators:adminSuccessfullyCreated") : e("administrators:adminSuccessfullyUpdated")
378
379
  });
379
- }).catch((error) => {
380
- console.error(error);
381
- errors.value = convertRequestErrorToMap(error);
382
- toast.show({
380
+ }).catch((E) => {
381
+ console.error(E), O.value = ie(E), m.show({
383
382
  variant: "danger",
384
- title: t("administrators:error"),
385
- body: isCreation.value ? t("administrators:adminCreationError") : t("administrators:adminUpdateError")
383
+ title: e("administrators:error"),
384
+ body: s.value ? e("administrators:adminCreationError") : e("administrators:adminUpdateError")
386
385
  });
387
386
  }).finally(() => {
388
- isSubmitting.value = false;
387
+ B.value = !1;
389
388
  });
390
389
  }
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
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
+ );
410
+ }
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
407
428
  };
408
429
  }
409
430
  });
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
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
418
436
  }, {
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"])
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
444
+ }, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
427
445
  ]),
428
- default: withCtx(() => [
429
- createElementVNode("form", {
446
+ default: b(() => [
447
+ C("form", {
430
448
  novalidate: "",
431
- onSubmit: _cache[4] || (_cache[4] = withModifiers(() => {
449
+ onSubmit: t[5] || (t[5] = le(() => {
432
450
  }, ["prevent"]))
433
451
  }, [
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"])
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
456
+ }, null, 8, ["tab-id", "tab-list"]),
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),
461
+ name: "name",
462
+ error: e.errors.name,
463
+ label: e.$i18n.t("administrators:name")
464
+ }, null, 8, ["value", "error", "label"]),
465
+ g(n, {
466
+ value: e.values.email,
467
+ "onUpdate:value": t[2] || (t[2] = (o) => e.values.email = o),
468
+ name: "email",
469
+ error: e.errors.email,
470
+ label: e.$i18n.t("administrators:email")
471
+ }, null, 8, ["value", "error", "label"]),
472
+ g(p, {
473
+ "selected-options": e.values.roles,
474
+ "onUpdate:selected-options": t[3] || (t[3] = (o) => e.values.roles = o),
475
+ name: "roles",
476
+ label: e.$i18n.t("administrators:roles"),
477
+ options: e.roleOptionList,
478
+ error: e.errors.roles
479
+ }, null, 8, ["selected-options", "label", "options", "error"]),
480
+ g(n, {
481
+ value: e.values.password,
482
+ "onUpdate:value": t[4] || (t[4] = (o) => e.values.password = o),
483
+ name: "password",
484
+ error: e.errors.password,
485
+ label: e.isCreation ? e.$i18n.t("administrators:password") : e.$i18n.t("administrators:newPassword")
486
+ }, null, 8, ["value", "error", "label"])
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)
463
492
  ], 32)
464
493
  ]),
465
494
  _: 1
466
495
  }, 8, ["title", "is-content-loading"]);
467
496
  }
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({
497
+ const Ge = /* @__PURE__ */ J(Ye, [["render", Ze]]), xe = z({
471
498
  name: "RoleList",
472
499
  components: {
473
- Page,
474
- DeleteIcon,
475
- EditIcon,
476
- DataTable,
477
- BaseButton
500
+ Page: j,
501
+ DeleteIcon: ue,
502
+ EditIcon: de,
503
+ DataTable: ce,
504
+ BaseButton: me
478
505
  },
479
506
  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(),
507
+ const { t: e } = q(), {
508
+ fetchEntityList: t,
509
+ isLoading: r,
510
+ rowData: m,
511
+ errorMessage: d
512
+ } = pe({
513
+ fetchEntityList: (a) => ye(),
488
514
  initialValue: [],
489
515
  resourceName: "Role list",
490
516
  pageSize: 100
491
517
  });
492
- onMounted(() => {
493
- fetchRoleList();
518
+ H(() => {
519
+ t();
494
520
  });
495
521
  const {
496
- handleResourceDelete: handleRoleDelete,
497
- isDeleting
498
- } = useResourceDelete({
499
- deleteResource: deleteRole,
522
+ handleResourceDelete: s,
523
+ isDeleting: c
524
+ } = ne({
525
+ deleteResource: Ne,
500
526
  resourceName: "Role",
501
- onSuccess: fetchRoleList
527
+ onSuccess: t
502
528
  });
503
- function isBusy(roleId) {
504
- return isDeleting(roleId) || isRoleListLoading.value;
529
+ function n(a) {
530
+ return c(a) || r.value;
505
531
  }
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
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
518
540
  }));
519
541
  }
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 "";
542
+ function f(a) {
543
+ return a === 1 ? e("administrators:andMorePrivilege", { count: 1 }) : a > 1 ? e("administrators:andMorePrivilege", {
544
+ count: a
545
+ }) : "";
530
546
  }
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
547
  return {
551
- columnDefs,
552
- rowData: roleList,
553
- isRowDataLoading: isRoleListLoading,
554
- errorMessage: error,
555
- isBusy,
556
- handleRoleDelete,
557
- getRoleFormUrl,
558
- getScopeGroupList,
559
- 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,
560
575
  scopesPerModuleCount: 3
561
576
  };
562
577
  }
563
- });
564
- const _hoisted_1 = {
578
+ }), et = {
565
579
  key: 0,
566
580
  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 = {
581
+ }, tt = { key: 1 }, at = { class: "module-name" }, ot = { class: "scope-list" }, nt = {
572
582
  key: 0,
573
583
  class: "rest-scopes-text"
574
584
  };
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"),
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"),
583
589
  "header-buttons": [
584
590
  {
585
- text: _ctx.$i18n.t("administrators:addRole"),
586
- href: _ctx.getRoleFormUrl({ roleId: "create" })
591
+ text: e.$i18n.t("administrators:addRole"),
592
+ href: e.getRoleFormUrl({ roleId: "create" })
587
593
  }
588
594
  ]
589
595
  }, {
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
+ default: b(() => [
597
+ g(f, {
598
+ "column-defs": e.columnDefs,
599
+ "row-data": e.rowData,
600
+ loading: e.isRowDataLoading,
601
+ "error-message": e.errorMessage
596
602
  }, {
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))
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))
617
624
  ]),
618
- "cell(actions)": withCtx(({ row }) => [
619
- createVNode(_component_BaseButton, {
625
+ "cell(actions)": b(({ row: a }) => [
626
+ g(n, {
620
627
  variant: "icon",
621
- title: _ctx.$i18n.t("administrators:edit"),
622
- disabled: _ctx.isBusy(row.id),
623
- 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 })
624
631
  }, {
625
- default: withCtx(() => [
626
- createVNode(_component_EditIcon)
632
+ default: b(() => [
633
+ g(c)
627
634
  ]),
628
635
  _: 2
629
636
  }, 1032, ["title", "disabled", "href"]),
630
- !row.isSuperAdmin ? (openBlock(), createBlock(_component_BaseButton, {
637
+ a.isSuperAdmin ? I("", !0) : (i(), S(n, {
631
638
  key: 0,
632
639
  variant: "icon",
633
- title: _ctx.$i18n.t("administrators:delete"),
634
- disabled: _ctx.isBusy(row.id),
635
- 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)
636
643
  }, {
637
- default: withCtx(() => [
638
- createVNode(_component_DeleteIcon)
644
+ default: b(() => [
645
+ g(p)
639
646
  ]),
640
647
  _: 2
641
- }, 1032, ["title", "disabled", "onClick"])) : createCommentVNode("", true)
648
+ }, 1032, ["title", "disabled", "onClick"]))
642
649
  ]),
643
650
  _: 1
644
651
  }, 8, ["column-defs", "row-data", "loading", "error-message"])
@@ -646,230 +653,214 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
646
653
  _: 1
647
654
  }, 8, ["title", "header-buttons"]);
648
655
  }
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
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
662
666
  };
663
667
  }
664
- function convertFormValuesToRoleCreationPayload(values) {
668
+ function Te(e) {
665
669
  return {
666
- name: values.name,
667
- scopes: values.scopes.map((scope) => scope.value)
670
+ name: e.name,
671
+ scopes: e.scopes.map((t) => t.value)
668
672
  };
669
673
  }
670
- function convertFormValuesToRoleUpdatePayload(values) {
674
+ function it(e) {
671
675
  return {
672
- ...convertFormValuesToRoleCreationPayload(values)
676
+ ...Te(e)
673
677
  };
674
678
  }
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();
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() : [];
682
686
  }
683
- var RoleForm_vue_vue_type_style_index_0_scoped_true_lang = "";
684
- const _sfc_main = defineComponent({
687
+ const dt = z({
685
688
  name: "RoleForm",
686
- components: { Page, FormFooter, FormField, FormFieldMultiSelect },
689
+ components: { Page: j, FormFooter: ve, FormField: ge, FormFieldMultiSelect: fe },
687
690
  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),
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),
696
693
  initialValue: null,
697
694
  resourceName: "Role"
698
- });
699
- const [
700
- fetchScopeData,
701
- { data: scopeData, loading: isScopeDataLoading }
702
- ] = useResource({
703
- fetchResource: getScopes,
695
+ }), [
696
+ f,
697
+ { data: v, loading: a }
698
+ ] = P({
699
+ fetchResource: _e,
704
700
  initialValue: null,
705
701
  resourceName: "Scope list"
706
702
  });
707
- onMounted(() => {
708
- fetchScopeData();
709
- if (isCreation.value)
710
- return;
711
- fetchRole();
703
+ H(() => {
704
+ f(), !s.value && c();
712
705
  });
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);
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);
719
711
  });
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({
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({
736
716
  variant: "success",
737
- title: t("administrators:success"),
738
- body: isCreation.value ? t("administrators:roleSuccessfullyCreated") : t("administrators:roleSuccessfullyUpdate")
717
+ title: e("administrators:success"),
718
+ body: s.value ? e("administrators:roleSuccessfullyCreated") : e("administrators:roleSuccessfullyUpdate")
739
719
  });
740
- }).catch((error) => {
741
- console.error(error);
742
- errors.value = convertRequestErrorToMap(error);
743
- toast.show({
720
+ }).catch(($) => {
721
+ console.error($), A.value = ie($), m.show({
744
722
  variant: "danger",
745
- title: t("administrators:error"),
746
- body: isCreation.value ? t("administrators:roleCreationError") : t("administrators:roleUpdateError")
723
+ title: e("administrators:error"),
724
+ body: s.value ? e("administrators:roleCreationError") : e("administrators:roleUpdateError")
747
725
  });
748
726
  }).finally(() => {
749
- isSubmitting.value = false;
727
+ y.value = !1;
750
728
  });
751
729
  }
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);
730
+ const O = R(() => s.value ? e("administrators:createRole") : `${e("administrators:updateRole")} "${u.value.name}"`), B = R(
731
+ () => p.value || a.value
732
+ );
756
733
  return {
757
- backButtonUrl: getRoleListUrl(),
758
- values,
759
- errors,
760
- isSubmitting,
761
- submitForm,
762
- isContentLoading,
763
- role,
764
- pageTitle,
765
- isCreation,
766
- 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
767
744
  };
768
745
  }
769
746
  });
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
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
778
752
  }, {
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"])
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"])
787
761
  ]),
788
- default: withCtx(() => [
789
- createElementVNode("form", {
762
+ default: b(() => [
763
+ C("form", {
790
764
  novalidate: "",
791
- onSubmit: _cache[2] || (_cache[2] = withModifiers(() => {
765
+ onSubmit: t[2] || (t[2] = le(() => {
792
766
  }, ["prevent"]))
793
767
  }, [
794
- createVNode(_component_FormField, {
795
- value: _ctx.values.name,
796
- "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),
797
771
  name: "name",
798
- error: _ctx.errors.name,
799
- label: _ctx.$i18n.t("administrators:name")
772
+ error: e.errors.name,
773
+ label: e.$i18n.t("administrators:name")
800
774
  }, null, 8, ["value", "error", "label"]),
801
- !_ctx.values.isSuperAdmin ? (openBlock(), createBlock(_component_FormFieldMultiSelect, {
775
+ e.values.isSuperAdmin ? I("", !0) : (i(), S(n, {
802
776
  key: 0,
803
- "selected-options": _ctx.values.scopes,
804
- "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),
805
779
  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)
780
+ label: e.$i18n.t("administrators:privileges"),
781
+ options: e.scopeOptionList,
782
+ error: e.errors.scopes
783
+ }, null, 8, ["selected-options", "label", "options", "error"]))
810
784
  ], 32)
811
785
  ]),
812
786
  _: 1
813
787
  }, 8, ["title", "is-content-loading"]);
814
788
  }
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,
789
+ const mt = /* @__PURE__ */ J(dt, [["render", ut], ["__scopeId", "data-v-2e498e82"]]), Lt = {
790
+ path: L.ADMIN_LIST,
791
+ component: Qe,
819
792
  name: "AdminList",
820
793
  meta: {
821
- getBreadcrumbs: (route, i18n2) => [
822
- { url: "/", text: i18n2.t("administrators:home") },
794
+ getBreadcrumbs: (e, t) => [
795
+ { url: "/", text: t.t("administrators:home") },
823
796
  {
824
- url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
825
- text: i18n2.t("administrators:adminList")
797
+ url: L.ADMIN_LIST,
798
+ text: t.t("administrators:adminList")
826
799
  }
827
800
  ]
828
801
  }
829
- };
830
- const ADMIN_FORM_ROUTE = {
831
- path: ADMINISTRATOR_ROUTE_PATHS.ADMIN_FORM,
832
- component: AdminForm,
802
+ }, ht = {
803
+ path: L.ADMIN_FORM,
804
+ component: Ge,
833
805
  name: "AdminForm",
834
806
  meta: {
835
- getBreadcrumbs: (route, i18n2) => [
836
- { url: "/", text: i18n2.t("administrators:home") },
807
+ getBreadcrumbs: (e, t) => [
808
+ { url: "/", text: t.t("administrators:home") },
837
809
  {
838
- url: ADMINISTRATOR_ROUTE_PATHS.ADMIN_LIST,
839
- text: i18n2.t("administrators:adminList")
810
+ url: L.ADMIN_LIST,
811
+ text: t.t("administrators:adminList")
840
812
  },
841
- { url: route.path, text: i18n2.t("administrators:adminForm") }
813
+ { url: e.path, text: t.t("administrators:adminForm") }
842
814
  ]
843
815
  }
844
- };
845
- const ROLE_LIST_ROUTE = {
846
- path: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
847
- component: RoleList,
816
+ }, yt = {
817
+ path: L.ROLE_LIST,
818
+ component: st,
848
819
  name: "RoleList",
849
820
  meta: {
850
- getBreadcrumbs: (route, i18n2) => [
851
- { url: "/", text: i18n2.t("administrators:home") },
821
+ getBreadcrumbs: (e, t) => [
822
+ { url: "/", text: t.t("administrators:home") },
852
823
  {
853
- url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
854
- text: i18n2.t("administrators:roleList")
824
+ url: L.ROLE_LIST,
825
+ text: t.t("administrators:roleList")
855
826
  }
856
827
  ]
857
828
  }
858
- };
859
- const ROLE_FORM_ROUTE = {
860
- path: ADMINISTRATOR_ROUTE_PATHS.ROLE_FORM,
861
- component: RoleForm,
829
+ }, Ft = {
830
+ path: L.ROLE_FORM,
831
+ component: mt,
862
832
  name: "RoleForm",
863
833
  meta: {
864
- getBreadcrumbs: (route, i18n2) => [
865
- { url: "/", text: i18n2.t("administrators:home") },
834
+ getBreadcrumbs: (e, t) => [
835
+ { url: "/", text: t.t("administrators:home") },
866
836
  {
867
- url: ADMINISTRATOR_ROUTE_PATHS.ROLE_LIST,
868
- text: i18n2.t("administrators:roleList")
837
+ url: L.ROLE_LIST,
838
+ text: t.t("administrators:roleList")
869
839
  },
870
- { url: route.path, text: i18n2.t("administrators:roleForm") }
840
+ { url: e.path, text: t.t("administrators:roleForm") }
871
841
  ]
872
842
  }
873
843
  };
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 };
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
+ };