@feedmepos/mf-hrm-portal 2.1.1-dev.3 → 2.1.1-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 (73) hide show
  1. package/dist/ApprovalCodeList-B0PLZwav.js +758 -0
  2. package/dist/AuditLogList-CRXwPImZ.js +1611 -0
  3. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-zJwkM_Xb.js +387 -0
  4. package/dist/EmployeeList-DN2pnXcS.js +884 -0
  5. package/dist/GrantUserList-DoyxknJZ.js +464 -0
  6. package/dist/{Main-cskEZ3k_.js → Main-B5BKGpLg.js} +1033 -1029
  7. package/dist/Main-BGONIxo8.js +122 -0
  8. package/dist/{Main-DLlpEU3j.js → Main-DQj4xtkB.js} +7 -7
  9. package/dist/PermissionSetList-4uIU9FvN.js +393 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D0luaKDb.js +4122 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BJp9hEfv.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js} +1 -0
  12. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-QrqYEy8i.js +42 -0
  13. package/dist/RoleList-Bj5Y5jd_.js +685 -0
  14. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +16 -0
  15. package/dist/TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js +37 -0
  16. package/dist/TeamMemberList-Byjlca2Y.js +1216 -0
  17. package/dist/{TimesheetList-B1H_6zfP.js → TimesheetList-DwIcsOM-.js} +118 -112
  18. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-DeTpbaRk.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-B9qlQ6KG.js} +2 -2
  19. package/dist/{app-DX-PG6wx.js → app-BZwE2coe.js} +5407 -2374
  20. package/dist/app.js +1 -1
  21. package/dist/{dayjs.min-BJrHE7oz.js → dayjs.min-BXBPls4m.js} +1 -1
  22. package/dist/{employee-BJcqtqLM.js → employee-CJTbs1f7.js} +3 -3
  23. package/dist/{iteration-Cfaqt-0s.js → iteration-BCbIbdHR.js} +1 -1
  24. package/dist/{lodash-ClKqCmlZ.js → lodash-CUIS1iIz.js} +1 -1
  25. package/dist/{role-CR_-nBDY.js → role-CzXchcSS.js} +1 -1
  26. package/dist/rule-BO6xj2Xa.js +1058 -0
  27. package/dist/src/api/audit-log/index.d.ts +6 -0
  28. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  29. package/dist/src/components/button/ResponsiveFabButton.vue.d.ts +7 -1
  30. package/dist/src/components/table/TableEmptyState.vue.d.ts +7 -15
  31. package/dist/src/composables/useBasePermission.d.ts +2 -1
  32. package/dist/src/composables/useConditionDraft.d.ts +40 -0
  33. package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
  34. package/dist/src/helpers/business-timezone.d.ts +22 -0
  35. package/dist/src/helpers/filter.d.ts +15 -0
  36. package/dist/src/helpers/permission-reconcile.d.ts +15 -0
  37. package/dist/src/helpers/permission-reconcile.test.d.ts +1 -0
  38. package/dist/src/helpers/permission-set.d.ts +8 -4
  39. package/dist/src/helpers/rule.d.ts +2 -1
  40. package/dist/src/stores/permission-set.d.ts +12 -3
  41. package/dist/src/types/approval-code.d.ts +22 -7
  42. package/dist/src/types/audit-log.d.ts +1 -1
  43. package/dist/src/views/approval-code/components/ApprovalCodeCreatedDialog.vue.d.ts +9 -0
  44. package/dist/src/views/approval-code/components/ApprovalCodeForm.vue.d.ts +6 -1
  45. package/dist/src/views/approval-code/locales/index.d.ts +40 -0
  46. package/dist/src/views/audit-log/event-line.d.ts +13 -0
  47. package/dist/src/views/audit-log/locales/index.d.ts +296 -0
  48. package/dist/src/views/audit-log/snapshot-diff.d.ts +11 -0
  49. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +1 -0
  50. package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
  51. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
  52. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
  53. package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
  54. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
  55. package/dist/src/views/team/locales/index.d.ts +80 -0
  56. package/dist/style.css +1 -1
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/useDebounce-B8ZPVS5C.js +15 -0
  59. package/dist/{useReportPermissions-ybHA26cJ.js → useReportPermissions-Q-xLwz5N.js} +3 -3
  60. package/package.json +2 -2
  61. package/dist/ApprovalCodeList-BH5sgVMU.js +0 -638
  62. package/dist/AuditLogList-Q4L5Te8O.js +0 -1145
  63. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
  64. package/dist/EmployeeList-GtKmJZbf.js +0 -899
  65. package/dist/GrantUserList-CnLjOi5_.js +0 -468
  66. package/dist/Main-Cn7Dawg4.js +0 -120
  67. package/dist/PermissionSetList-C2fK2pTz.js +0 -357
  68. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CMh0DL1_.js +0 -3458
  69. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +0 -38
  70. package/dist/RoleList-CcuT1ERb.js +0 -567
  71. package/dist/TeamMemberList-Dfs2iNdC.js +0 -1131
  72. package/dist/rule-BB-3S-2R.js +0 -996
  73. package/dist/useDebounce-CWb5QR9G.js +0 -28
