@feedmepos/mf-hrm-portal 2.0.17-dev.2 → 2.0.17-dev.4

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