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