@@ -1,899 +0,0 @@
1
- import { defineComponent as Ee, computed as b, createElementBlock as C, openBlock as v, Fragment as le, createBlock as j, createCommentVNode as N, createElementVNode as m, unref as o, normalizeClass as ke, renderSlot as Pe, createVNode as i, toRaw as He, ref as y, watch as te, resolveComponent as _, withCtx as w, toDisplayString as z, renderList as De, withKeys as Se, withModifiers as ae, onUnmounted as Je, isRef as Ve, createTextVNode as we, h as me } from "vue";
2
- import { useI18n as Be, useCoreStore as We } from "@feedmepos/mf-common";
3
- import { useBreakpoints as Te, useSnackbar as Ne, components as ze, useDialog as Qe } from "@feedmepos/ui-library";
4
- import { S as pe, _ as Ye } from "./SelectFilter-ATOm0hdn.js";
5
- import { _ as Ze, a as Xe } from "./app-DX-PG6wx.js";
6
- import { _ as Ce, u as et, H as tt } from "./FormItem.vue_vue_type_script_setup_true_lang-DPT2FoIc.js";
7
- import { u as at, _ as lt } from "./useDiscardConfirm-DPhEV6v0.js";
8
- import { _ as Re } from "./index.vue_vue_type_script_setup_true_lang-BVVwfd7B.js";
9
- import { u as st, _ as $e } from "./useDebounce-CWb5QR9G.js";
10
- import { u as Oe, E as ot } from "./employee-BJcqtqLM.js";
11
- import { u as Ke } from "./restaurant-YOVMuuFY.js";
12
- import { l as rt } from "./lodash-ClKqCmlZ.js";
13
- import { _ as Ue } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
14
- import { u as je } from "./useLoading-BH02lYns.js";
15
- import { u as xe } from "./role-CR_-nBDY.js";
16
- /* empty css */
17
- const nt = {
18
- key: 0,
19
- class: "pointer-events-none absolute inset-0 flex items-center justify-center"
20
- }, it = /* @__PURE__ */ Ee({
21
- __name: "TableEmptyState",
22
- props: {
23
- title: {},
24
- subtitle: {},
25
- isEmpty: { type: Boolean },
26
- isLoading: { type: Boolean, default: !1 },
27
- collapseAt: { type: [String, Boolean], default: "sm" },
28
- hideTableBelow: { type: [String, Boolean], default: "xs" }
29
- },
30
- setup(x) {
31
- const R = x, { isAtMost: n } = Te(), g = b(() => R.collapseAt !== !1 && n(R.collapseAt)), f = b(
32
- () => R.hideTableBelow !== !1 && n(R.hideTableBelow)
33
- ), k = b(() => R.isEmpty && !R.isLoading);
34
- return (X, L) => (v(), C(le, null, [
35
- k.value && g.value ? (v(), j(o(Re), {
36
- key: 0,
37
- title: x.title,
38
- subtitle: x.subtitle
39
- }, null, 8, ["title", "subtitle"])) : N("", !0),
40
- m("div", {
41
- class: ke(["relative min-h-0 flex-1", { hidden: f.value }])
42
- }, [
43
- Pe(X.$slots, "default", { isTableCollapsed: g.value }),
44
- k.value && !g.value ? (v(), C("div", nt, [
45
- i(o(Re), {
46
- class: "pointer-events-auto",
47
- "is-outlined": !1,
48
- title: x.title,
49
- subtitle: x.subtitle
50
- }, null, 8, ["title", "subtitle"])
51
- ])) : N("", !0)
52
- ], 2)
53
- ], 64));
54
- }
55
- });
56
- function Me(x) {
57
- return JSON.parse(JSON.stringify(x));
58
- }
59
- function Le(x) {
60
- if (typeof structuredClone > "u")
61
- return Me(x);
62
- try {
63
- return structuredClone(He(x));
64
- } catch {
65
- return Me(x);
66
- }
67
- }
68
- const ut = { class: "flex w-full items-center justify-between" }, dt = { class: "fm-typo-en-title-md-600" }, ct = { class: "space-y-40" }, mt = { class: "flex flex-row gap-16" }, pt = { class: "space-y-16" }, ft = { class: "rounded-lg border border-fm-color-neutral-gray-200 p-16 space-y-16" }, vt = { class: "fm-typo-en-title-sm-600" }, yt = { class: "space-y-16" }, ht = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, gt = { class: "text-sm font-semibold text-fm-color-typo-primary" }, _t = { class: "text-sm font-semibold text-fm-color-typo-primary" }, bt = { class: "flex justify-self-end" }, wt = ["tabindex", "aria-disabled", "aria-label", "onClick", "onKeydown"], xt = { class: "flex gap-8 items-center justify-start" }, Ae = 4, Et = /* @__PURE__ */ Ee({
69
- __name: "EmployeeForm",
70
- props: {
71
- roleErrorMessage: {
72
- type: String,
73
- default: ""
74
- }
75
- },
76
- emits: ["submitted"],
77
- setup(x, { expose: R, emit: n }) {
78
- const g = xe(), f = Ke(), k = Oe(), X = Ne(), L = je(X), fe = n, { t: d } = Be(), A = y(!1), O = y(!0);
79
- function G() {
80
- return {
81
- restaurantId: "",
82
- roleId: ""
83
- };
84
- }
85
- function ve(r) {
86
- if (!r) return I();
87
- const a = Le(r);
88
- return {
89
- code: a.code ?? "",
90
- isMasterUser: a.isMasterUser ?? !1,
91
- name: a.name ?? "",
92
- passcode: a.passcode ?? "",
93
- restaurants: a.restaurants.length > 0 ? a.restaurants.map(({ restaurantId: c, roleId: h }) => ({
94
- restaurantId: c,
95
- roleId: h
96
- })) : [G()]
97
- };
98
- }
99
- const se = (r) => {
100
- s.value = ve(r), V.value = Le(s.value), oe.value = r == null ? void 0 : r._id, U.value = [], s.value.passcode && (U.value = s.value.passcode.split(""), D.value = !0), O.value = !r, A.value = !0;
101
- };
102
- function I() {
103
- return {
104
- code: "",
105
- isMasterUser: !1,
106
- name: "",
107
- passcode: "",
108
- restaurants: [G()]
109
- };
110
- }
111
- const H = b(() => O.value ? d("hr.employee.form.add") : d("hr.employee.form.update")), J = b(() => O.value ? d("common.create") : d("common.update")), V = y(I()), s = y(I()), oe = y(void 0), q = b(
112
- () => s.value.restaurants.map((r) => r.restaurantId).filter(Boolean)
113
- );
114
- function $(r) {
115
- var a;
116
- return r ? !((a = f.restaurants.value.find((c) => c._id === r)) != null && a.managable) : !1;
117
- }
118
- function re(r = "") {
119
- return f.restaurants.value.filter((a) => a.managable || a._id === r).map((a) => ({
120
- label: `${a.profile.code ? `${a.profile.code} - ` : ""}${a.profile.name}`,
121
- value: a._id,
122
- disabled: q.value.includes(a._id) && a._id !== r
123
- }));
124
- }
125
- function ne(r, a = "") {
126
- return r ? g.roles.value.filter((c) => c.restaurants.some((h) => h.id == r)).map((c) => ({
127
- label: c.name,
128
- value: c._id,
129
- disabled: !c.isUsable && c._id !== a
130
- })) : [];
131
- }
132
- function ye(r, a) {
133
- var F, M, B;
134
- const c = ((F = s.value.restaurants[r]) == null ? void 0 : F.roleId) ?? "", h = ne(a, c), E = ((M = h.find((T) => T.value === c && !T.disabled)) == null ? void 0 : M.value) ?? ((B = h.find((T) => !T.disabled)) == null ? void 0 : B.value) ?? "";
135
- s.value.restaurants[r] = {
136
- restaurantId: a,
137
- roleId: E
138
- };
139
- }
140
- function he(r, a) {
141
- s.value.restaurants[r].roleId = a;
142
- }
143
- function ge() {
144
- s.value.restaurants = [
145
- ...s.value.restaurants,
146
- G()
147
- ];
148
- }
149
- function P(r) {
150
- var c;
151
- const a = ((c = s.value.restaurants[r]) == null ? void 0 : c.restaurantId) ?? "";
152
- if (!$(a)) {
153
- if (s.value.restaurants.length === 1) {
154
- s.value.restaurants = [G()];
155
- return;
156
- }
157
- s.value.restaurants = s.value.restaurants.filter(
158
- (h, E) => E !== r
159
- );
160
- }
161
- }
162
- const ie = b(() => {
163
- const r = f.restaurants.value.some(
164
- (c) => c.managable && !q.value.includes(c._id)
165
- ), a = s.value.restaurants.every(
166
- (c) => c.restaurantId && c.roleId
167
- );
168
- return r && a;
169
- }), U = y([]), D = y(!1);
170
- function W() {
171
- D.value && (D.value = !1, U.value = []);
172
- }
173
- const K = y(!1), Q = y(!1);
174
- async function ee() {
175
- Q.value = !0;
176
- try {
177
- const r = await ot.generateEmployeePasscode();
178
- D.value = !1, U.value = r.split("");
179
- } finally {
180
- Q.value = !1;
181
- }
182
- }
183
- const Y = at(
184
- () => !rt.isEqual(s.value, V.value),
185
- () => {
186
- A.value = !1;
187
- }
188
- );
189
- async function ue() {
190
- const r = {
191
- user: {
192
- name: s.value.name,
193
- passcode: s.value.passcode,
194
- code: s.value.code
195
- },
196
- roles: s.value.restaurants
197
- };
198
- s.value.isMasterUser ? await k.createMasterEmployee(r) : (delete r.user.code, await k.createEmployee(r));
199
- }
200
- async function de() {
201
- var h, E;
202
- const r = V.value, a = oe.value, c = {
203
- user: {
204
- name: s.value.name,
205
- passcode: s.value.passcode
206
- },
207
- roles: s.value.restaurants,
208
- previousRoles: (h = r.restaurants) == null ? void 0 : h.map((F) => ({
209
- restaurantId: F.restaurantId,
210
- roleId: F.roleId
211
- }))
212
- };
213
- if (!s.value.isMasterUser)
214
- await k.updateEmployee(a, c);
215
- else {
216
- const F = {
217
- user: {
218
- name: s.value.name,
219
- passcode: s.value.passcode,
220
- code: s.value.code
221
- },
222
- roles: s.value.restaurants,
223
- previousRoles: (E = r.restaurants) == null ? void 0 : E.map((M) => ({
224
- restaurantId: M.restaurantId,
225
- roleId: M.roleId
226
- }))
227
- };
228
- V.value.isMasterUser ? await k.updateMasterEmployee(a, F) : await k.migrateToMasterUser(a, F);
229
- }
230
- }
231
- async function _e() {
232
- O.value ? await L.minor(
233
- async () => {
234
- await ue();
235
- },
236
- {
237
- successMessage: d("hr.employee.create.successMessage"),
238
- isLoading: K
239
- }
240
- ) : await L.minor(
241
- async () => {
242
- await de();
243
- },
244
- {
245
- successMessage: d("hr.employee.update.successMessage"),
246
- isLoading: K
247
- }
248
- ), fe("submitted"), A.value = !1;
249
- }
250
- return te(
251
- () => A.value,
252
- (r) => {
253
- }
254
- ), R({
255
- show: A,
256
- trigger: se
257
- }), (r, a) => {
258
- const c = _("FmIcon"), h = _("FmSwitch"), E = _("FmTextField"), F = _("FmPinField"), M = _("FmFormGroup"), B = _("FmButton"), T = _("FmSelect"), e = _("fm-button"), l = _("fm-side-sheet");
259
- return v(), C(le, null, [
260
- Pe(r.$slots, "default", { trigger: se }),
261
- i(l, {
262
- id: "unit-form",
263
- "model-value": A.value,
264
- "is-container": o(ze).FmForm,
265
- "is-container-props": {
266
- onValidationSuccess: _e,
267
- blameFormChildOnValidationFailed: !0
268
- },
269
- "max-width": 960,
270
- "close-button": !1,
271
- "onOn:clickedAway": o(Y)
272
- }, {
273
- "side-sheet-header": w(() => [
274
- m("div", ut, [
275
- m("p", dt, z(H.value), 1),
276
- i(c, {
277
- name: "close",
278
- size: "md",
279
- class: "cursor-pointer",
280
- onClick: o(Y)
281
- }, null, 8, ["onClick"])
282
- ])
283
- ]),
284
- "side-sheet-footer": w(() => [
285
- m("div", xt, [
286
- i(e, {
287
- label: J.value,
288
- size: "lg",
289
- type: "submit",
290
- variant: "primary",
291
- disabled: K.value
292
- }, null, 8, ["label", "disabled"]),
293
- i(e, {
294
- label: o(d)("common.cancel"),
295
- size: "lg",
296
- variant: "tertiary",
297
- disabled: K.value,
298
- onClick: o(Y)
299
- }, null, 8, ["label", "disabled", "onClick"])
300
- ])
301
- ]),
302
- default: w(() => [
303
- m("div", ct, [
304
- i(Ue, {
305
- title: o(d)("hr.employee.form.employeeSetting")
306
- }, {
307
- default: w(() => [
308
- i(Ce, {
309
- label: o(d)("hr.employee.form.masterUserConfig")
310
- }, {
311
- default: w(() => [
312
- i(h, {
313
- modelValue: s.value.isMasterUser,
314
- "onUpdate:modelValue": a[0] || (a[0] = (t) => s.value.isMasterUser = t),
315
- value: "masterUser",
316
- label: o(d)("hr.employee.form.masterUser"),
317
- sublabel: o(d)("hr.employee.form.masterUserSublabel"),
318
- "label-placement": "right"
319
- }, null, 8, ["modelValue", "label", "sublabel"])
320
- ]),
321
- _: 1
322
- }, 8, ["label"]),
323
- m("div", mt, [
324
- s.value.isMasterUser ? (v(), j(E, {
325
- key: 0,
326
- modelValue: s.value.code,
327
- "onUpdate:modelValue": a[1] || (a[1] = (t) => s.value.code = t),
328
- label: o(d)("hr.employee.form.code")
329
- }, null, 8, ["modelValue", "label"])) : N("", !0),
330
- i(E, {
331
- modelValue: s.value.name,
332
- "onUpdate:modelValue": a[2] || (a[2] = (t) => s.value.name = t),
333
- class: "w-full",
334
- label: o(d)("hr.employee.form.name"),
335
- rules: [(t) => !!t || o(d)("hr.employee.form.required")]
336
- }, null, 8, ["modelValue", "label", "rules"])
337
- ]),
338
- i(Ce, {
339
- label: o(d)("hr.employee.form.passcode")
340
- }, {
341
- default: w(() => [
342
- m("div", pt, [
343
- i(M, {
344
- modelValue: U.value,
345
- "onUpdate:modelValue": a[5] || (a[5] = (t) => U.value = t),
346
- rules: [
347
- (t) => (t == null ? void 0 : t.filter((u) => !!u).length) !== Ae ? o(d)("hr.employee.form.passcodeRequired") : !0
348
- ]
349
- }, {
350
- default: w(() => [
351
- i(F, {
352
- modelValue: U.value,
353
- "onUpdate:modelValue": a[3] || (a[3] = (t) => U.value = t),
354
- length: Ae,
355
- masked: D.value,
356
- onComplete: a[4] || (a[4] = (t) => s.value.passcode = t),
357
- onFocus: W
358
- }, null, 8, ["modelValue", "masked"])
359
- ]),
360
- _: 1
361
- }, 8, ["modelValue", "rules"]),
362
- i(B, {
363
- variant: "secondary",
364
- "text-color": "primary",
365
- "border-color": "primary",
366
- label: o(d)("hr.employee.form.passcodeGenerate"),
367
- size: "md",
368
- loading: Q.value,
369
- onClick: ee
370
- }, null, 8, ["label", "loading"])
371
- ])
372
- ]),
373
- _: 1
374
- }, 8, ["label"])
375
- ]),
376
- _: 1
377
- }, 8, ["title"]),
378
- i(Ue, null, {
379
- default: w(() => [
380
- i(M, {
381
- modelValue: s.value.restaurants,
382
- "onUpdate:modelValue": a[6] || (a[6] = (t) => s.value.restaurants = t),
383
- tag: "div",
384
- rules: [
385
- (t) => t.length > 0 || o(d)("hr.employee.form.atLeastOneRestaurant"),
386
- (t) => t.every((u) => u.restaurantId && u.roleId) || o(d)("hr.employee.form.roleRequired")
387
- ]
388
- }, {
389
- default: w(() => [
390
- m("div", ft, [
391
- m("div", vt, z(o(d)("hr.employee.form.assignmentSection")), 1),
392
- m("div", yt, [
393
- m("div", ht, [
394
- m("div", gt, z(o(d)("hr.employee.columns.restaurants")), 1),
395
- m("div", _t, z(o(d)("hr.employee.form.role")), 1),
396
- a[7] || (a[7] = m("div", null, null, -1))
397
- ]),
398
- (v(!0), C(le, null, De(s.value.restaurants, (t, u) => (v(), C("div", {
399
- key: `${t.restaurantId || "new"}-${u}`,
400
- class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
401
- }, [
402
- i(T, {
403
- class: "min-w-0",
404
- "model-value": t.restaurantId,
405
- items: re(t.restaurantId),
406
- multiselect: !1,
407
- placeholder: o(d)("hr.employee.columns.restaurants"),
408
- disabled: $(t.restaurantId),
409
- "onUpdate:modelValue": (S) => ye(u, S)
410
- }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
411
- i(T, {
412
- class: "min-w-0",
413
- "model-value": t.roleId,
414
- items: ne(t.restaurantId, t.roleId),
415
- multiselect: !1,
416
- placeholder: o(d)("hr.employee.form.role"),
417
- disabled: !t.restaurantId || $(t.restaurantId),
418
- "onUpdate:modelValue": (S) => he(u, S)
419
- }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
420
- m("div", bt, [
421
- s.value.restaurants.length > 1 ? (v(), C("div", {
422
- key: 0,
423
- role: "button",
424
- tabindex: $(t.restaurantId) ? -1 : 0,
425
- "aria-disabled": $(t.restaurantId),
426
- class: ke(["inline-flex h-40 w-40 shrink-0 items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary disabled:cursor-not-allowed disabled:text-fm-color-neutral-gray-200 disabled:hover:bg-transparent", {
427
- "cursor-pointer": !$(t.restaurantId),
428
- "pointer-events-none": $(t.restaurantId)
429
- }]),
430
- "aria-label": o(d)("common.remove"),
431
- onClick: ae((S) => P(u), ["stop"]),
432
- onKeydown: [
433
- Se(ae((S) => P(u), ["prevent", "stop"]), ["enter"]),
434
- Se(ae((S) => P(u), ["prevent", "stop"]), ["space"])
435
- ]
436
- }, [
437
- i(c, {
438
- name: "delete",
439
- size: "md"
440
- })
441
- ], 42, wt)) : N("", !0)
442
- ])
443
- ]))), 128))
444
- ]),
445
- i(B, {
446
- type: "button",
447
- variant: "secondary",
448
- "text-color": "primary",
449
- "border-color": "primary",
450
- "prepend-icon": "add",
451
- label: o(d)("hr.employee.form.addAnother"),
452
- size: "md",
453
- disabled: !ie.value,
454
- onClick: ae(ge, ["stop"])
455
- }, null, 8, ["label", "disabled"])
456
- ])
457
- ]),
458
- _: 1
459
- }, 8, ["modelValue", "rules"])
460
- ]),
461
- _: 1
462
- })
463
- ])
464
- ]),
465
- _: 1
466
- }, 8, ["model-value", "is-container", "is-container-props", "onOn:clickedAway"])
467
- ], 64);
468
- };
469
- }
470
- }), kt = {
471
- class: "space-y-8"
472
- }, It = {
473
- key: 0,
474
- class: "flex w-full items-start justify-between"
475
- }, Ft = {
476
- class: "flex items-start gap-8"
477
- }, St = {
478
- class: "flex"
479
- }, Vt = {
480
- key: 1,
481
- class: "space-y-4"
482
- }, Ct = {
483
- class: "px-16"
484
- }, Rt = {
485
- class: "px-16 flex items-start gap-8"
486
- }, $t = {
487
- class: "flex h-full flex-col overflow-auto"
488
- }, Ut = {
489
- class: "pb-64 sm:hidden md:hidden lg:hidden"
490
- }, Mt = {
491
- class: "space-y-4"
492
- }, Lt = {
493
- class: "fm-typo-en-body-lg-600"
494
- }, At = {
495
- key: 0,
496
- class: "mr-4"
497
- }, Pt = {
498
- class: "text-fm-color-typo-secondary"
499
- }, Dt = {
500
- class: "line-clamp-2"
501
- }, Bt = {
502
- class: "font-bold"
503
- }, Z = 200, Tt = /* @__PURE__ */ Ee({
504
- __name: "EmployeeList",
505
- setup(x, {
506
- expose: R
507
- }) {
508
- const {
509
- t: n
510
- } = Be(), g = y(), f = Oe(), k = Ke(), X = We(), {
511
- currentBusiness: L,
512
- sessionUser: fe
513
- } = X, d = xe(), A = b(() => k.isLoading.value), O = y(d.roles.value.length === 0);
514
- te(k.restaurants, (e) => {
515
- if (e.length > 0 && f.listEmployees.value.length > 0) {
516
- const l = new Map(e.map((t) => [t._id, t]));
517
- f.listEmployees.value = f.listEmployees.value.map((t) => ({
518
- ...t,
519
- restaurants: t.restaurants.map((u) => {
520
- var S, ce;
521
- return {
522
- ...u,
523
- restaurantName: ((S = l.get(u.restaurantId)) == null ? void 0 : S.profile.name) || u.restaurantName,
524
- restaurantCode: ((ce = l.get(u.restaurantId)) == null ? void 0 : ce.profile.code) ?? void 0
525
- };
526
- })
527
- }));
528
- }
529
- });
530
- const G = b(() => k.restaurants.value.map((e) => ({
531
- label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
532
- value: e._id
533
- }))), ve = te(d.roles, (e) => {
534
- if (e.length > 0) {
535
- if (O.value = !1, f.listEmployees.value.length > 0) {
536
- const l = new Map(e.map((t) => [t._id, t.name]));
537
- f.listEmployees.value = f.listEmployees.value.map((t) => ({
538
- ...t,
539
- restaurants: t.restaurants.map((u) => ({
540
- ...u,
541
- roleName: l.get(u.roleId) || u.roleName
542
- }))
543
- }));
544
- }
545
- ve();
546
- }
547
- }), se = b(() => f.listEmployees.value), {
548
- searchKey: I
549
- } = et(), H = y(""), J = b(() => se.value), V = b(() => f.totalEmployees.value), s = y(1), oe = b(() => f.isLoading.value), q = y(!1), $ = b(() => {
550
- var e;
551
- return JSON.stringify({
552
- businessId: ((e = L.value) == null ? void 0 : e._id) ?? "",
553
- search: H.value.trim(),
554
- restaurantIds: [...g.value ?? []].sort(),
555
- roleIds: [...a.value ?? []].sort()
556
- });
557
- }), re = (e) => {
558
- const l = e.restaurantCode, t = e.restaurantName;
559
- return l ? `${l} - ${t}` : t;
560
- }, ne = (e) => e.roleName || "-";
561
- function ye(e) {
562
- return [{
563
- label: n("hr.employee.form.update"),
564
- onClick: () => ee(e)
565
- }, {
566
- label: n("hr.employee.remove.title"),
567
- onClick: () => ue(e),
568
- itemClass: "text-fm-color-typo-error"
569
- }];
570
- }
571
- const he = ({
572
- employee: e,
573
- className: l = ""
574
- }) => i("div", {
575
- class: l,
576
- onClick: (t) => {
577
- t.stopPropagation();
578
- }
579
- }, [i(lt, {
580
- items: ye(e)
581
- }, null)]), ge = [{
582
- accessorKey: "code",
583
- size: 100,
584
- header: () => n("hr.employee.columns.code")
585
- }, {
586
- accessorKey: "name",
587
- header: () => n("hr.employee.columns.name"),
588
- enableSorting: !1,
589
- cell(e) {
590
- const l = e.row.original;
591
- return i("div", {
592
- class: "flex items-center gap-8"
593
- }, [i(ze.FmAvatar, {
594
- name: l.name,
595
- size: "sm",
596
- class: "shrink-0"
597
- }, null), i("span", {
598
- class: "truncate"
599
- }, [l.name])]);
600
- }
601
- }, {
602
- accessorKey: "restaurants",
603
- align: "center",
604
- header: () => n("hr.employee.columns.restaurants"),
605
- enableSorting: !1,
606
- cell(e) {
607
- return A.value || O.value ? me($e) : e.row.original.restaurants.map((l, t) => {
608
- const u = re(l);
609
- return me("div", {
610
- key: l.restaurantId || t
611
- }, (t ? `
612
- ` : "") + u);
613
- });
614
- }
615
- }, {
616
- accessorKey: "assignedRole",
617
- align: "center",
618
- header: () => n("hr.employee.columns.assignedRole"),
619
- enableSorting: !1,
620
- cell(e) {
621
- return A.value || O.value ? me($e, {
622
- width: "120px"
623
- }) : e.row.original.restaurants.map((l, t) => {
624
- const u = ne(l);
625
- return me("div", {
626
- key: l.restaurantId || t
627
- }, (t ? `
628
- ` : "") + u);
629
- });
630
- }
631
- }, {
632
- accessorKey: "since",
633
- header: () => n("hr.employee.columns.since"),
634
- enableSorting: !1
635
- }, {
636
- id: "action",
637
- size: 52,
638
- meta: {
639
- cellClass: "pl-16",
640
- headerContentClass: "-mx-16"
641
- },
642
- cell(e) {
643
- return he({
644
- employee: e.row.original,
645
- className: "flex w-full items-center justify-end"
646
- });
647
- }
648
- }], P = Ne(), ie = Qe(), U = je(P), D = y(!1), W = y(), K = y();
649
- function Q(e) {
650
- const l = e.isRestricted;
651
- return l && P.open({
652
- message: n("hr.employee.cannotUpdateMasterUser", {
653
- name: e.name
654
- }),
655
- type: "error"
656
- }), l;
657
- }
658
- const ee = (e) => {
659
- var t;
660
- e && Q(e) || (t = K.value) == null || t.trigger(e);
661
- }, {
662
- breakpoints: Y
663
- } = Te(), ue = (e) => {
664
- Q(e) || ie.open({
665
- title: n("hr.employee.remove.title"),
666
- message: n("hr.employee.remove.message", {
667
- name: e.name
668
- }),
669
- minWidth: Y.value.lg ? 588 : 0,
670
- primaryActions: {
671
- text: n("common.remove"),
672
- close: !1,
673
- variant: "destructive",
674
- isLoading: D
675
- },
676
- secondaryActions: {
677
- text: n("common.cancel"),
678
- close: !0
679
- }
680
- }).onPrimary(async () => {
681
- if (D.value) return;
682
- const t = e.isMasterUser ? f.deleteMasterEmployee : f.deleteEmployee;
683
- await U.minor(async () => {
684
- await t(e), await E();
685
- }, {
686
- isLoading: D,
687
- successMessage: n("hr.employee.remove.successMessage", {
688
- name: e.name
689
- })
690
- }).catch(() => {
691
- }), ie.close();
692
- });
693
- }, de = y("");
694
- function _e() {
695
- var e;
696
- (e = K.value) == null || e.trigger();
697
- }
698
- const r = b(() => xe().roles.value.map((e) => ({
699
- label: e.name,
700
- value: e._id
701
- }))), a = y();
702
- async function c() {
703
- try {
704
- await f.syncUsersMeta(), await E(), P.open({
705
- message: n("hr.employee.sync.successMessage"),
706
- type: "success"
707
- });
708
- } catch (e) {
709
- console.error("Error syncing users:", e), P.open({
710
- message: n("hr.employee.sync.errorMessage"),
711
- type: "error"
712
- });
713
- }
714
- }
715
- async function h(e = s.value) {
716
- var l, t;
717
- try {
718
- await f.readEmployeesPage({
719
- limit: Z,
720
- offset: (e - 1) * Z,
721
- search: H.value.trim() || void 0,
722
- restaurantIds: (l = g.value) != null && l.length ? g.value : void 0,
723
- roleIds: (t = a.value) != null && t.length ? a.value : void 0
724
- });
725
- } catch (u) {
726
- console.error("Failed to load employees:", u), P.open({
727
- message: u instanceof Error ? u.message : String(u),
728
- type: "error"
729
- });
730
- }
731
- }
732
- async function E() {
733
- var l;
734
- if (!((l = L.value) != null && l._id)) return;
735
- await h(s.value);
736
- const e = Math.max(1, Math.ceil(V.value / Z));
737
- s.value > e && (s.value = e, await h(s.value));
738
- }
739
- async function F() {
740
- var e, l;
741
- return await f.readAllEmployeesPage({
742
- search: H.value.trim() || void 0,
743
- restaurantIds: (e = g.value) != null && e.length ? g.value : void 0,
744
- roleIds: (l = a.value) != null && l.length ? a.value : void 0
745
- }, V.value);
746
- }
747
- const M = st(I, () => {
748
- H.value = I.value;
749
- }, 300);
750
- Je(M);
751
- let B = !1;
752
- async function T({
753
- pageIndex: e
754
- }) {
755
- var l;
756
- if ((l = L.value) != null && l._id && !B && !(e === 0 && s.value === 1 && J.value.length > 0)) {
757
- B = !0, s.value = e + 1;
758
- try {
759
- await h(s.value);
760
- } finally {
761
- B = !1;
762
- }
763
- }
764
- }
765
- return te($, async () => {
766
- var e;
767
- s.value = 1, q.value = !1, (e = L.value) != null && e._id && (await h(1), q.value = !0);
768
- }, {
769
- immediate: !0
770
- }), te(() => W.value && W.value.restaurants, (e) => {
771
- e && e.length > 0 && (de.value = "");
772
- }), R({
773
- create: _e,
774
- filteredEmployees: J,
775
- exportEmployees: F
776
- }), (e, l) => {
777
- var Ie, Fe;
778
- const t = _("FmButton"), u = _("FmTooltip"), S = _("FmSearch"), ce = _("FmTable"), Ge = _("FmListItem"), qe = _("FmList");
779
- return v(), C(le, null, [i(Et, {
780
- ref_key: "employeeFormRef",
781
- ref: K,
782
- modelValue: W.value,
783
- "onUpdate:modelValue": l[0] || (l[0] = (p) => W.value = p),
784
- "role-error-message": de.value,
785
- class: "gap-8",
786
- onSubmitted: E
787
- }, null, 8, ["modelValue", "role-error-message"]), m("div", kt, [o(Y).xs ? (v(), C("div", Vt, [m("div", Ct, [i(S, {
788
- modelValue: o(I),
789
- "onUpdate:modelValue": l[4] || (l[4] = (p) => Ve(I) ? I.value = p : null),
790
- placeholder: o(n)("hr.employee.search.placeholder")
791
- }, null, 8, ["modelValue", "placeholder"])]), i(tt), m("div", Rt, [i(pe, {
792
- modelValue: g.value,
793
- "onUpdate:modelValue": l[5] || (l[5] = (p) => g.value = p),
794
- multiple: "",
795
- items: G.value,
796
- variant: "dark",
797
- "selected-prefix": o(n)("hr.role.columns.restaurants"),
798
- placeholder: o(n)("hr.role.columns.restaurants"),
799
- class: "!w-auto"
800
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), i(pe, {
801
- modelValue: a.value,
802
- "onUpdate:modelValue": l[6] || (l[6] = (p) => a.value = p),
803
- multiple: "",
804
- items: r.value,
805
- variant: "dark",
806
- "selected-prefix": o(n)("hr.employee.filter.selected_role_prefix"),
807
- placeholder: o(n)("hr.employee.filter.role_placeholder")
808
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (v(), C("div", It, [m("div", Ft, [i(pe, {
809
- modelValue: g.value,
810
- "onUpdate:modelValue": l[1] || (l[1] = (p) => g.value = p),
811
- multiple: "",
812
- items: G.value,
813
- variant: "dark",
814
- "selected-prefix": o(n)("hr.role.columns.restaurants"),
815
- placeholder: o(n)("hr.role.columns.restaurants"),
816
- class: "!w-auto"
817
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), i(pe, {
818
- modelValue: a.value,
819
- "onUpdate:modelValue": l[2] || (l[2] = (p) => a.value = p),
820
- multiple: "",
821
- variant: "dark",
822
- items: r.value,
823
- "selected-prefix": o(n)("hr.employee.filter.selected_role_prefix"),
824
- placeholder: o(n)("hr.employee.filter.role_placeholder")
825
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), m("div", St, [(Ie = o(fe)) != null && Ie.role.isAdmin ? (v(), j(u, {
826
- key: 0,
827
- content: o(n)("hr.employee.sync.tooltip")
828
- }, {
829
- default: w(() => [i(t, {
830
- icon: "refresh",
831
- label: o(n)("hr.employee.sync.tooltip"),
832
- variant: "tertiary",
833
- onClick: c
834
- }, null, 8, ["label"])]),
835
- _: 1
836
- }, 8, ["content"])) : N("", !0), i(S, {
837
- modelValue: o(I),
838
- "onUpdate:modelValue": l[3] || (l[3] = (p) => Ve(I) ? I.value = p : null),
839
- autofocus: "",
840
- class: "pl-4 w-[320px]",
841
- placeholder: o(n)("hr.employee.search.placeholder")
842
- }, null, 8, ["modelValue", "placeholder"])])])), (Fe = o(L)) != null && Fe._id ? (v(), j(Ze, {
843
- key: 2
844
- }, {
845
- default: w(() => [m("div", $t, [!q.value && o(f).isLoading.value ? (v(), j(Xe, {
846
- key: 0
847
- })) : N("", !0), q.value ? (v(), j(it, {
848
- key: 1,
849
- "is-loading": o(f).isLoading.value,
850
- "is-empty": V.value === 0,
851
- title: o(n)("hr.employee.noData.title"),
852
- subtitle: o(n)("hr.employee.noData.subtitle")
853
- }, {
854
- default: w(() => [(v(), j(ce, {
855
- key: $.value,
856
- class: ke(["employee-list-table h-full", {
857
- "employee-list-table--pagination-loading": oe.value
858
- }]),
859
- "column-defs": ge,
860
- "row-data": J.value,
861
- "page-size": Z,
862
- "page-count": Math.ceil(V.value / Z),
863
- "row-count": V.value,
864
- "fetch-fn": T,
865
- "hide-footer": V.value <= Z,
866
- loading: o(f).isLoading.value,
867
- virtual: !1,
868
- "pin-header-row": "",
869
- onRowClick: l[7] || (l[7] = (p) => ee(p.original))
870
- }, null, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
871
- _: 1
872
- }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : N("", !0), m("div", Ut, [i(qe, {
873
- separator: ""
874
- }, {
875
- default: w(() => [(v(!0), C(le, null, De(J.value, (p) => (v(), j(Ge, {
876
- key: p._id,
877
- class: "py-12 px-16 items-center justify-between",
878
- onClick: (be) => ee(p)
879
- }, {
880
- default: w(() => [m("div", Mt, [m("p", Lt, [p.code ? (v(), C("span", At, z(p.code) + ".", 1)) : N("", !0), we(z(p.name), 1)]), m("div", Pt, [m("p", Dt, [m("span", Bt, z(o(n)("hr.employee.columns.restaurants")) + ":", 1), we(" " + z(p.restaurants.map((be) => re(be)).join(", ")), 1)]), m("p", null, [l[8] || (l[8] = m("span", {
881
- class: "font-bold"
882
- }, "Since:", -1)), we(" " + z(p.since), 1)])])]), i(t, {
883
- icon: "delete",
884
- variant: "tertiary",
885
- "text-color": "neutral-gray-400",
886
- onClick: ae((be) => ue(p), ["stop"])
887
- }, null, 8, ["onClick"])]),
888
- _: 2
889
- }, 1032, ["onClick"]))), 128))]),
890
- _: 1
891
- })])])]),
892
- _: 1
893
- })) : N("", !0)])], 64);
894
- };
895
- }
896
- }), aa = /* @__PURE__ */ Ye(Tt, [["__scopeId", "data-v-caeeab1d"]]);
897
- export {
898
- aa as default
899
- };