@feedmepos/mf-hrm-portal 2.0.19 → 2.0.20-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 (66) hide show
  1. package/dist/AuditLogList-ChxAzO74.js +1037 -0
  2. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +58 -0
  3. package/dist/EmployeeList-Cs-Mn6UA.js +843 -0
  4. package/dist/FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js +45 -0
  5. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +49 -0
  6. package/dist/{Main-BPM7QyFL.js → Main-B9_TyRDo.js} +2009 -2005
  7. package/dist/Main-CdHW4UkN.js +90 -0
  8. package/dist/Main-DcvmP7s-.js +574 -0
  9. package/dist/PermissionSetList-VFVS0g0v.js +347 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Dr3R9JjS.js +3444 -0
  11. package/dist/RoleList-BZ6RZvm2.js +556 -0
  12. package/dist/TeamMemberList-C-zhFauD.js +1115 -0
  13. package/dist/{TimesheetList-CdWXksIf.js → TimesheetList-CZex54an.js} +129 -115
  14. package/dist/{app-D6OxaCEx.js → app-CLL3p27X.js} +699 -653
  15. package/dist/app.js +1 -1
  16. package/dist/{dayjs.min-C0I-OiL6.js → dayjs.min-CDt1i9vl.js} +1 -1
  17. package/dist/employee-BpRvjWNh.js +200 -0
  18. package/dist/{iteration-CcZFMm5X.js → iteration-BVjUzYL5.js} +9314 -9272
  19. package/dist/{lodash-CW7MBjcM.js → lodash-CrwgACp2.js} +1 -1
  20. package/dist/{rule-6Lg9M_3I.js → rule-BlQ5YZ9Z.js} +274 -275
  21. package/dist/src/api/audit-log/index.d.ts +9 -0
  22. package/dist/src/api/index.d.ts +0 -1
  23. package/dist/src/api/restaurant/index.d.ts +5 -0
  24. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  25. package/dist/src/components/CollapsibleWrapper.vue.d.ts +2 -0
  26. package/dist/src/components/Skeleton.vue.d.ts +7 -0
  27. package/dist/src/composables/useBasePermission.d.ts +1 -0
  28. package/dist/src/composables/useRestaurantMap.d.ts +2 -329
  29. package/dist/src/stores/restaurant.d.ts +181 -0
  30. package/dist/src/stores/role.d.ts +7 -7
  31. package/dist/src/stores/team.d.ts +6 -6
  32. package/dist/src/types/restaurant.d.ts +11 -0
  33. package/dist/src/types/team.d.ts +2 -1
  34. package/dist/src/views/hr/locales/index.d.ts +16 -0
  35. package/dist/src/views/team/components/BasePermission.vue.d.ts +3 -7
  36. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +2 -2
  37. package/dist/src/views/team/locales/index.d.ts +32 -0
  38. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +5 -3
  39. package/dist/src/views/team/member/TeamMemberMasterUser.vue.d.ts +3 -3
  40. package/dist/style.css +1 -1
  41. package/dist/{timesheet-CaSIm-Rv.js → timesheet-jFs4GTAL.js} +2 -2
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/useAppStore-DMAL8VFY.js +169 -0
  44. package/dist/useDebounce-CWb5QR9G.js +28 -0
  45. package/dist/useDiscardConfirm-DPhEV6v0.js +157 -0
  46. package/dist/{useLoading-cnpr1-pP.js → useLoading-AFTjRLyO.js} +1 -1
  47. package/dist/{useReportPermissions-CNr0AdOf.js → useReportPermissions-hODG0Xx3.js} +3 -3
  48. package/package.json +1 -1
  49. package/dist/AuditLogList-Bw3sRBhW.js +0 -980
  50. package/dist/EmployeeList-C4tVWPJE.js +0 -736
  51. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js +0 -71
  52. package/dist/HorizontalSplitter-o860F4xM.js +0 -12
  53. package/dist/Main-BC20s7cs.js +0 -560
  54. package/dist/Main-eN8MDWpv.js +0 -85
  55. package/dist/PermissionSetList-CPSRrCsu.js +0 -341
  56. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CXt721Zo.js +0 -3480
  57. package/dist/RoleList-tRu19xyl.js +0 -530
  58. package/dist/TeamMemberList-CvitYIKw.js +0 -1114
  59. package/dist/TeamMemberList.vue_vue_type_style_index_0_scoped_473cbd86_lang-BDjrD45a.js +0 -34
  60. package/dist/employee-yT17VCCS.js +0 -204
  61. package/dist/src/api/account/index.d.ts +0 -4
  62. package/dist/src/composables/useSupportedCountries.d.ts +0 -5
  63. package/dist/useAppStore-CONZvtGc.js +0 -171
  64. package/dist/useDebounce-B8ZPVS5C.js +0 -15
  65. package/dist/useDiscardConfirm-BHni0LNu.js +0 -28
  66. package/dist/useSearch-B6WK1LBB.js +0 -15
