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