@feedmepos/mf-hrm-portal 2.0.25 → 2.1.0-dev

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 (55) hide show
  1. package/dist/AuditLogList-C1bGND8z.js +1037 -0
  2. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-tiuei7CA.js +383 -0
  3. package/dist/{EmployeeList-aRGYYmxf.js → EmployeeList-DqQF9xEx.js} +78 -78
  4. package/dist/{FormItem.vue_vue_type_script_setup_true_lang-DPT2FoIc.js → FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js} +1 -1
  5. package/dist/{Main-C6YMg19H.js → Main-BgOhmojO.js} +6 -6
  6. package/dist/{Main-CyqPnLTe.js → Main-D2Wf__wM.js} +1138 -1142
  7. package/dist/Main-DcKVuIjB.js +90 -0
  8. package/dist/PermissionSetList-CQpTa0eY.js +384 -0
  9. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CCKVpAwv.js +4030 -0
  10. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-DWeS7VXx.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-D-14ca2J.js} +1 -1
  11. package/dist/RoleList-tSC8RJHe.js +674 -0
  12. package/dist/SelectFilter-DUj7GBtT.js +251 -0
  13. package/dist/TeamMemberList-Bz-kDJ0e.js +1163 -0
  14. package/dist/{TimesheetList-DzeE73Ns.js → TimesheetList-BFVhmcRt.js} +10 -10
  15. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-CTQs7MIl.js → TimesheetList.vue_vue_type_style_index_0_scoped_d7ed31d7_lang-CtHuL5tW.js} +2 -2
  16. package/dist/{app-Df4eEEIU.js → app-DRnSocX8.js} +5052 -2394
  17. package/dist/app.js +1 -1
  18. package/dist/{dayjs.min-DmGoh5hw.js → dayjs.min-B8xOAypU.js} +1 -1
  19. package/dist/{employee-zWTRoOkw.js → employee-UrXqUaik.js} +3 -3
  20. package/dist/{iteration-DTV3udF0.js → iteration-LEYoQKiI.js} +3 -3
  21. package/dist/{lodash-LInzVEDS.js → lodash-Bq6_eZZ0.js} +1 -1
  22. package/dist/rule-CJC6Cq6S.js +1047 -0
  23. package/dist/src/api/audit-log/index.d.ts +0 -17
  24. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  25. package/dist/src/components/form/SelectFilter.vue.d.ts +0 -3
  26. package/dist/src/composables/useBasePermission.d.ts +1 -0
  27. package/dist/src/composables/useConditionDraft.d.ts +40 -0
  28. package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
  29. package/dist/src/helpers/business-timezone.d.ts +22 -0
  30. package/dist/src/helpers/permission-set.d.ts +4 -2
  31. package/dist/src/helpers/rule.d.ts +2 -1
  32. package/dist/src/stores/team.d.ts +1 -4
  33. package/dist/src/views/audit-log/locales/index.d.ts +16 -24
  34. package/dist/src/views/hr/locales/index.d.ts +0 -4
  35. package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
  36. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
  37. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
  38. package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
  39. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
  40. package/dist/src/views/team/locales/index.d.ts +68 -4
  41. package/dist/style.css +1 -1
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/{useAppStore-BlQSL2ZO.js → useAppStore-BGsfYWAR.js} +1 -1
  44. package/dist/{useLoading-NkUvAr71.js → useLoading-BUM5R2qV.js} +1 -1
  45. package/dist/{useReportPermissions-R-eg1L2r.js → useReportPermissions-nlQ_BBL2.js} +3 -3
  46. package/package.json +2 -2
  47. package/dist/AuditLogList-BWwgm5wH.js +0 -1145
  48. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
  49. package/dist/Main-DQg87aB2.js +0 -94
  50. package/dist/PermissionSetList-BfKgFFUh.js +0 -356
  51. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CNEAlTnY.js +0 -3457
  52. package/dist/RoleList-CtcVwAPE.js +0 -566
  53. package/dist/SelectFilter-ATOm0hdn.js +0 -269
  54. package/dist/TeamMemberList-DU1jYeql.js +0 -1130
  55. package/dist/rule-O-E9JWJz.js +0 -995
