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