@feedmepos/mf-hrm-portal 2.2.1-dev.2 → 2.2.1-dev.3

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.
Files changed (42) hide show
  1. package/dist/{ApprovalCodeList-DZajn7xx.js → ApprovalCodeList-rL8dh-6s.js} +5 -5
  2. package/dist/{AuditLogList-CpKIq8I0.js → AuditLogList-NvISIfUq.js} +4 -4
  3. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-BJgpH-kw.js +438 -0
  4. package/dist/{EmployeeList-DDuxDdlJ.js → EmployeeList-C3VvVY6A.js} +6 -6
  5. package/dist/{GrantUserList-735upmIE.js → GrantUserList-DjZ4O0VB.js} +6 -6
  6. package/dist/{Main-DyZ6dJ2d.js → Main-ByWrRV70.js} +8 -8
  7. package/dist/{Main-tQ6MrkkP.js → Main-DVTx58X9.js} +11 -11
  8. package/dist/{Main-CHHR0r5b.js → Main-LaAbAOfs.js} +5 -5
  9. package/dist/{PermissionSetList-ZxLNYPEB.js → PermissionSetList-DD45SSY3.js} +7 -7
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-yDPvNHiW.js +4169 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-XHuHin8t.js} +1 -1
  12. package/dist/RoleList-BDxgwmAV.js +725 -0
  13. package/dist/{TeamMemberList-B58boeR9.js → TeamMemberList-DrLbMN34.js} +9 -9
  14. package/dist/{TimesheetList-DMnNVVlB.js → TimesheetList-CdaxlO97.js} +7 -7
  15. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-Ch8Ng6wi.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-ogjfztLs.js} +3 -3
  16. package/dist/{app-CtuaUGnw.js → app-B8eo04d6.js} +6 -6
  17. package/dist/app.js +1 -1
  18. package/dist/{approval-code-Q4666xp5.js → approval-code-jIjkeVEb.js} +1 -1
  19. package/dist/{dayjs.min-9pRWRTS9.js → dayjs.min-DZEHW2QB.js} +1 -1
  20. package/dist/{employee-JmfN-rQF.js → employee-DX0CZF-B.js} +4 -4
  21. package/dist/{grant-user-CQZaTzVt.js → grant-user-SNiDV22U.js} +1 -1
  22. package/dist/{iteration-CkzTvtOv.js → iteration-yBS4dpFh.js} +1 -1
  23. package/dist/{lodash-BNBzabCH.js → lodash-344d5Ope.js} +1 -1
  24. package/dist/{restaurant-YOVMuuFY.js → restaurant-BTpBmfBV.js} +12 -14
  25. package/dist/role-BXBuBxs5.js +92 -0
  26. package/dist/rule-DWlFon04.js +1094 -0
  27. package/dist/src/composables/useReportPermissions.d.ts +1 -0
  28. package/dist/src/helpers/rule.d.ts +10 -1
  29. package/dist/src/stores/role.d.ts +6 -6
  30. package/dist/src/views/team/components/PortalConditionForm.vue.d.ts +44 -0
  31. package/dist/src/views/team/condition-builders/ConditionBuilderForm.vue.d.ts +39 -0
  32. package/dist/tsconfig.app.tsbuildinfo +1 -1
  33. package/dist/{useAppStore-DNTlIeMv.js → useAppStore-DCwd8GWN.js} +1 -1
  34. package/dist/{useLoading-BH02lYns.js → useLoading-CXzTpIVv.js} +1 -1
  35. package/dist/useReportPermissions-C0exkIxU.js +71 -0
  36. package/package.json +1 -1
  37. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-DCfvikJB.js +0 -387
  38. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-MoFevdmL.js +0 -4122
  39. package/dist/RoleList-BZbEGpCi.js +0 -685
  40. package/dist/role-R_9sO2QD.js +0 -82
  41. package/dist/rule-D1pKbnKR.js +0 -1066
  42. package/dist/useReportPermissions-ByxRc3kz.js +0 -70