@@ -0,0 +1,556 @@
1
+ import { computed as _, defineComponent as ge, ref as $, watch as se, onMounted as be, resolveComponent as x, createBlock as P, openBlock as d, unref as o, withCtx as b, createElementVNode as p, createVNode as m, createElementBlock as k, Fragment as D, createCommentVNode as de, renderList as te, toDisplayString as N, h as S, createTextVNode as pe, resolveDynamicComponent as ve, withModifiers as Le, nextTick as fe } from "vue";
2
+ import { u as me, e as L } from "./iteration-BVjUzYL5.js";
3
+ import { useI18n as ye } from "@feedmepos/mf-common";
4
+ import { useSnackbar as xe, components as ue, useDialog as Ee, useBreakpoints as Ue, FmButtonColorThemeVariant as Ie } from "@feedmepos/ui-library";
5
+ import { _ as Se } from "./app-CLL3p27X.js";
6
+ import { u as Pe, _ as he } from "./useDiscardConfirm-DPhEV6v0.js";
7
+ import { _ as $e } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
8
+ import { e as Te, r as W, h as Re, f as Me, g as _e, a as ae } from "./rule-BlQ5YZ9Z.js";
9
+ import { u as Ce } from "./useAppStore-DMAL8VFY.js";
10
+ import { u as Fe } from "./useReportPermissions-hODG0Xx3.js";
11
+ import { l as le } from "./lodash-CrwgACp2.js";
12
+ import { _ as Be } from "./CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js";
13
+ import { _ as ie } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
14
+ import { u as De } from "./useLoading-AFTjRLyO.js";
15
+ function Ne() {
16
+ const j = me();
17
+ return _(() => {
18
+ const s = {};
19
+ return j.restaurants.value.forEach((R) => {
20
+ s[R._id] = R;
21
+ }), s;
22
+ });
23
+ }
24
+ const Oe = { class: "fm-typo-en-title-md-600" }, Ae = { class: "space-y-40" }, Je = {
25
+ key: 0,
26
+ class: "flex justify-center py-16"
27
+ }, qe = { class: "space-y-8" }, ze = { class: "fm-typo-en-title-sm-600" }, Ke = { class: "mt-16 space-y-8" }, We = {
28
+ key: 0,
29
+ class: "ml-20 mt-8 flex max-w-[320px] flex-row items-start gap-8"
30
+ }, je = { class: "mt-8 whitespace-nowrap" }, Ge = { class: "flex gap-8 items-center justify-start" }, He = /* @__PURE__ */ ge({
31
+ __name: "RoleForm",
32
+ props: {
33
+ id: {
34
+ type: String,
35
+ default: void 0
36
+ }
37
+ },
38
+ setup(j, { expose: G }) {
39
+ const { t: s } = ye(), R = me(), T = $(""), E = _(() => R.restaurants.value.filter(({ profile: e }) => {
40
+ const a = `${e.code ? e.code + "-" : ""}${e.legalName}`;
41
+ return !T.value || a.toLowerCase().includes(T.value.toLowerCase());
42
+ })), J = $(R.restaurants.value.length === 0);
43
+ se(
44
+ () => R.restaurants.value.length,
45
+ (e) => {
46
+ e > 0 && (J.value = !1);
47
+ }
48
+ );
49
+ const M = Ce(), H = xe(), Q = De(H), { fetchReportPermissions: X, allReportPermissions: oe, availableReportKeys: B } = Fe(), C = j, F = $(!1), re = () => {
50
+ F.value = !F.value, F.value && Z();
51
+ }, q = _(() => C.id ? s("hr.role.form.update") : s("hr.role.form.add")), Y = _(() => C.id ? s("common.update") : s("common.add")), O = _(() => {
52
+ const e = Te.filter(
53
+ (n) => n.subject !== L.F_RULE_SUBJECT.enum.report
54
+ ).map((n) => W(n)), a = oe.value.map((n) => W(n));
55
+ return [...e, ...a];
56
+ }), v = _(() => M.roles.value.find((e) => e._id == C.id)), U = () => ({
57
+ name: "",
58
+ restaurantIds: [],
59
+ permissions: [],
60
+ maxDiscountPercentage: 100
61
+ }), t = $(U()), z = _(() => [
62
+ {
63
+ title: s("hr.role.labels.operation"),
64
+ filter: (e) => e.isOrderOperation
65
+ },
66
+ {
67
+ title: s("hr.role.labels.report"),
68
+ filter: (e) => e.isReportPermission
69
+ },
70
+ {
71
+ title: s("hr.role.labels.other"),
72
+ filter: (e) => !e.isOrderOperation && !e.isReportPermission
73
+ }
74
+ ].map((e) => ({
75
+ title: e.title,
76
+ options: O.value.filter(e.filter).map(({ label: a, value: n }) => ({
77
+ label: s(`hr.role.form.permissionLabels.${n}`, a),
78
+ value: n
79
+ }))
80
+ }))), g = _(() => {
81
+ var e;
82
+ return Re(((e = v.value) == null ? void 0 : e.permissions) || []);
83
+ });
84
+ function Z() {
85
+ var e;
86
+ t.value = U(), t.value.name = ((e = v.value) == null ? void 0 : e.name) ?? "", g.value ? (t.value.restaurantIds = E.value.map((a) => a._id), t.value.permissions = O.value.map((a) => a.value)) : v.value && (t.value.restaurantIds = v.value.restaurants.map((a) => a.id), t.value.permissions = v.value.permissions.map((a) => W(a).value).filter((a) => a.startsWith("report:") ? B.value.has(a.split(":")[1]) : !0), t.value.maxDiscountPercentage = _e(
87
+ v.value.permissions
88
+ ));
89
+ }
90
+ be(async () => {
91
+ await R.readRestaurants(), await X(), Z();
92
+ }), se(F, async (e) => {
93
+ e && await X();
94
+ }), se(B, () => {
95
+ F.value && v.value && !g.value && (t.value.permissions = t.value.permissions.filter((e) => e.startsWith("report:") ? B.value.has(e.split(":")[1]) : !0));
96
+ });
97
+ const ne = $(""), l = _(() => ({
98
+ restaurantIds: t.value.restaurantIds,
99
+ role: {
100
+ name: t.value.name,
101
+ permissions: Me(t.value.permissions, t.value.maxDiscountPercentage)
102
+ }
103
+ })), r = async () => {
104
+ const e = l.value;
105
+ await Q.minor(
106
+ async () => {
107
+ v.value ? await M.updateRole(v.value._id, e) : await M.createRole(e);
108
+ },
109
+ {
110
+ successMessage: v.value ? s("hr.role.update.successMessage", { name: e.role.name }) : s("hr.role.add.successMessage", { name: e.role.name })
111
+ }
112
+ ), F.value = !1;
113
+ }, c = _(
114
+ () => t.value.restaurantIds.filter((e) => E.value.some((a) => a._id === e))
115
+ ), i = _(() => E.value.length > 0 && E.value.length === c.value.length), h = () => {
116
+ const e = t.value.restaurantIds.filter((a) => !c.value.includes(a));
117
+ i.value === !0 ? t.value.restaurantIds = e : t.value.restaurantIds = E.value.map((a) => a._id);
118
+ }, y = (e) => e.map((n) => n.value).every((n) => t.value.permissions.includes(n)), f = (e) => {
119
+ const a = t.value.permissions.filter(
120
+ (n) => !e.map((A) => A.value).includes(n)
121
+ );
122
+ y(e) === !0 ? t.value.permissions = a : t.value.permissions = [...a, ...e.map((n) => n.value)];
123
+ };
124
+ se(
125
+ () => t.value.restaurantIds,
126
+ (e) => {
127
+ e.length > 0 && (ne.value = "");
128
+ }
129
+ );
130
+ const V = Pe(
131
+ () => {
132
+ var e, a, n, A;
133
+ return !le.isEqual(t.value.name, ((e = v.value) == null ? void 0 : e.name) || U().name) || !le.isEqual(
134
+ t.value.restaurantIds,
135
+ ((a = v.value) == null ? void 0 : a.restaurants.map((K) => K.id)) || U().restaurantIds
136
+ ) || !le.isEqual(
137
+ t.value.permissions,
138
+ ((n = v.value) == null ? void 0 : n.permissions.map((K) => W(K).value)) || U().permissions
139
+ ) || !le.isEqual(
140
+ t.value.maxDiscountPercentage,
141
+ v.value ? _e((A = v.value) == null ? void 0 : A.permissions) : U().maxDiscountPercentage
142
+ );
143
+ },
144
+ () => {
145
+ F.value = !1;
146
+ }
147
+ );
148
+ return G({
149
+ show: F,
150
+ trigger: re
151
+ }), (e, a) => {
152
+ const n = x("FmTextField"), A = x("FmCircularProgress"), K = x("FmSearch"), ee = x("FmCheckbox"), we = x("FmFormGroup"), ke = x("FmCard"), ce = x("fm-button"), Ve = x("fm-side-sheet");
153
+ return d(), P(Ve, {
154
+ id: "unit-form",
155
+ "model-value": F.value,
156
+ "is-container": o(ue).FmForm,
157
+ "is-container-props": {
158
+ onValidationSuccess: r,
159
+ blameFormChildOnValidationFailed: !0
160
+ },
161
+ "max-width": 960,
162
+ "onOn:clickedAway": o(V),
163
+ "onOn:close": o(V)
164
+ }, {
165
+ "side-sheet-header": b(() => [
166
+ p("p", Oe, N(q.value), 1)
167
+ ]),
168
+ "side-sheet-footer": b(() => [
169
+ p("div", Ge, [
170
+ m(ce, {
171
+ label: Y.value,
172
+ size: "lg",
173
+ type: "submit",
174
+ variant: "primary",
175
+ disabled: g.value
176
+ }, null, 8, ["label", "disabled"]),
177
+ m(ce, {
178
+ label: o(s)("common.cancel"),
179
+ size: "lg",
180
+ variant: "tertiary",
181
+ onClick: o(V)
182
+ }, null, 8, ["label", "onClick"])
183
+ ])
184
+ ]),
185
+ default: b(() => [
186
+ p("div", Ae, [
187
+ m(ie, { title: "Role detail" }, {
188
+ default: b(() => [
189
+ m(n, {
190
+ modelValue: t.value.name,
191
+ "onUpdate:modelValue": a[0] || (a[0] = (u) => t.value.name = u),
192
+ autofocus: "",
193
+ rules: [(u) => !!u || o(s)("hr.role.form.required")],
194
+ label: o(s)("hr.role.form.name"),
195
+ disabled: g.value
196
+ }, null, 8, ["modelValue", "rules", "label", "disabled"])
197
+ ]),
198
+ _: 1
199
+ }),
200
+ m(ie, {
201
+ title: o(s)("hr.role.form.restaurant")
202
+ }, {
203
+ default: b(() => [
204
+ J.value ? (d(), k("div", Je, [
205
+ m(A)
206
+ ])) : (d(), k(D, { key: 1 }, [
207
+ m(K, {
208
+ modelValue: T.value,
209
+ "onUpdate:modelValue": a[1] || (a[1] = (u) => T.value = u),
210
+ placeholder: o(s)("hr.restaurant.search.placeholder")
211
+ }, null, 8, ["modelValue", "placeholder"]),
212
+ m(we, {
213
+ modelValue: t.value.restaurantIds,
214
+ "onUpdate:modelValue": a[3] || (a[3] = (u) => t.value.restaurantIds = u),
215
+ rules: [(u) => u.length > 0 || o(s)("hr.role.form.atLeastOneRestaurant")]
216
+ }, {
217
+ default: b(() => [
218
+ p("div", qe, [
219
+ T.value ? de("", !0) : (d(), k(D, { key: 0 }, [
220
+ m(ee, {
221
+ "model-value": i.value,
222
+ label: o(s)("hr.role.form.all"),
223
+ value: "1",
224
+ disabled: g.value,
225
+ "onUpdate:modelValue": h
226
+ }, null, 8, ["model-value", "label", "disabled"]),
227
+ a[6] || (a[6] = p("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1))
228
+ ], 64)),
229
+ (d(!0), k(D, null, te(E.value, (u) => (d(), k("div", {
230
+ key: u._id
231
+ }, [
232
+ m(ee, {
233
+ modelValue: t.value.restaurantIds,
234
+ "onUpdate:modelValue": a[2] || (a[2] = (I) => t.value.restaurantIds = I),
235
+ label: `${u.profile.code ? u.profile.code + "-" : ""}${u.profile.name}`,
236
+ value: u._id,
237
+ disabled: g.value
238
+ }, null, 8, ["modelValue", "label", "value", "disabled"])
239
+ ]))), 128))
240
+ ])
241
+ ]),
242
+ _: 1
243
+ }, 8, ["modelValue", "rules"])
244
+ ], 64))
245
+ ]),
246
+ _: 1
247
+ }, 8, ["title"]),
248
+ m(ie, {
249
+ title: o(s)("hr.role.form.permissions")
250
+ }, {
251
+ default: b(() => [
252
+ (d(!0), k(D, null, te(z.value, (u) => (d(), P(ke, {
253
+ key: u.title,
254
+ variant: "outlined",
255
+ class: "p-16"
256
+ }, {
257
+ default: b(() => [
258
+ m(Be, null, {
259
+ title: b(() => [
260
+ p("p", ze, N(u.title), 1)
261
+ ]),
262
+ default: b(() => [
263
+ p("div", Ke, [
264
+ m(ee, {
265
+ "model-value": y(u.options),
266
+ label: o(s)("hr.role.form.all"),
267
+ value: "1",
268
+ disabled: g.value,
269
+ "onUpdate:modelValue": (I) => f(u.options)
270
+ }, null, 8, ["model-value", "label", "disabled", "onUpdate:modelValue"]),
271
+ a[7] || (a[7] = p("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1)),
272
+ (d(!0), k(D, null, te(u.options, (I) => (d(), k("div", {
273
+ key: I.value
274
+ }, [
275
+ m(ee, {
276
+ modelValue: t.value.permissions,
277
+ "onUpdate:modelValue": a[4] || (a[4] = (w) => t.value.permissions = w),
278
+ label: I.label,
279
+ value: I.value,
280
+ disabled: g.value
281
+ }, null, 8, ["modelValue", "label", "value", "disabled"]),
282
+ I.value === "order:discount" && t.value.permissions.includes(I.value) ? (d(), k("div", We, [
283
+ p("div", je, N(o(s)("hr.role.form.maxDiscountPercentage")), 1),
284
+ m(n, {
285
+ modelValue: t.value.maxDiscountPercentage,
286
+ "onUpdate:modelValue": a[5] || (a[5] = (w) => t.value.maxDiscountPercentage = w),
287
+ rules: [
288
+ (w) => !!w || o(s)("hr.role.form.required"),
289
+ (w) => !isNaN(w) || o(s)("hr.role.form.onlyContainsNumber"),
290
+ (w) => w <= 100 || o(s)("hr.role.form.maxValueIs", { max: 100 }),
291
+ (w) => w >= 0 || o(s)("hr.role.form.minValueIs", { min: 0 })
292
+ ],
293
+ "append-text": "%",
294
+ disabled: g.value
295
+ }, null, 8, ["modelValue", "rules", "disabled"])
296
+ ])) : de("", !0)
297
+ ]))), 128))
298
+ ])
299
+ ]),
300
+ _: 2
301
+ }, 1024)
302
+ ]),
303
+ _: 2
304
+ }, 1024))), 128))
305
+ ]),
306
+ _: 1
307
+ }, 8, ["title"])
308
+ ])
309
+ ]),
310
+ _: 1
311
+ }, 8, ["model-value", "is-container", "is-container-props", "onOn:clickedAway", "onOn:close"]);
312
+ };
313
+ }
314
+ }), Qe = {
315
+ class: "space-y-8"
316
+ }, Xe = {
317
+ class: "flex justify-end xs:px-16"
318
+ }, Ye = {
319
+ class: "pb-64 sm:hidden md:hidden lg:hidden"
320
+ }, Ze = {
321
+ class: "space-y-4"
322
+ }, es = {
323
+ class: "fm-typo-en-body-lg-600"
324
+ }, ss = {
325
+ class: "text-fm-color-typo-secondary"
326
+ }, as = {
327
+ class: "flex"
328
+ }, ls = {
329
+ class: "flex"
330
+ }, gs = /* @__PURE__ */ ge({
331
+ __name: "RoleList",
332
+ setup(j, {
333
+ expose: G
334
+ }) {
335
+ const {
336
+ t: s
337
+ } = ye(), {
338
+ allReportPermissions: R
339
+ } = Fe(), T = me(), E = _(() => T.restaurants.value), J = _(() => E.value.map((l) => l._id));
340
+ function M(l, r) {
341
+ const c = r === L.F_RULE_SUBJECT.enum.report ? R.value : void 0, i = ae(l, r, c);
342
+ return ["-", "All"].includes(i) ? () => null : () => S(ue.FmTooltip, {
343
+ "z-index": "999",
344
+ placement: "top",
345
+ class: "ml-2"
346
+ }, {
347
+ content: () => S("div", [s("hr.role.tooltip.labels.permission"), ...l.filter((h) => h.subject === r).map((h) => S("div", ["- ", W(h).label]))]),
348
+ default: () => S(ue.FmIcon, {
349
+ name: "info",
350
+ color: Ie.NeutralGray400
351
+ })
352
+ });
353
+ }
354
+ function H(l, r) {
355
+ const c = r === L.F_RULE_SUBJECT.enum.report ? R.value : void 0, i = ae(l, r, c);
356
+ return () => i === "All" ? i : S("div", {
357
+ class: "flex items-center"
358
+ }, [i, M(l, r)()]);
359
+ }
360
+ function Q(l) {
361
+ return [{
362
+ label: s("hr.role.form.update"),
363
+ onClick: () => B(l)
364
+ }, {
365
+ label: s("hr.role.remove.title"),
366
+ onClick: () => U(l),
367
+ itemClass: "text-fm-color-typo-error",
368
+ disabled: Re(l.permissions)
369
+ }];
370
+ }
371
+ const X = ({
372
+ role: l,
373
+ className: r = ""
374
+ }) => m("div", {
375
+ class: r,
376
+ onClick: (c) => {
377
+ c.stopPropagation();
378
+ }
379
+ }, [m(he, {
380
+ items: Q(l)
381
+ }, null)]), oe = [{
382
+ accessorKey: "name",
383
+ header: () => s("hr.role.columns.name"),
384
+ enableSorting: !1
385
+ }, {
386
+ accessorKey: "operation",
387
+ header: () => s("hr.role.columns.operation"),
388
+ cell: (l) => S(H(l.row.original.permissions, L.F_RULE_SUBJECT.enum.order)),
389
+ enableSorting: !1
390
+ }, {
391
+ accessorKey: "report",
392
+ header: () => s("hr.role.columns.report"),
393
+ cell: (l) => S(H(l.row.original.permissions, L.F_RULE_SUBJECT.enum.report)),
394
+ enableSorting: !1
395
+ }, {
396
+ accessorKey: "restaurants",
397
+ header: () => s("hr.role.columns.restaurants"),
398
+ cell: (l) => l.row.original.restaurants.map((r, c) => {
399
+ const i = r.code, h = `${i ? i + " - " : ""}${r.name}`;
400
+ return S("div", (c ? `
401
+ ` : "") + h);
402
+ }),
403
+ enableSorting: !1
404
+ }, {
405
+ id: "action",
406
+ size: 52,
407
+ meta: {
408
+ cellClass: "pl-16",
409
+ headerContentClass: "-mx-16"
410
+ },
411
+ cell: (l) => X({
412
+ role: l.row.original,
413
+ className: "flex w-full items-center justify-end"
414
+ })
415
+ }], B = async (l) => {
416
+ var r;
417
+ g.value = l._id, await fe(), (r = z.value) == null || r.trigger();
418
+ }, C = Ce(), F = Ne(), re = _(() => {
419
+ const l = C.roles.value || [];
420
+ return (J.value.length === 0 ? l : l.filter((c) => c.restaurants.some((i) => J.value.includes(i.id)))).map((c) => {
421
+ const i = c.restaurants.map((h) => {
422
+ const y = F.value[h.id];
423
+ return {
424
+ ...h,
425
+ // Prefer live data from restaurantMap so names populate reactively
426
+ // even when restaurants loaded after roles.
427
+ name: (y == null ? void 0 : y.profile.name) || h.name,
428
+ code: y == null ? void 0 : y.profile.code
429
+ };
430
+ });
431
+ return {
432
+ ...c,
433
+ restaurants: i
434
+ };
435
+ });
436
+ }), q = _(() => {
437
+ var r;
438
+ return (r = re.value) == null ? void 0 : r.filter((c) => {
439
+ const i = t.value.toLowerCase(), h = c.name.toLowerCase().includes(i), f = (c.restaurants || []).some((V) => {
440
+ var e;
441
+ return V.name.toLowerCase().includes(i) || ((e = V.code) == null ? void 0 : e.toLowerCase().includes(i));
442
+ });
443
+ return h || f;
444
+ });
445
+ }), Y = Ee(), O = xe(), {
446
+ breakpoints: v
447
+ } = Ue(), U = (l) => {
448
+ Y.open({
449
+ title: s("hr.role.remove.title"),
450
+ message: s("hr.role.remove.message", {
451
+ name: l.name
452
+ }),
453
+ minWidth: v.value.lg ? 588 : 0,
454
+ primaryActions: {
455
+ text: s("common.remove"),
456
+ close: !1,
457
+ variant: "destructive"
458
+ },
459
+ secondaryActions: {
460
+ text: s("common.cancel"),
461
+ close: !0
462
+ }
463
+ }).onPrimary(async () => {
464
+ await C.deleteRole(l).then(() => O.open({
465
+ message: s("hr.role.remove.successMessage", {
466
+ name: l.name
467
+ }),
468
+ type: "success"
469
+ })).catch((r) => O.open({
470
+ message: r,
471
+ type: "error"
472
+ })), Y.close();
473
+ });
474
+ }, t = $(""), z = $(), g = $(void 0);
475
+ async function Z() {
476
+ var l;
477
+ g.value = void 0, await fe(), (l = z.value) == null || l.trigger();
478
+ }
479
+ async function ne() {
480
+ if (C.roles.value.length === 0)
481
+ try {
482
+ await C.readRoles();
483
+ } catch (l) {
484
+ console.error("Failed to load roles:", l), O.open({
485
+ message: l instanceof Error ? l.message : String(l),
486
+ type: "error"
487
+ });
488
+ }
489
+ }
490
+ return be(() => {
491
+ ne();
492
+ }), G({
493
+ create: Z
494
+ }), (l, r) => {
495
+ const c = x("FmSearch"), i = x("FmTable"), h = x("FmListItem"), y = x("FmList");
496
+ return d(), k(D, null, [(d(), P(He, {
497
+ id: g.value,
498
+ key: g.value,
499
+ ref_key: "roleFormRef",
500
+ ref: z
501
+ }, null, 8, ["id"])), p("div", Qe, [p("div", Xe, [m(c, {
502
+ modelValue: t.value,
503
+ "onUpdate:modelValue": r[0] || (r[0] = (f) => t.value = f),
504
+ class: "w-[320px] xs:w-full",
505
+ autofocus: "",
506
+ placeholder: o(s)("hr.role.search.placeholder") + " / " + o(s)("hr.restaurant.search.placeholder")
507
+ }, null, 8, ["modelValue", "placeholder"])]), o(C).roles.value.length > 0 || o(C).isLoading.value ? (d(), P(Se, {
508
+ key: 0,
509
+ class: "overflow-auto"
510
+ }, {
511
+ default: b(() => [m(i, {
512
+ class: "xs:hidden",
513
+ "column-defs": oe,
514
+ "row-data": q.value,
515
+ "page-size": q.value.length,
516
+ loading: o(C).isLoading.value,
517
+ "pin-header-row": "",
518
+ "hide-footer": "",
519
+ "shrink-at": !1,
520
+ onRowClick: r[1] || (r[1] = (f) => B(f.original))
521
+ }, null, 8, ["row-data", "page-size", "loading"]), p("div", Ye, [m(y, {
522
+ separator: ""
523
+ }, {
524
+ default: b(() => [(d(!0), k(D, null, te(q.value, (f) => (d(), P(h, {
525
+ key: f._id,
526
+ class: "py-12 px-16 items-center justify-between",
527
+ onClick: (V) => B(f)
528
+ }, {
529
+ default: b(() => [p("div", Ze, [p("p", es, N(f.name), 1), p("div", ss, [p("p", null, N(o(s)("hr.role.labels.restaurantList", {
530
+ items: f.restaurants.map((V) => V.name).join(", ")
531
+ })), 1), p("p", as, [pe(N(o(s)("hr.role.labels.operationList", {
532
+ items: o(ae)(f.permissions, o(L.F_RULE_SUBJECT).enum.order)
533
+ })) + " ", 1), (d(), P(ve(M(f.permissions, o(L.F_RULE_SUBJECT).enum.order))))]), p("p", ls, [pe(N(o(s)("hr.role.labels.reportList", {
534
+ items: o(ae)(f.permissions, o(L.F_RULE_SUBJECT).enum.report, o(R))
535
+ })) + " ", 1), (d(), P(ve(M(f.permissions, o(L.F_RULE_SUBJECT).enum.report))))])])]), p("div", {
536
+ onClick: r[2] || (r[2] = Le(() => {
537
+ }, ["stop"]))
538
+ }, [m(he, {
539
+ items: Q(f)
540
+ }, null, 8, ["items"])])]),
541
+ _: 2
542
+ }, 1032, ["onClick"]))), 128))]),
543
+ _: 1
544
+ })])]),
545
+ _: 1
546
+ })) : (d(), P(o($e), {
547
+ key: 1,
548
+ title: o(s)("hr.role.noData.title"),
549
+ subtitle: o(s)("hr.role.noData.subtitle")
550
+ }, null, 8, ["title", "subtitle"]))])], 64);
551
+ };
552
+ }
553
+ });
554
+ export {
555
+ gs as default
556
+ };