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