@@ -1,685 +0,0 @@
1
- import { computed as R, defineComponent as we, ref as D, watch as oe, onMounted as ke, resolveComponent as F, createBlock as j, openBlock as c, unref as o, withCtx as b, createElementVNode as n, createVNode as u, createElementBlock as C, Fragment as E, createCommentVNode as re, renderList as Q, toDisplayString as U, normalizeClass as ze, h as B, createTextVNode as pe, resolveDynamicComponent as xe, withModifiers as Ke, nextTick as Ce } from "vue";
2
- import { e as L } from "./iteration-CkzTvtOv.js";
3
- import { useI18n as Ve } from "@feedmepos/mf-common";
4
- import { useSnackbar as Se, components as ve, useDialog as Ne, useBreakpoints as Oe, FmButtonColorThemeVariant as Je } from "@feedmepos/ui-library";
5
- import { k as qe, A as We, S as Ge, _ as He } from "./app-CtuaUGnw.js";
6
- import { u as Qe, _ as Fe } from "./useDiscardConfirm-DPhEV6v0.js";
7
- import { _ as Xe } from "./TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js";
8
- import { e as Ye, r as W, h as Ue, f as Ze, g as Re, a as es, b as ne } from "./rule-D1pKbnKR.js";
9
- import { u as _e } from "./restaurant-YOVMuuFY.js";
10
- import { u as $e } from "./role-R_9sO2QD.js";
11
- import { u as Ee } from "./useReportPermissions-ByxRc3kz.js";
12
- import { l as ie } from "./lodash-BNBzabCH.js";
13
- import { u as ss, _ as ts, a as as } from "./ConditionFormHost.vue_vue_type_script_setup_true_lang-DCfvikJB.js";
14
- import { _ as fe } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
15
- import { u as ls } from "./useLoading-BH02lYns.js";
16
- function os() {
17
- const X = _e();
18
- return R(() => {
19
- const t = {};
20
- return X.restaurants.value.forEach((V) => {
21
- t[V._id] = V;
22
- }), t;
23
- });
24
- }
25
- const rs = { class: "flex w-full items-center justify-between" }, ns = { class: "fm-typo-en-title-md-600" }, is = { class: "space-y-40" }, us = {
26
- key: 0,
27
- class: "flex justify-center py-16"
28
- }, cs = { class: "space-y-8" }, ms = { class: "fm-typo-en-title-sm-600" }, ds = { class: "mt-16 space-y-8" }, ps = { class: "flex items-center" }, fs = { class: "h-[24px] w-[24px] flex items-center justify-center" }, vs = { class: "flex flex-col gap-12 p-16 w-[320px]" }, _s = { class: "fm-typo-en-title-sm-600" }, hs = {
29
- key: 0,
30
- class: "h-px w-full bg-fm-color-neutral-gray-200"
31
- }, gs = { class: "flex justify-end pt-8" }, bs = {
32
- key: 0,
33
- class: "ml-20 mt-8 flex max-w-[320px] flex-row items-start gap-8"
34
- }, ys = { class: "mt-8 whitespace-nowrap" }, xs = { class: "flex gap-8 items-center justify-start" }, Cs = /* @__PURE__ */ we({
35
- __name: "RoleForm",
36
- props: {
37
- id: {
38
- type: String,
39
- default: void 0
40
- }
41
- },
42
- setup(X, { expose: Y }) {
43
- const { t } = Ve(), V = _e(), A = D(""), M = R(() => V.restaurants.value.filter(({ profile: e }) => {
44
- const s = `${e.code ? e.code + "-" : ""}${e.legalName}`;
45
- return !A.value || s.toLowerCase().includes(A.value.toLowerCase());
46
- })), G = D(V.restaurants.value.length === 0);
47
- oe(
48
- () => V.restaurants.value.length,
49
- (e) => {
50
- e > 0 && (G.value = !1);
51
- }
52
- );
53
- const z = $e(), Z = Se(), ee = ls(Z), { fetchReportPermissions: se, allReportPermissions: ue, availableReportKeys: K } = Ee(), $ = X, S = D(!1), ce = () => {
54
- S.value = !S.value, S.value && _();
55
- }, O = R(() => $.id ? t("hr.role.form.update") : t("hr.role.form.add")), te = R(() => $.id ? t("common.update") : t("common.add")), J = R(() => {
56
- const e = Ye.filter(
57
- (r) => r.subject !== L.F_RULE_SUBJECT.enum.report
58
- ).map((r) => W(r)), s = ue.value.map((r) => W(r));
59
- return [...e, ...s];
60
- }), v = R(() => z.roles.value.find((e) => e._id == $.id)), P = () => ({
61
- name: "",
62
- restaurantIds: [],
63
- permissions: [],
64
- maxDiscountPercentage: 100
65
- }), a = D(P()), y = D(/* @__PURE__ */ new Map()), w = ss(y), ae = qe("report");
66
- function me(e) {
67
- const s = y.value.get(e);
68
- return !!s && Object.keys(s).length > 0;
69
- }
70
- function l(e, s) {
71
- const r = w.getDraft({ subject: e, builderKey: s.builderKey });
72
- return r ? r.formValue : s.fromCondition(
73
- We(y.value.get(e), s)
74
- );
75
- }
76
- function i(e, s, r) {
77
- w.setDraft({ subject: e, builderKey: s.builderKey }, { formValue: r });
78
- }
79
- function f(e) {
80
- if (w.getDraftsForSubject(e).size === 0) return;
81
- const r = [];
82
- for (const I of ae) {
83
- const q = w.getDraft({ subject: e, builderKey: I.builderKey });
84
- q && r.push({ builder: I, form: q.formValue });
85
- }
86
- if (r.length === 0) return;
87
- const k = y.value.get(e), T = Ge(
88
- k,
89
- r.map(({ builder: I, form: q }) => ({ builder: I, formValue: q }))
90
- ), H = new Map(y.value);
91
- Object.keys(T).length === 0 ? H.delete(e) : H.set(e, T), y.value = H, w.clearDraftsForSubject(e);
92
- }
93
- function p(e) {
94
- return w.hasDraftsForSubject(e);
95
- }
96
- const x = R(() => [
97
- {
98
- title: t("hr.role.labels.operation"),
99
- filter: (e) => e.isOrderOperation
100
- },
101
- {
102
- title: t("hr.role.labels.report"),
103
- filter: (e) => e.isReportPermission
104
- },
105
- {
106
- title: t("hr.role.labels.other"),
107
- filter: (e) => !e.isOrderOperation && !e.isReportPermission
108
- }
109
- ].map((e) => ({
110
- title: e.title,
111
- options: J.value.filter(e.filter).map(({ label: s, value: r }) => ({
112
- label: t(`hr.role.form.permissionLabels.${r}`, s),
113
- value: r
114
- }))
115
- }))), m = R(() => {
116
- var e;
117
- return Ue(((e = v.value) == null ? void 0 : e.permissions) || []);
118
- });
119
- function _() {
120
- var e;
121
- if (a.value = P(), y.value = /* @__PURE__ */ new Map(), a.value.name = ((e = v.value) == null ? void 0 : e.name) ?? "", m.value)
122
- a.value.restaurantIds = M.value.map((s) => s._id), a.value.permissions = J.value.map((s) => s.value);
123
- else if (v.value) {
124
- a.value.restaurantIds = v.value.restaurants.map((s) => s.id), a.value.permissions = v.value.permissions.map((s) => W(s).value).filter((s) => s.startsWith("report:") ? K.value.has(s.split(":")[1]) : !0), a.value.maxDiscountPercentage = Re(
125
- v.value.permissions
126
- );
127
- for (const s of v.value.permissions) {
128
- const r = W(s), k = es(s);
129
- k && y.value.set(r.value, k);
130
- }
131
- }
132
- }
133
- ke(async () => {
134
- await V.readRestaurants(), await se(), _();
135
- }), oe(S, async (e) => {
136
- e && await se();
137
- }), oe(K, () => {
138
- if (S.value && v.value && !m.value) {
139
- a.value.permissions = a.value.permissions.filter((s) => s.startsWith("report:") ? K.value.has(s.split(":")[1]) : !0);
140
- const e = new Map(y.value);
141
- for (const s of e.keys())
142
- s.startsWith("report:") && !a.value.permissions.includes(s) && e.delete(s);
143
- y.value = e;
144
- }
145
- });
146
- const N = D(""), le = R(() => ({
147
- restaurantIds: a.value.restaurantIds,
148
- role: {
149
- name: a.value.name,
150
- permissions: Ze(
151
- a.value.permissions,
152
- a.value.maxDiscountPercentage,
153
- y.value
154
- )
155
- }
156
- })), Ie = async () => {
157
- const e = le.value;
158
- await ee.minor(
159
- async () => {
160
- v.value ? await z.updateRole(v.value._id, e) : await z.createRole(e);
161
- },
162
- {
163
- successMessage: v.value ? t("hr.role.update.successMessage", { name: e.role.name }) : t("hr.role.add.successMessage", { name: e.role.name })
164
- }
165
- ), S.value = !1;
166
- }, he = R(
167
- () => a.value.restaurantIds.filter((e) => M.value.some((s) => s._id === e))
168
- ), ge = R(() => M.value.length > 0 && M.value.length === he.value.length), Le = () => {
169
- const e = a.value.restaurantIds.filter((s) => !he.value.includes(s));
170
- ge.value === !0 ? a.value.restaurantIds = e : a.value.restaurantIds = M.value.map((s) => s._id);
171
- }, be = (e) => e.map((r) => r.value).every((r) => a.value.permissions.includes(r)), De = (e) => {
172
- const s = a.value.permissions.filter(
173
- (r) => !e.map((k) => k.value).includes(r)
174
- );
175
- be(e) === !0 ? a.value.permissions = s : a.value.permissions = [...s, ...e.map((r) => r.value)];
176
- };
177
- oe(
178
- () => a.value.restaurantIds,
179
- (e) => {
180
- e.length > 0 && (N.value = "");
181
- }
182
- );
183
- const de = Qe(
184
- () => {
185
- var e, s, r, k;
186
- return !ie.isEqual(a.value.name, ((e = v.value) == null ? void 0 : e.name) || P().name) || !ie.isEqual(
187
- a.value.restaurantIds,
188
- ((s = v.value) == null ? void 0 : s.restaurants.map((T) => T.id)) || P().restaurantIds
189
- ) || !ie.isEqual(
190
- a.value.permissions,
191
- ((r = v.value) == null ? void 0 : r.permissions.map((T) => W(T).value)) || P().permissions
192
- ) || !ie.isEqual(
193
- a.value.maxDiscountPercentage,
194
- v.value ? Re((k = v.value) == null ? void 0 : k.permissions) : P().maxDiscountPercentage
195
- );
196
- },
197
- () => {
198
- S.value = !1;
199
- }
200
- );
201
- return Y({
202
- show: S,
203
- trigger: ce
204
- }), (e, s) => {
205
- const r = F("FmIcon"), k = F("FmTextField"), T = F("FmCircularProgress"), H = F("FmSearch"), I = F("FmCheckbox"), q = F("FmFormGroup"), Me = F("FmButton"), Pe = F("FmMenu"), Te = F("FmCard"), ye = F("fm-button"), Be = F("fm-side-sheet");
206
- return c(), j(Be, {
207
- id: "unit-form",
208
- "model-value": S.value,
209
- "is-container": o(ve).FmForm,
210
- "is-container-props": {
211
- onValidationSuccess: Ie,
212
- blameFormChildOnValidationFailed: !0
213
- },
214
- "max-width": 960,
215
- "close-button": !1,
216
- "onOn:clickedAway": o(de)
217
- }, {
218
- "side-sheet-header": b(() => [
219
- n("div", rs, [
220
- n("p", ns, U(O.value), 1),
221
- u(r, {
222
- name: "close",
223
- size: "md",
224
- class: "cursor-pointer",
225
- onClick: o(de)
226
- }, null, 8, ["onClick"])
227
- ])
228
- ]),
229
- "side-sheet-footer": b(() => [
230
- n("div", xs, [
231
- u(ye, {
232
- label: te.value,
233
- size: "lg",
234
- type: "submit",
235
- variant: "primary",
236
- disabled: m.value
237
- }, null, 8, ["label", "disabled"]),
238
- u(ye, {
239
- label: o(t)("common.cancel"),
240
- size: "lg",
241
- variant: "tertiary",
242
- onClick: o(de)
243
- }, null, 8, ["label", "onClick"])
244
- ])
245
- ]),
246
- default: b(() => [
247
- n("div", is, [
248
- u(fe, {
249
- title: o(t)("hr.role.form.roleDetail")
250
- }, {
251
- default: b(() => [
252
- u(k, {
253
- modelValue: a.value.name,
254
- "onUpdate:modelValue": s[0] || (s[0] = (d) => a.value.name = d),
255
- autofocus: "",
256
- rules: [(d) => !!d || o(t)("hr.role.form.required")],
257
- label: o(t)("hr.role.form.name"),
258
- disabled: m.value
259
- }, null, 8, ["modelValue", "rules", "label", "disabled"])
260
- ]),
261
- _: 1
262
- }, 8, ["title"]),
263
- u(fe, {
264
- title: o(t)("hr.role.form.restaurant")
265
- }, {
266
- default: b(() => [
267
- G.value ? (c(), C("div", us, [
268
- u(T)
269
- ])) : (c(), C(E, { key: 1 }, [
270
- u(H, {
271
- modelValue: A.value,
272
- "onUpdate:modelValue": s[1] || (s[1] = (d) => A.value = d),
273
- placeholder: o(t)("hr.restaurant.search.placeholder")
274
- }, null, 8, ["modelValue", "placeholder"]),
275
- u(q, {
276
- modelValue: a.value.restaurantIds,
277
- "onUpdate:modelValue": s[3] || (s[3] = (d) => a.value.restaurantIds = d),
278
- rules: [(d) => d.length > 0 || o(t)("hr.role.form.atLeastOneRestaurant")]
279
- }, {
280
- default: b(() => [
281
- n("div", cs, [
282
- A.value ? re("", !0) : (c(), C(E, { key: 0 }, [
283
- u(I, {
284
- "model-value": ge.value,
285
- label: o(t)("hr.role.form.all"),
286
- value: "1",
287
- disabled: m.value,
288
- "onUpdate:modelValue": Le
289
- }, null, 8, ["model-value", "label", "disabled"]),
290
- s[6] || (s[6] = n("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1))
291
- ], 64)),
292
- (c(!0), C(E, null, Q(M.value, (d) => (c(), C("div", {
293
- key: d._id
294
- }, [
295
- u(I, {
296
- modelValue: a.value.restaurantIds,
297
- "onUpdate:modelValue": s[2] || (s[2] = (h) => a.value.restaurantIds = h),
298
- label: `${d.profile.code ? d.profile.code + "-" : ""}${d.profile.name}`,
299
- value: d._id,
300
- disabled: m.value
301
- }, null, 8, ["modelValue", "label", "value", "disabled"])
302
- ]))), 128))
303
- ])
304
- ]),
305
- _: 1
306
- }, 8, ["modelValue", "rules"])
307
- ], 64))
308
- ]),
309
- _: 1
310
- }, 8, ["title"]),
311
- u(fe, {
312
- title: o(t)("hr.role.form.permissions")
313
- }, {
314
- default: b(() => [
315
- (c(!0), C(E, null, Q(x.value, (d) => (c(), j(Te, {
316
- key: d.title,
317
- variant: "outlined",
318
- class: "p-16"
319
- }, {
320
- default: b(() => [
321
- u(ts, null, {
322
- title: b(() => [
323
- n("p", ms, U(d.title), 1)
324
- ]),
325
- default: b(() => [
326
- n("div", ds, [
327
- u(I, {
328
- "model-value": be(d.options),
329
- label: o(t)("hr.role.form.all"),
330
- value: "1",
331
- disabled: m.value,
332
- "onUpdate:modelValue": (h) => De(d.options)
333
- }, null, 8, ["model-value", "label", "disabled", "onUpdate:modelValue"]),
334
- s[7] || (s[7] = n("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1)),
335
- (c(!0), C(E, null, Q(d.options, (h) => (c(), C("div", {
336
- key: h.value
337
- }, [
338
- n("div", ps, [
339
- u(I, {
340
- modelValue: a.value.permissions,
341
- "onUpdate:modelValue": s[4] || (s[4] = (g) => a.value.permissions = g),
342
- label: h.label,
343
- value: h.value,
344
- disabled: m.value,
345
- class: "flex-1"
346
- }, null, 8, ["modelValue", "label", "value", "disabled"]),
347
- h.value.startsWith("report:") ? (c(), C(E, { key: 0 }, [
348
- a.value.permissions.includes(h.value) ? (c(), j(Pe, {
349
- key: 0,
350
- "close-on-click": !1,
351
- disabled: m.value,
352
- class: "h-5 flex items-center",
353
- onClose: () => o(w).clearDraftsForSubject(h.value)
354
- }, {
355
- "menu-button": b(() => [
356
- n("div", fs, [
357
- u(r, {
358
- name: "settings",
359
- size: "sm",
360
- class: ze([
361
- "cursor-pointer transition-colors",
362
- me(h.value) ? "text-fm-color-primary-main" : "text-fm-color-neutral-gray-400 hover:text-fm-color-neutral-gray-600"
363
- ])
364
- }, null, 8, ["class"])
365
- ])
366
- ]),
367
- default: b(() => [
368
- n("div", vs, [
369
- n("p", _s, U(h.label), 1),
370
- (c(!0), C(E, null, Q(o(ae), (g, je) => (c(), C(E, {
371
- key: g.builderKey
372
- }, [
373
- je > 0 ? (c(), C("div", hs)) : re("", !0),
374
- u(as, {
375
- builder: g,
376
- "model-value": l(h.value, g),
377
- disable: m.value,
378
- "onUpdate:modelValue": (Ae) => i(h.value, g, Ae)
379
- }, null, 8, ["builder", "model-value", "disable", "onUpdate:modelValue"])
380
- ], 64))), 128)),
381
- n("div", gs, [
382
- u(Me, {
383
- label: o(t)("team.memberForm.permissions.conditionApply"),
384
- size: "md",
385
- variant: "primary",
386
- disabled: m.value || !p(h.value),
387
- onClick: (g) => f(h.value)
388
- }, null, 8, ["label", "disabled", "onClick"])
389
- ])
390
- ])
391
- ]),
392
- _: 2
393
- }, 1032, ["disabled", "onClose"])) : (c(), j(r, {
394
- key: 1,
395
- name: "settings",
396
- size: "sm",
397
- class: "invisible"
398
- }))
399
- ], 64)) : re("", !0)
400
- ]),
401
- h.value === "order:discount" && a.value.permissions.includes(h.value) ? (c(), C("div", bs, [
402
- n("div", ys, U(o(t)("hr.role.form.maxDiscountPercentage")), 1),
403
- u(k, {
404
- modelValue: a.value.maxDiscountPercentage,
405
- "onUpdate:modelValue": s[5] || (s[5] = (g) => a.value.maxDiscountPercentage = g),
406
- rules: [
407
- (g) => !!g || o(t)("hr.role.form.required"),
408
- (g) => !isNaN(g) || o(t)("hr.role.form.onlyContainsNumber"),
409
- (g) => g <= 100 || o(t)("hr.role.form.maxValueIs", { max: 100 }),
410
- (g) => g >= 0 || o(t)("hr.role.form.minValueIs", { min: 0 })
411
- ],
412
- "append-text": "%",
413
- disabled: m.value
414
- }, null, 8, ["modelValue", "rules", "disabled"])
415
- ])) : re("", !0)
416
- ]))), 128))
417
- ])
418
- ]),
419
- _: 2
420
- }, 1024)
421
- ]),
422
- _: 2
423
- }, 1024))), 128))
424
- ]),
425
- _: 1
426
- }, 8, ["title"])
427
- ])
428
- ]),
429
- _: 1
430
- }, 8, ["model-value", "is-container", "is-container-props", "onOn:clickedAway"]);
431
- };
432
- }
433
- }), Fs = {
434
- class: "space-y-8"
435
- }, Rs = {
436
- class: "flex justify-end xs:px-16"
437
- }, ws = {
438
- class: "flex flex-col h-full overflow-auto"
439
- }, ks = {
440
- class: "pb-64 sm:hidden md:hidden lg:hidden"
441
- }, Vs = {
442
- class: "space-y-4"
443
- }, Ss = {
444
- class: "fm-typo-en-body-lg-600"
445
- }, Us = {
446
- class: "text-fm-color-typo-secondary"
447
- }, $s = {
448
- class: "line-clamp-2"
449
- }, Es = {
450
- class: "font-bold"
451
- }, Is = {
452
- class: "flex items-start gap-4"
453
- }, Ls = {
454
- class: "line-clamp-2"
455
- }, Ds = {
456
- class: "font-bold"
457
- }, Ms = {
458
- class: "flex items-start gap-4"
459
- }, Ps = {
460
- class: "line-clamp-2"
461
- }, Ts = {
462
- class: "font-bold"
463
- }, Zs = /* @__PURE__ */ we({
464
- __name: "RoleList",
465
- setup(X, {
466
- expose: Y
467
- }) {
468
- const {
469
- t
470
- } = Ve(), {
471
- allReportPermissions: V
472
- } = Ee(), A = _e(), M = R(() => A.restaurants.value), G = R(() => M.value.map((l) => l._id));
473
- function z(l, i) {
474
- const f = i === L.F_RULE_SUBJECT.enum.report ? V.value : void 0, p = ne(l, i, f);
475
- return ["-", "All"].includes(p) ? () => null : () => B(ve.FmTooltip, {
476
- "z-index": "999",
477
- placement: "top",
478
- class: "ml-2"
479
- }, {
480
- content: () => B("div", [t("hr.role.tooltip.labels.permission"), ...l.filter((x) => x.subject === i).map((x) => B("div", ["- ", W(x).label]))]),
481
- default: () => B(ve.FmIcon, {
482
- name: "info",
483
- color: Je.NeutralGray400
484
- })
485
- });
486
- }
487
- function Z(l, i) {
488
- const f = i === L.F_RULE_SUBJECT.enum.report ? V.value : void 0, p = ne(l, i, f);
489
- return () => p === "All" ? p : B("div", {
490
- class: "flex items-center"
491
- }, [p, z(l, i)()]);
492
- }
493
- function ee(l) {
494
- return [{
495
- label: t("hr.role.form.update"),
496
- onClick: () => K(l)
497
- }, {
498
- label: t("hr.role.remove.title"),
499
- onClick: () => P(l),
500
- itemClass: "text-fm-color-typo-error",
501
- disabled: Ue(l.permissions)
502
- }];
503
- }
504
- const se = ({
505
- role: l,
506
- className: i = ""
507
- }) => u("div", {
508
- class: i,
509
- onClick: (f) => {
510
- f.stopPropagation();
511
- }
512
- }, [u(Fe, {
513
- items: ee(l)
514
- }, null)]), ue = [{
515
- accessorKey: "name",
516
- header: () => t("hr.role.columns.name"),
517
- enableSorting: !1
518
- }, {
519
- accessorKey: "operation",
520
- header: () => t("hr.role.columns.operation"),
521
- cell: (l) => B(Z(l.row.original.permissions, L.F_RULE_SUBJECT.enum.order)),
522
- enableSorting: !1
523
- }, {
524
- accessorKey: "report",
525
- header: () => t("hr.role.columns.report"),
526
- cell: (l) => B(Z(l.row.original.permissions, L.F_RULE_SUBJECT.enum.report)),
527
- enableSorting: !1
528
- }, {
529
- accessorKey: "restaurants",
530
- header: () => t("hr.role.columns.restaurants"),
531
- cell: (l) => l.row.original.restaurants.map((i, f) => {
532
- const p = i.code, x = `${p ? p + " - " : ""}${i.name}`;
533
- return B("div", (f ? `
534
- ` : "") + x);
535
- }),
536
- enableSorting: !1
537
- }, {
538
- id: "action",
539
- size: 52,
540
- meta: {
541
- cellClass: "pl-16",
542
- headerContentClass: "-mx-16"
543
- },
544
- cell: (l) => se({
545
- role: l.row.original,
546
- className: "flex w-full items-center justify-end"
547
- })
548
- }], K = async (l) => {
549
- var i;
550
- w.value = l._id, await Ce(), (i = y.value) == null || i.trigger();
551
- }, $ = $e(), S = os(), ce = R(() => {
552
- const l = $.roles.value || [];
553
- return (G.value.length === 0 ? l : l.filter((f) => f.restaurants.some((p) => G.value.includes(p.id)))).map((f) => {
554
- const p = f.restaurants.map((x) => {
555
- const m = S.value[x.id];
556
- return {
557
- ...x,
558
- // Prefer live data from restaurantMap so names populate reactively
559
- // even when restaurants loaded after roles.
560
- name: (m == null ? void 0 : m.profile.name) || x.name,
561
- code: m == null ? void 0 : m.profile.code
562
- };
563
- });
564
- return {
565
- ...f,
566
- restaurants: p
567
- };
568
- });
569
- }), O = R(() => {
570
- var i;
571
- return (i = ce.value) == null ? void 0 : i.filter((f) => {
572
- const p = a.value.toLowerCase(), x = f.name.toLowerCase().includes(p), _ = (f.restaurants || []).some((N) => {
573
- var le;
574
- return N.name.toLowerCase().includes(p) || ((le = N.code) == null ? void 0 : le.toLowerCase().includes(p));
575
- });
576
- return x || _;
577
- });
578
- }), te = Ne(), J = Se(), {
579
- breakpoints: v
580
- } = Oe(), P = (l) => {
581
- te.open({
582
- title: t("hr.role.remove.title"),
583
- message: t("hr.role.remove.message", {
584
- name: l.name
585
- }),
586
- minWidth: v.value.lg ? 588 : 0,
587
- primaryActions: {
588
- text: t("common.remove"),
589
- close: !1,
590
- variant: "destructive"
591
- },
592
- secondaryActions: {
593
- text: t("common.cancel"),
594
- close: !0
595
- }
596
- }).onPrimary(async () => {
597
- await $.deleteRole(l).then(() => J.open({
598
- message: t("hr.role.remove.successMessage", {
599
- name: l.name
600
- }),
601
- type: "success"
602
- })).catch((i) => J.open({
603
- message: i,
604
- type: "error"
605
- })), te.close();
606
- });
607
- }, a = D(""), y = D(), w = D(void 0);
608
- async function ae() {
609
- var l;
610
- w.value = void 0, await Ce(), (l = y.value) == null || l.trigger();
611
- }
612
- async function me() {
613
- if ($.roles.value.length === 0)
614
- try {
615
- await $.readRoles();
616
- } catch (l) {
617
- console.error("Failed to load roles:", l), J.open({
618
- message: l instanceof Error ? l.message : String(l),
619
- type: "error"
620
- });
621
- }
622
- }
623
- return ke(() => {
624
- me();
625
- }), Y({
626
- create: ae
627
- }), (l, i) => {
628
- const f = F("FmSearch"), p = F("FmTable"), x = F("FmListItem"), m = F("FmList");
629
- return c(), C(E, null, [(c(), j(Cs, {
630
- id: w.value,
631
- key: w.value,
632
- ref_key: "roleFormRef",
633
- ref: y
634
- }, null, 8, ["id"])), n("div", Fs, [n("div", Rs, [u(f, {
635
- modelValue: a.value,
636
- "onUpdate:modelValue": i[0] || (i[0] = (_) => a.value = _),
637
- class: "w-[320px] xs:w-full",
638
- autofocus: "",
639
- placeholder: o(t)("hr.role.search.placeholder") + " / " + o(t)("hr.restaurant.search.placeholder")
640
- }, null, 8, ["modelValue", "placeholder"])]), u(He, null, {
641
- default: b(() => [n("div", ws, [u(Xe, {
642
- "is-loading": o($).isLoading.value,
643
- "is-empty": O.value.length === 0,
644
- "collapse-at": "xs",
645
- title: o(t)("hr.role.noData.title"),
646
- subtitle: o(t)("hr.role.noData.subtitle")
647
- }, {
648
- default: b(() => [u(p, {
649
- class: "xs:hidden",
650
- "column-defs": ue,
651
- "row-data": O.value,
652
- "page-size": O.value.length,
653
- loading: o($).isLoading.value,
654
- "pin-header-row": "",
655
- "hide-footer": "",
656
- "shrink-at": !1,
657
- onRowClick: i[1] || (i[1] = (_) => K(_.original))
658
- }, null, 8, ["row-data", "page-size", "loading"])]),
659
- _: 1
660
- }, 8, ["is-loading", "is-empty", "title", "subtitle"]), n("div", ks, [u(m, {
661
- separator: ""
662
- }, {
663
- default: b(() => [(c(!0), C(E, null, Q(O.value, (_) => (c(), j(x, {
664
- key: _._id,
665
- class: "py-12 px-16 items-center justify-between",
666
- onClick: (N) => K(_)
667
- }, {
668
- default: b(() => [n("div", Vs, [n("p", Ss, U(_.name), 1), n("div", Us, [n("p", $s, [n("span", Es, U(o(t)("hr.role.labels.restaurant")) + ":", 1), pe(" " + U(_.restaurants.map((N) => N.name).join(", ")), 1)]), n("p", Is, [n("span", Ls, [n("span", Ds, U(o(t)("hr.role.labels.operation")) + ":", 1), pe(" " + U(o(ne)(_.permissions, o(L.F_RULE_SUBJECT).enum.order)), 1)]), (c(), j(xe(z(_.permissions, o(L.F_RULE_SUBJECT).enum.order))))]), n("p", Ms, [n("span", Ps, [n("span", Ts, U(o(t)("hr.role.labels.report")) + ":", 1), pe(" " + U(o(ne)(_.permissions, o(L.F_RULE_SUBJECT).enum.report, o(V))), 1)]), (c(), j(xe(z(_.permissions, o(L.F_RULE_SUBJECT).enum.report))))])])]), n("div", {
669
- onClick: i[2] || (i[2] = Ke(() => {
670
- }, ["stop"]))
671
- }, [u(Fe, {
672
- items: ee(_)
673
- }, null, 8, ["items"])])]),
674
- _: 2
675
- }, 1032, ["onClick"]))), 128))]),
676
- _: 1
677
- })])])]),
678
- _: 1
679
- })])], 64);
680
- };
681
- }
682
- });
683
- export {
684
- Zs as default
685
- };