@feedmepos/mf-hrm-portal 2.0.19-dev.1 → 2.0.20-dev.1

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