@@ -0,0 +1,674 @@
1
+ import { computed as R, defineComponent as we, ref as $, watch as oe, onMounted as ke, resolveComponent as F, createBlock as L, openBlock as u, unref as o, withCtx as C, createElementVNode as c, createVNode as i, createElementBlock as x, Fragment as E, createCommentVNode as re, renderList as Q, toDisplayString as j, normalizeClass as ze, h as B, createTextVNode as ye, resolveDynamicComponent as xe, withModifiers as Ke, nextTick as Ce } from "vue";
2
+ import { u as ve, e as D } from "./iteration-LEYoQKiI.js";
3
+ import { useI18n as Ve } from "@feedmepos/mf-common";
4
+ import { useSnackbar as Se, components as fe, 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-DRnSocX8.js";
6
+ import { u as Qe, _ as Fe } from "./useDiscardConfirm-DPhEV6v0.js";
7
+ import { _ as Xe } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
8
+ import { e as Ye, r as q, h as Ue, f as Ze, g as Re, a as es, b as ne } from "./rule-CJC6Cq6S.js";
9
+ import { u as Ee } from "./useAppStore-BGsfYWAR.js";
10
+ import { u as Le } from "./useReportPermissions-nlQ_BBL2.js";
11
+ import { l as ie } from "./lodash-Bq6_eZZ0.js";
12
+ import { u as ss, _ as ts, a as as } from "./ConditionFormHost.vue_vue_type_script_setup_true_lang-tiuei7CA.js";
13
+ import { _ as pe } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
14
+ import { u as ls } from "./useLoading-BUM5R2qV.js";
15
+ function os() {
16
+ const X = ve();
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]" }, hs = { class: "fm-typo-en-title-sm-600" }, _s = {
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 = ve(), A = $(""), 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
+ })), W = $(V.restaurants.value.length === 0);
46
+ oe(
47
+ () => V.restaurants.value.length,
48
+ (e) => {
49
+ e > 0 && (W.value = !1);
50
+ }
51
+ );
52
+ const z = Ee(), Z = Se(), ee = ls(Z), { fetchReportPermissions: se, allReportPermissions: ue, availableReportKeys: K } = Le(), S = X, U = $(!1), ce = () => {
53
+ U.value = !U.value, U.value && h();
54
+ }, G = R(() => S.id ? t("hr.role.form.update") : t("hr.role.form.add")), te = R(() => S.id ? t("common.update") : t("common.add")), O = R(() => {
55
+ const e = Ye.filter(
56
+ (r) => r.subject !== D.F_RULE_SUBJECT.enum.report
57
+ ).map((r) => q(r)), s = ue.value.map((r) => q(r));
58
+ return [...e, ...s];
59
+ }), v = R(() => z.roles.value.find((e) => e._id == S.id)), P = () => ({
60
+ name: "",
61
+ restaurantIds: [],
62
+ permissions: [],
63
+ maxDiscountPercentage: 100
64
+ }), a = $(P()), b = $(/* @__PURE__ */ new Map()), w = ss(b), ae = qe("report");
65
+ function me(e) {
66
+ const s = b.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(b.value.get(e), s)
73
+ );
74
+ }
75
+ function n(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 J = w.getDraft({ subject: e, builderKey: I.builderKey });
83
+ J && r.push({ builder: I, form: J.formValue });
84
+ }
85
+ if (r.length === 0) return;
86
+ const k = b.value.get(e), T = Ge(
87
+ k,
88
+ r.map(({ builder: I, form: J }) => ({ builder: I, formValue: J }))
89
+ ), H = new Map(b.value);
90
+ Object.keys(T).length === 0 ? H.delete(e) : H.set(e, T), b.value = H, w.clearDraftsForSubject(e);
91
+ }
92
+ function p(e) {
93
+ return w.hasDraftsForSubject(e);
94
+ }
95
+ const y = 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: O.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 h() {
119
+ var e;
120
+ if (a.value = P(), b.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 = O.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) => q(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 = q(s), k = es(s);
128
+ k && b.value.set(r.value, k);
129
+ }
130
+ }
131
+ }
132
+ ke(async () => {
133
+ await V.readRestaurants(), await se(), h();
134
+ }), oe(U, async (e) => {
135
+ e && await se();
136
+ }), oe(K, () => {
137
+ if (U.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(b.value);
140
+ for (const s of e.keys())
141
+ s.startsWith("report:") && !a.value.permissions.includes(s) && e.delete(s);
142
+ b.value = e;
143
+ }
144
+ });
145
+ const N = $(""), 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
+ b.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
+ ), U.value = !1;
165
+ }, he = R(
166
+ () => a.value.restaurantIds.filter((e) => M.value.some((s) => s._id === e))
167
+ ), _e = R(() => M.value.length > 0 && M.value.length === he.value.length), De = () => {
168
+ const e = a.value.restaurantIds.filter((s) => !he.value.includes(s));
169
+ _e.value === !0 ? a.value.restaurantIds = e : a.value.restaurantIds = M.value.map((s) => s._id);
170
+ }, ge = (e) => e.map((r) => r.value).every((r) => a.value.permissions.includes(r)), $e = (e) => {
171
+ const s = a.value.permissions.filter(
172
+ (r) => !e.map((k) => k.value).includes(r)
173
+ );
174
+ ge(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) => q(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
+ U.value = !1;
198
+ }
199
+ );
200
+ return Y({
201
+ show: U,
202
+ trigger: ce
203
+ }), (e, s) => {
204
+ const r = F("FmIcon"), k = F("FmTextField"), T = F("FmCircularProgress"), H = F("FmSearch"), I = F("FmCheckbox"), J = F("FmFormGroup"), Me = F("FmButton"), Pe = F("FmMenu"), Te = F("FmCard"), be = F("fm-button"), Be = F("fm-side-sheet");
205
+ return u(), L(Be, {
206
+ id: "unit-form",
207
+ "model-value": U.value,
208
+ "is-container": o(fe).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": C(() => [
218
+ c("div", rs, [
219
+ c("p", ns, j(G.value), 1),
220
+ i(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": C(() => [
229
+ c("div", xs, [
230
+ i(be, {
231
+ label: te.value,
232
+ size: "lg",
233
+ type: "submit",
234
+ variant: "primary",
235
+ disabled: m.value
236
+ }, null, 8, ["label", "disabled"]),
237
+ i(be, {
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: C(() => [
246
+ c("div", is, [
247
+ i(pe, {
248
+ title: o(t)("hr.role.form.roleDetail")
249
+ }, {
250
+ default: C(() => [
251
+ i(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
+ i(pe, {
263
+ title: o(t)("hr.role.form.restaurant")
264
+ }, {
265
+ default: C(() => [
266
+ W.value ? (u(), x("div", us, [
267
+ i(T)
268
+ ])) : (u(), x(E, { key: 1 }, [
269
+ i(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
+ i(J, {
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: C(() => [
280
+ c("div", cs, [
281
+ A.value ? re("", !0) : (u(), x(E, { key: 0 }, [
282
+ i(I, {
283
+ "model-value": _e.value,
284
+ label: o(t)("hr.role.form.all"),
285
+ value: "1",
286
+ disabled: m.value,
287
+ "onUpdate:modelValue": De
288
+ }, null, 8, ["model-value", "label", "disabled"]),
289
+ s[6] || (s[6] = c("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1))
290
+ ], 64)),
291
+ (u(!0), x(E, null, Q(M.value, (d) => (u(), x("div", {
292
+ key: d._id
293
+ }, [
294
+ i(I, {
295
+ modelValue: a.value.restaurantIds,
296
+ "onUpdate:modelValue": s[2] || (s[2] = (_) => a.value.restaurantIds = _),
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
+ i(pe, {
311
+ title: o(t)("hr.role.form.permissions")
312
+ }, {
313
+ default: C(() => [
314
+ (u(!0), x(E, null, Q(y.value, (d) => (u(), L(Te, {
315
+ key: d.title,
316
+ variant: "outlined",
317
+ class: "p-16"
318
+ }, {
319
+ default: C(() => [
320
+ i(ts, null, {
321
+ title: C(() => [
322
+ c("p", ms, j(d.title), 1)
323
+ ]),
324
+ default: C(() => [
325
+ c("div", ds, [
326
+ i(I, {
327
+ "model-value": ge(d.options),
328
+ label: o(t)("hr.role.form.all"),
329
+ value: "1",
330
+ disabled: m.value,
331
+ "onUpdate:modelValue": (_) => $e(d.options)
332
+ }, null, 8, ["model-value", "label", "disabled", "onUpdate:modelValue"]),
333
+ s[7] || (s[7] = c("div", { class: "h-px w-full bg-fm-color-neutral-gray-200" }, null, -1)),
334
+ (u(!0), x(E, null, Q(d.options, (_) => (u(), x("div", {
335
+ key: _.value
336
+ }, [
337
+ c("div", ps, [
338
+ i(I, {
339
+ modelValue: a.value.permissions,
340
+ "onUpdate:modelValue": s[4] || (s[4] = (g) => a.value.permissions = g),
341
+ label: _.label,
342
+ value: _.value,
343
+ disabled: m.value,
344
+ class: "flex-1"
345
+ }, null, 8, ["modelValue", "label", "value", "disabled"]),
346
+ _.value.startsWith("report:") ? (u(), x(E, { key: 0 }, [
347
+ a.value.permissions.includes(_.value) ? (u(), L(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(_.value)
353
+ }, {
354
+ "menu-button": C(() => [
355
+ c("div", fs, [
356
+ i(r, {
357
+ name: "settings",
358
+ size: "sm",
359
+ class: ze([
360
+ "cursor-pointer transition-colors",
361
+ me(_.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: C(() => [
367
+ c("div", vs, [
368
+ c("p", hs, j(_.label), 1),
369
+ (u(!0), x(E, null, Q(o(ae), (g, je) => (u(), x(E, {
370
+ key: g.builderKey
371
+ }, [
372
+ je > 0 ? (u(), x("div", _s)) : re("", !0),
373
+ i(as, {
374
+ builder: g,
375
+ "model-value": l(_.value, g),
376
+ disable: m.value,
377
+ "onUpdate:modelValue": (Ae) => n(_.value, g, Ae)
378
+ }, null, 8, ["builder", "model-value", "disable", "onUpdate:modelValue"])
379
+ ], 64))), 128)),
380
+ c("div", gs, [
381
+ i(Me, {
382
+ label: o(t)("team.memberForm.permissions.conditionApply"),
383
+ size: "md",
384
+ variant: "primary",
385
+ disabled: m.value || !p(_.value),
386
+ onClick: (g) => f(_.value)
387
+ }, null, 8, ["label", "disabled", "onClick"])
388
+ ])
389
+ ])
390
+ ]),
391
+ _: 2
392
+ }, 1032, ["disabled", "onClose"])) : (u(), L(r, {
393
+ key: 1,
394
+ name: "settings",
395
+ size: "sm",
396
+ class: "invisible"
397
+ }))
398
+ ], 64)) : re("", !0)
399
+ ]),
400
+ _.value === "order:discount" && a.value.permissions.includes(_.value) ? (u(), x("div", bs, [
401
+ c("div", ys, j(o(t)("hr.role.form.maxDiscountPercentage")), 1),
402
+ i(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: "pb-64 sm:hidden md:hidden lg:hidden"
438
+ }, ks = {
439
+ class: "space-y-4"
440
+ }, Vs = {
441
+ class: "fm-typo-en-body-lg-600"
442
+ }, Ss = {
443
+ class: "text-fm-color-typo-secondary"
444
+ }, Us = {
445
+ class: "flex"
446
+ }, Es = {
447
+ class: "flex"
448
+ }, Js = /* @__PURE__ */ we({
449
+ __name: "RoleList",
450
+ setup(X, {
451
+ expose: Y
452
+ }) {
453
+ const {
454
+ t
455
+ } = Ve(), {
456
+ allReportPermissions: V
457
+ } = Le(), A = ve(), M = R(() => A.restaurants.value), W = R(() => M.value.map((l) => l._id));
458
+ function z(l, n) {
459
+ const f = n === D.F_RULE_SUBJECT.enum.report ? V.value : void 0, p = ne(l, n, f);
460
+ return ["-", "All"].includes(p) ? () => null : () => B(fe.FmTooltip, {
461
+ "z-index": "999",
462
+ placement: "top",
463
+ class: "ml-2"
464
+ }, {
465
+ content: () => B("div", [t("hr.role.tooltip.labels.permission"), ...l.filter((y) => y.subject === n).map((y) => B("div", ["- ", q(y).label]))]),
466
+ default: () => B(fe.FmIcon, {
467
+ name: "info",
468
+ color: Je.NeutralGray400
469
+ })
470
+ });
471
+ }
472
+ function Z(l, n) {
473
+ const f = n === D.F_RULE_SUBJECT.enum.report ? V.value : void 0, p = ne(l, n, f);
474
+ return () => p === "All" ? p : B("div", {
475
+ class: "flex items-center"
476
+ }, [p, z(l, n)()]);
477
+ }
478
+ function ee(l) {
479
+ return [{
480
+ label: t("hr.role.form.update"),
481
+ onClick: () => K(l)
482
+ }, {
483
+ label: t("hr.role.remove.title"),
484
+ onClick: () => P(l),
485
+ itemClass: "text-fm-color-typo-error",
486
+ disabled: Ue(l.permissions)
487
+ }];
488
+ }
489
+ const se = ({
490
+ role: l,
491
+ className: n = ""
492
+ }) => i("div", {
493
+ class: n,
494
+ onClick: (f) => {
495
+ f.stopPropagation();
496
+ }
497
+ }, [i(Fe, {
498
+ items: ee(l)
499
+ }, null)]), ue = [{
500
+ accessorKey: "name",
501
+ header: () => t("hr.role.columns.name"),
502
+ enableSorting: !1
503
+ }, {
504
+ accessorKey: "operation",
505
+ header: () => t("hr.role.columns.operation"),
506
+ cell: (l) => B(Z(l.row.original.permissions, D.F_RULE_SUBJECT.enum.order)),
507
+ enableSorting: !1
508
+ }, {
509
+ accessorKey: "report",
510
+ header: () => t("hr.role.columns.report"),
511
+ cell: (l) => B(Z(l.row.original.permissions, D.F_RULE_SUBJECT.enum.report)),
512
+ enableSorting: !1
513
+ }, {
514
+ accessorKey: "restaurants",
515
+ header: () => t("hr.role.columns.restaurants"),
516
+ cell: (l) => l.row.original.restaurants.map((n, f) => {
517
+ const p = n.code, y = `${p ? p + " - " : ""}${n.name}`;
518
+ return B("div", (f ? `
519
+ ` : "") + y);
520
+ }),
521
+ enableSorting: !1
522
+ }, {
523
+ id: "action",
524
+ size: 52,
525
+ meta: {
526
+ cellClass: "pl-16",
527
+ headerContentClass: "-mx-16"
528
+ },
529
+ cell: (l) => se({
530
+ role: l.row.original,
531
+ className: "flex w-full items-center justify-end"
532
+ })
533
+ }], K = async (l) => {
534
+ var n;
535
+ w.value = l._id, await Ce(), (n = b.value) == null || n.trigger();
536
+ }, S = Ee(), U = os(), ce = R(() => {
537
+ const l = S.roles.value || [];
538
+ return (W.value.length === 0 ? l : l.filter((f) => f.restaurants.some((p) => W.value.includes(p.id)))).map((f) => {
539
+ const p = f.restaurants.map((y) => {
540
+ const m = U.value[y.id];
541
+ return {
542
+ ...y,
543
+ // Prefer live data from restaurantMap so names populate reactively
544
+ // even when restaurants loaded after roles.
545
+ name: (m == null ? void 0 : m.profile.name) || y.name,
546
+ code: m == null ? void 0 : m.profile.code
547
+ };
548
+ });
549
+ return {
550
+ ...f,
551
+ restaurants: p
552
+ };
553
+ });
554
+ }), G = R(() => {
555
+ var n;
556
+ return (n = ce.value) == null ? void 0 : n.filter((f) => {
557
+ const p = a.value.toLowerCase(), y = f.name.toLowerCase().includes(p), h = (f.restaurants || []).some((N) => {
558
+ var le;
559
+ return N.name.toLowerCase().includes(p) || ((le = N.code) == null ? void 0 : le.toLowerCase().includes(p));
560
+ });
561
+ return y || h;
562
+ });
563
+ }), te = Ne(), O = Se(), {
564
+ breakpoints: v
565
+ } = Oe(), P = (l) => {
566
+ te.open({
567
+ title: t("hr.role.remove.title"),
568
+ message: t("hr.role.remove.message", {
569
+ name: l.name
570
+ }),
571
+ minWidth: v.value.lg ? 588 : 0,
572
+ primaryActions: {
573
+ text: t("common.remove"),
574
+ close: !1,
575
+ variant: "destructive"
576
+ },
577
+ secondaryActions: {
578
+ text: t("common.cancel"),
579
+ close: !0
580
+ }
581
+ }).onPrimary(async () => {
582
+ await S.deleteRole(l).then(() => O.open({
583
+ message: t("hr.role.remove.successMessage", {
584
+ name: l.name
585
+ }),
586
+ type: "success"
587
+ })).catch((n) => O.open({
588
+ message: n,
589
+ type: "error"
590
+ })), te.close();
591
+ });
592
+ }, a = $(""), b = $(), w = $(void 0);
593
+ async function ae() {
594
+ var l;
595
+ w.value = void 0, await Ce(), (l = b.value) == null || l.trigger();
596
+ }
597
+ async function me() {
598
+ if (S.roles.value.length === 0)
599
+ try {
600
+ await S.readRoles();
601
+ } catch (l) {
602
+ console.error("Failed to load roles:", l), O.open({
603
+ message: l instanceof Error ? l.message : String(l),
604
+ type: "error"
605
+ });
606
+ }
607
+ }
608
+ return ke(() => {
609
+ me();
610
+ }), Y({
611
+ create: ae
612
+ }), (l, n) => {
613
+ const f = F("FmSearch"), p = F("FmTable"), y = F("FmListItem"), m = F("FmList");
614
+ return u(), x(E, null, [(u(), L(Cs, {
615
+ id: w.value,
616
+ key: w.value,
617
+ ref_key: "roleFormRef",
618
+ ref: b
619
+ }, null, 8, ["id"])), c("div", Fs, [c("div", Rs, [i(f, {
620
+ modelValue: a.value,
621
+ "onUpdate:modelValue": n[0] || (n[0] = (h) => a.value = h),
622
+ class: "w-[320px] xs:w-full",
623
+ autofocus: "",
624
+ placeholder: o(t)("hr.role.search.placeholder") + " / " + o(t)("hr.restaurant.search.placeholder")
625
+ }, null, 8, ["modelValue", "placeholder"])]), o(S).roles.value.length > 0 || o(S).isLoading.value ? (u(), L(He, {
626
+ key: 0,
627
+ class: "overflow-auto"
628
+ }, {
629
+ default: C(() => [i(p, {
630
+ class: "xs:hidden",
631
+ "column-defs": ue,
632
+ "row-data": G.value,
633
+ "page-size": G.value.length,
634
+ loading: o(S).isLoading.value,
635
+ "pin-header-row": "",
636
+ "hide-footer": "",
637
+ "shrink-at": !1,
638
+ onRowClick: n[1] || (n[1] = (h) => K(h.original))
639
+ }, null, 8, ["row-data", "page-size", "loading"]), c("div", ws, [i(m, {
640
+ separator: ""
641
+ }, {
642
+ default: C(() => [(u(!0), x(E, null, Q(G.value, (h) => (u(), L(y, {
643
+ key: h._id,
644
+ class: "py-12 px-16 items-center justify-between",
645
+ onClick: (N) => K(h)
646
+ }, {
647
+ default: C(() => [c("div", ks, [c("p", Vs, j(h.name), 1), c("div", Ss, [c("p", null, j(o(t)("hr.role.labels.restaurantList", {
648
+ items: h.restaurants.map((N) => N.name).join(", ")
649
+ })), 1), c("p", Us, [ye(j(o(t)("hr.role.labels.operationList", {
650
+ items: o(ne)(h.permissions, o(D.F_RULE_SUBJECT).enum.order)
651
+ })) + " ", 1), (u(), L(xe(z(h.permissions, o(D.F_RULE_SUBJECT).enum.order))))]), c("p", Es, [ye(j(o(t)("hr.role.labels.reportList", {
652
+ items: o(ne)(h.permissions, o(D.F_RULE_SUBJECT).enum.report, o(V))
653
+ })) + " ", 1), (u(), L(xe(z(h.permissions, o(D.F_RULE_SUBJECT).enum.report))))])])]), c("div", {
654
+ onClick: n[2] || (n[2] = Ke(() => {
655
+ }, ["stop"]))
656
+ }, [i(Fe, {
657
+ items: ee(h)
658
+ }, null, 8, ["items"])])]),
659
+ _: 2
660
+ }, 1032, ["onClick"]))), 128))]),
661
+ _: 1
662
+ })])]),
663
+ _: 1
664
+ })) : (u(), L(o(Xe), {
665
+ key: 1,
666
+ title: o(t)("hr.role.noData.title"),
667
+ subtitle: o(t)("hr.role.noData.subtitle")
668
+ }, null, 8, ["title", "subtitle"]))])], 64);
669
+ };
670
+ }
671
+ });
672
+ export {
673
+ Js as default
674
+ };