@feedmepos/mf-report 5.27.13 → 5.27.14-beta.0

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 (30) hide show
  1. package/dist/{App-BlHs_KyM.js → App-CcdMlfSd.js} +96 -95
  2. package/dist/DateRangeSelect.vue_vue_type_script_setup_true_lang-OQRT1HAp.js +389 -0
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-CxR3luuJ.js → Default.vue_vue_type_script_setup_true_lang-BoZCI7kN.js} +1 -1
  4. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-DJTZFtNV.js +5079 -0
  5. package/dist/{GlobalFilterSelect.vue_vue_type_script_setup_true_lang-oCAIT-ax.js → GlobalFilterSelect.vue_vue_type_script_setup_true_lang-faQ1wSGW.js} +5193 -4810
  6. package/dist/{InsightView-N5Lzz_b4.js → InsightView-B7hXryQe.js} +4 -4
  7. package/dist/{Integration-BotRTI4i.js → Integration-Cm0DNd94.js} +3 -3
  8. package/dist/{Integrations-B26o5QXd.js → Integrations-s2XnL_lQ.js} +2 -2
  9. package/dist/{Layout-6NKUqxol.js → Layout-BaxsdPkO.js} +1 -1
  10. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-BijCez3Y.js → MenuTab.vue_vue_type_script_setup_true_lang-D-uVoZ83.js} +4 -4
  11. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-CA9MugVT.js → NavigationTab.vue_vue_type_script_setup_true_lang-40Mxqpsi.js} +2795 -2779
  12. package/dist/{OverviewView-vdfq-4MN.js → OverviewView-YYCDda7Z.js} +4 -4
  13. package/dist/{Report-Dz8mKOpQ.js → Report-fQv1rMXB.js} +3 -3
  14. package/dist/ReportEditor-BQi5vZ5G.js +1828 -0
  15. package/dist/{ReportView-DHNMt0BV.js → ReportView-CePzSNVf.js} +6 -6
  16. package/dist/{Setting-Cpy5DtfI.js → Setting-DA1IUerO.js} +14 -14
  17. package/dist/{Template-6U_iB8qy.js → Template-BNwoCMjJ.js} +3 -3
  18. package/dist/TileEditor-EBbG7Odu.js +4064 -0
  19. package/dist/TileGrid.vue_vue_type_script_setup_true_lang-BseyYYvj.js +154 -0
  20. package/dist/{TransitionFade-C7B6bWjS.js → TransitionFade-vNYa-qkr.js} +760 -828
  21. package/dist/{app-Dz4qiCQj.js → app-D2QVuN8P.js} +388 -291
  22. package/dist/app.js +1 -1
  23. package/dist/style.css +1 -1
  24. package/dist/{useRestaurantPermission-DDTn3OLP.js → useRestaurantPermission-qFfSh5xv.js} +1 -1
  25. package/package.json +1 -1
  26. package/dist/DateRangeSelect.vue_vue_type_script_setup_true_lang-B9yWyW2A.js +0 -383
  27. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-BZdgw5zR.js +0 -4922
  28. package/dist/ReportEditor-CSq4R2KR.js +0 -1826
  29. package/dist/TileEditor-REt2Wbx9.js +0 -4036
  30. package/dist/TileGrid.vue_vue_type_script_setup_true_lang-D0rrgUXG.js +0 -152
@@ -1,1826 +0,0 @@
1
- import { defineComponent as Ce, mergeModels as Ne, useModel as Re, ref as z, computed as v, resolveComponent as F, createBlock as k, openBlock as u, withCtx as y, createElementVNode as b, createVNode as r, unref as l, normalizeClass as Pe, createTextVNode as Ae, toDisplayString as L, createElementBlock as N, Fragment as xe, renderSlot as pt, createCommentVNode as M, watch as he, renderList as Ee, onMounted as vt, onUnmounted as Tt, resolveDynamicComponent as $t, isRef as ft, normalizeStyle as lt } from "vue";
2
- import { W as St, g as Dt, _ as Ot, a as It, e as Ue, d as gt, b as bt, i as Nt, S as We, T as Rt, c as Ut } from "./TransitionFade-C7B6bWjS.js";
3
- import { C as Oe, D as fe, c as qe, g as Bt, u as at, M as yt, r as Mt, d as st, n as qt, e as Et, f as Pt, h as zt, i as Lt, a as At, j as Ye, k as Xe, m as Gt, Q as He, o as Wt, l as Ht, b as ut, p as jt } from "./GlobalFilterSelect.vue_vue_type_script_setup_true_lang-oCAIT-ax.js";
4
- import { storeToRefs as Be } from "pinia";
5
- import { useRouter as nt, useRoute as rt } from "vue-router";
6
- import { useBreakpoints as je, useSnackbar as ht, FmButtonColorThemeVariant as Ie } from "@feedmepos/ui-library";
7
- import { u as it } from "./message-dialog-UoMWOnil.js";
8
- import { u as ze, a as Jt } from "./_plugin-vue_export-helper-onplcgja.js";
9
- import { r as Ge } from "./i18n-CI_sQ5d_.js";
10
- import { _ as Ze } from "./TileGrid.vue_vue_type_script_setup_true_lang-D0rrgUXG.js";
11
- import { a as et, _ as tt } from "./SelectComponent.vue_vue_type_script_setup_true_lang-CGbb3b5G.js";
12
- import { useCoreStore as Kt } from "@feedmepos/mf-common";
13
- import { u as Qt, a as Yt } from "./app-Dz4qiCQj.js";
14
- import { d as Xt } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-B9yWyW2A.js";
15
- const Zt = /* @__PURE__ */ Ce({
16
- __name: "WidgetDialog",
17
- props: /* @__PURE__ */ Ne({
18
- isOpen: { type: Boolean }
19
- }, {
20
- modelValue: {},
21
- modelModifiers: {}
22
- }),
23
- emits: /* @__PURE__ */ Ne(["update:isOpen"], ["update:modelValue"]),
24
- setup(R, { emit: i }) {
25
- const { t: a } = ze(), { breakpoints: c } = je(), p = Re(R, "modelValue"), f = R, q = i;
26
- function le() {
27
- q("update:isOpen", !1);
28
- }
29
- function T() {
30
- h.value && (p.value = h.value, h.value = void 0, q("update:isOpen", !1));
31
- }
32
- const h = z(), x = v(() => !h.value);
33
- return ($, W) => {
34
- const E = F("FmButton"), G = F("FmDialog");
35
- return u(), k(G, {
36
- "model-value": f.isOpen
37
- }, {
38
- "dialog-header": y(() => [
39
- Ae(L(l(a)("report.widget.type")), 1)
40
- ]),
41
- default: y(() => [
42
- r(St, {
43
- modelValue: h.value,
44
- "onUpdate:modelValue": W[0] || (W[0] = (S) => h.value = S),
45
- class: Pe(`grid ${l(c).lg || l(c).md ? "grid-cols-3 gap-3" : "grid-cols-2 gap-3"}`),
46
- "child-class": "p-[8px] flex flex-col"
47
- }, null, 8, ["modelValue", "class"])
48
- ]),
49
- "dialog-footer": y(() => [
50
- W[1] || (W[1] = b("div", { class: "grow" }, null, -1)),
51
- r(E, {
52
- label: l(a)("report.common.cancel"),
53
- variant: "tertiary",
54
- onClick: le
55
- }, null, 8, ["label"]),
56
- r(E, {
57
- label: l(a)("report.common.confirm"),
58
- disabled: x.value,
59
- onClick: T
60
- }, null, 8, ["label", "disabled"])
61
- ]),
62
- _: 1
63
- }, 8, ["model-value"]);
64
- };
65
- }
66
- }), el = { class: "fm-typo-en-body-lg-600" }, ot = /* @__PURE__ */ Ce({
67
- __name: "ReportEditorTabHeader",
68
- props: /* @__PURE__ */ Ne({
69
- icon: {
70
- type: String,
71
- required: !0
72
- }
73
- }, {
74
- modelValue: { type: Boolean, required: !0, default: !1 },
75
- modelModifiers: {}
76
- }),
77
- emits: ["update:modelValue"],
78
- setup(R) {
79
- const { t: i } = ze(), a = Re(R, "modelValue"), c = R;
80
- return (p, f) => {
81
- const q = F("FmIcon");
82
- return u(), N("div", {
83
- class: "px-6 py-16 flex items-center gap-2 bg-fm-color-neutral-white border cursor-pointer",
84
- onClick: f[0] || (f[0] = (le) => a.value = !a.value)
85
- }, [
86
- b("p", el, L(l(i)("report.editor.customizeReport")), 1),
87
- f[1] || (f[1] = b("div", { class: "grow" }, null, -1)),
88
- r(q, {
89
- name: c.icon
90
- }, null, 8, ["name"])
91
- ]);
92
- };
93
- }
94
- }), tl = /* @__PURE__ */ Ce({
95
- __name: "ReportEditorTabDesktop",
96
- props: {
97
- modelValue: { required: !0, default: !1 },
98
- modelModifiers: {}
99
- },
100
- emits: ["update:modelValue"],
101
- setup(R) {
102
- const i = Re(R, "modelValue");
103
- return (a, c) => (u(), N(xe, null, [
104
- r(ot, {
105
- modelValue: i.value,
106
- "onUpdate:modelValue": c[0] || (c[0] = (p) => i.value = p),
107
- icon: "keyboard_double_arrow_left"
108
- }, null, 8, ["modelValue"]),
109
- pt(a.$slots, "default")
110
- ], 64));
111
- }
112
- }), ll = /* @__PURE__ */ Ce({
113
- __name: "ReportEditorTabMobile",
114
- props: {
115
- modelValue: { required: !0, default: !1 },
116
- modelModifiers: {}
117
- },
118
- emits: ["update:modelValue"],
119
- setup(R) {
120
- const i = Re(R, "modelValue");
121
- return (a, c) => {
122
- const p = F("FmTopSheet"), f = F("FmCard");
123
- return u(), k(f, { class: "fixed bottom-0 w-full" }, {
124
- default: y(() => [
125
- r(ot, {
126
- modelValue: i.value,
127
- "onUpdate:modelValue": c[0] || (c[0] = (q) => i.value = q),
128
- icon: "keyboard_double_arrow_up"
129
- }, null, 8, ["modelValue"]),
130
- r(p, {
131
- modelValue: i.value,
132
- "onUpdate:modelValue": c[2] || (c[2] = (q) => i.value = q),
133
- "fullscreen-size": "sm"
134
- }, {
135
- default: y(() => [
136
- r(ot, {
137
- modelValue: i.value,
138
- "onUpdate:modelValue": c[1] || (c[1] = (q) => i.value = q),
139
- icon: "keyboard_double_arrow_down"
140
- }, null, 8, ["modelValue"]),
141
- i.value ? pt(a.$slots, "default", { key: 0 }) : M("", !0)
142
- ]),
143
- _: 3
144
- }, 8, ["modelValue"])
145
- ]),
146
- _: 3
147
- });
148
- };
149
- }
150
- }), ol = {
151
- key: 2,
152
- class: "flex flex-col gap-3 mt-2 border border-neutral-300 p-3"
153
- }, al = { class: "grid grid-cols-1 gap-2 rounded-md border border-neutral-300 p-2 sm:grid-cols-[1.3fr_1fr_1fr_auto] sm:items-end" }, nl = {
154
- key: 0,
155
- class: "flex justify-end sm:pb-[2px]"
156
- }, rl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, il = { class: "pl-1" }, sl = {
157
- key: 0,
158
- class: "flex justify-end sm:pb-[2px]"
159
- }, ul = {
160
- key: 4,
161
- class: "flex flex-col gap-2"
162
- }, dl = /* @__PURE__ */ Ce({
163
- __name: "GlobalFilterDialog",
164
- props: /* @__PURE__ */ Ne({
165
- schemas: {
166
- type: Array,
167
- default: () => []
168
- },
169
- tiles: {
170
- type: Array,
171
- required: !0
172
- }
173
- }, {
174
- globalFilter: {
175
- default: () => null
176
- },
177
- globalFilterModifiers: {},
178
- isOpen: { type: Boolean, default: () => !1, required: !0 },
179
- isOpenModifiers: {}
180
- }),
181
- emits: ["update:globalFilter", "update:isOpen"],
182
- setup(R) {
183
- const { t: i, te: a } = ze(), c = Re(R, "globalFilter"), p = Re(R, "isOpen"), f = ht(), q = R, le = z(""), T = z(), h = z(), x = z(), $ = z([]), W = z([]), E = z(""), G = z(!1), S = z(!1), U = z([]), B = z([]), se = z(Oe.Equal);
184
- function de(t) {
185
- return JSON.parse(JSON.stringify(t));
186
- }
187
- function K(t, e) {
188
- return { hour: t, minute: e };
189
- }
190
- function w(t) {
191
- return t ? `${String(t.hour).padStart(2, "0")}:${String(t.minute).padStart(2, "0")}` : null;
192
- }
193
- function _e(t) {
194
- if (!t) return null;
195
- const [e, g] = t.split(":").map(Number);
196
- return Number.isNaN(e) || Number.isNaN(g) ? null : { hour: e, minute: g };
197
- }
198
- const me = v(() => h.value ? !(h.value.type === fe.Timestamp && x.value === qe.DateTime) : !1), oe = v(
199
- () => {
200
- var t;
201
- return ((t = h.value) == null ? void 0 : t.type) === fe.Timestamp && x.value === qe.TimeOfDay;
202
- }
203
- ), ce = v(() => {
204
- var t;
205
- return (((t = h.value) == null ? void 0 : t.filterOperators) ?? []).filter((e) => e !== Oe.And && e !== Oe.Or).map((e) => ({
206
- label: i(`report.section.comparisonOperator.${e}`),
207
- value: e
208
- }));
209
- });
210
- function ge() {
211
- var e;
212
- const t = (e = ce.value[0]) == null ? void 0 : e.value;
213
- return t || (h.value ? ue(h.value.type, x.value ?? null) : Oe.Equal);
214
- }
215
- function ye(t) {
216
- if (h.value)
217
- return Bt({
218
- operator: t ?? ge(),
219
- dataType: h.value.type,
220
- dimensionOption: h.value.type === fe.Timestamp ? x.value ?? null : null,
221
- t: i
222
- });
223
- }
224
- function P(t, e) {
225
- if (typeof (e == null ? void 0 : e.default) == "boolean" || t.length > 0 && t.every((V) => typeof V == "boolean")) {
226
- const V = t.reduce((O, X) => (typeof X == "boolean" && O.push(X), O), []);
227
- if (e)
228
- for (e.fixed && V.splice(e.count); V.length < e.count; )
229
- V.push(typeof e.default == "boolean" ? e.default : !1);
230
- return V;
231
- }
232
- const _ = t.reduce((V, O) => (typeof O == "string" && V.push(O), V), []);
233
- if (e)
234
- for (e.fixed && _.splice(e.count); _.length < e.count; )
235
- _.push(typeof e.default == "string" ? e.default : "");
236
- return _;
237
- }
238
- function H(t = se.value) {
239
- const e = ye(t), g = P(
240
- e ? Array(e.count).fill(e.default) : [],
241
- e
242
- );
243
- return {
244
- label: "",
245
- operator: t,
246
- values: g
247
- };
248
- }
249
- function Z() {
250
- return {
251
- name: "",
252
- startTime: K(0, 0),
253
- endTime: K(23, 59)
254
- };
255
- }
256
- function be() {
257
- if (!(!me.value || !S.value)) {
258
- if (oe.value) {
259
- B.value.length === 0 && (B.value = [Z()]);
260
- return;
261
- }
262
- U.value.length === 0 && (U.value = [H()]);
263
- }
264
- }
265
- function we() {
266
- var g, _, V;
267
- const t = de(((g = c.value) == null ? void 0 : g.customOptions) ?? []), e = de(((_ = c.value) == null ? void 0 : _.customTimeRanges) ?? []);
268
- se.value = ((V = t[0]) == null ? void 0 : V.operator) ?? ge(), S.value = t.length > 0 || e.length > 0, U.value = t, B.value = e, be();
269
- }
270
- function ee(t) {
271
- se.value = t, U.value = U.value.map((e, g) => {
272
- const _ = U.value[g];
273
- if (!_)
274
- return H(t);
275
- const V = ye(t), O = P(
276
- Array.isArray(_.values) ? [..._.values] : [],
277
- V
278
- );
279
- return {
280
- ..._,
281
- operator: t,
282
- values: O
283
- };
284
- });
285
- }
286
- function Ve() {
287
- U.value = [...U.value, H()];
288
- }
289
- function pe(t) {
290
- U.value.length <= 1 || (U.value = U.value.filter((e, g) => g !== t));
291
- }
292
- function Fe() {
293
- B.value = [...B.value, Z()];
294
- }
295
- function ke(t) {
296
- B.value.length <= 1 || (B.value = B.value.filter(
297
- (e, g) => g !== t
298
- ));
299
- }
300
- function Te(t, e, g) {
301
- const _ = B.value[t];
302
- _ && (B.value[t] = {
303
- ..._,
304
- [e]: _e(g)
305
- });
306
- }
307
- function $e(t) {
308
- return t.length === 0 || t.some((e) => e == null || e === "");
309
- }
310
- function Se() {
311
- if (!S.value) return !0;
312
- if (oe.value) {
313
- const g = B.value.map((V) => V.name.trim()).filter(Boolean);
314
- return B.value.some(
315
- (V) => !V.name.trim() || !V.startTime || !V.endTime
316
- ) ? (f.open({
317
- message: i("report.section.filter.invalidCustomTimeRange"),
318
- type: "error"
319
- }), !1) : new Set(g).size !== g.length ? (f.open({
320
- message: i("report.section.filter.customTimeRangeNamesMustBeUnique"),
321
- type: "error"
322
- }), !1) : !0;
323
- }
324
- const t = U.value.map((g) => g.label.trim()).filter(Boolean);
325
- return U.value.some(
326
- (g) => !g.label.trim() || $e(g.values)
327
- ) ? (f.open({ message: i("report.section.filter.invalidCustomOption"), type: "error" }), !1) : new Set(t).size !== t.length ? (f.open({
328
- message: i("report.section.filter.customOptionLabelsMustBeUnique"),
329
- type: "error"
330
- }), !1) : !0;
331
- }
332
- he(p, (t) => {
333
- var e, g, _, V, O, X, re;
334
- t && (le.value = ((e = c.value) == null ? void 0 : e.label) || "", T.value = q.schemas.find(
335
- (ie) => {
336
- var j;
337
- return ie.name === ((j = c.value) == null ? void 0 : j.schemaName);
338
- }
339
- ), h.value = (g = n.value.find(
340
- (ie) => {
341
- var j;
342
- return ie.value.name === ((j = c.value) == null ? void 0 : j.name);
343
- }
344
- )) == null ? void 0 : g.value, x.value = (_ = c.value) == null ? void 0 : _.option, $.value = ((V = c.value) == null ? void 0 : V.tileIds) || [], W.value = ((O = c.value) == null ? void 0 : O.filters) || [], G.value = !!((X = c.value) != null && X.dataFormula), E.value = ((re = c.value) == null ? void 0 : re.dataFormula) || "", we());
345
- }), he(S, (t) => {
346
- var e;
347
- t && (se.value = ((e = U.value[0]) == null ? void 0 : e.operator) ?? ge(), be());
348
- }), he(me, (t) => {
349
- if (!t) {
350
- S.value = !1, U.value = [], B.value = [];
351
- return;
352
- }
353
- be();
354
- }), he(oe, () => {
355
- be();
356
- }), he(ce, (t) => {
357
- var g;
358
- const e = (g = t[0]) == null ? void 0 : g.value;
359
- e && (t.some((_) => _.value === se.value) || ee(e));
360
- });
361
- const Me = v(
362
- () => q.schemas.map((t) => ({
363
- label: t.label || t.name,
364
- value: t
365
- }))
366
- ), n = v(() => {
367
- var t;
368
- return (((t = T.value) == null ? void 0 : t.fields) || []).filter((e) => e.type !== fe.Numeric).map((e) => ({
369
- label: e.label || e.name,
370
- value: e
371
- }));
372
- }), d = v(() => {
373
- var t;
374
- return ((t = h.value) == null ? void 0 : t.type) !== fe.Timestamp ? [] : Dt(i);
375
- }), A = v(() => q.tiles.reduce((t, e, g) => {
376
- var O, X, re, ie, j;
377
- const _ = ((O = e.widget) == null ? void 0 : O.config.schemaNames) ?? [], V = (((X = e.widget) == null ? void 0 : X.config.joinDatasources) ?? []).flatMap(
378
- (Le) => Le.schemaNames ?? []
379
- );
380
- return [..._, ...V].includes(((re = T.value) == null ? void 0 : re.name) || "") && t.push({
381
- label: (j = (ie = e.widget) == null ? void 0 : ie.title) != null && j.trim() ? e.widget.title : `Widget ${g + 1}`,
382
- value: e.id
383
- }), t;
384
- }, [])), ne = v(
385
- () => q.schemas.flatMap(
386
- (t) => (t.fields ?? []).map((e) => ({
387
- ...e,
388
- labels: [
389
- Ge(i, a, t.label, "schema"),
390
- Ge(i, a, e.label || e.name, "other")
391
- ]
392
- }))
393
- )
394
- );
395
- function te(t) {
396
- var e;
397
- t.name !== ((e = T.value) == null ? void 0 : e.name) && (T.value = t, h.value = void 0, se.value = Oe.Equal, S.value = !1, U.value = [], B.value = []);
398
- }
399
- function Q(t) {
400
- h.value = t, x.value = t.type === fe.Timestamp ? qe.DateTime : void 0, se.value = ge(), S.value = !1, U.value = [], B.value = [];
401
- }
402
- function ue(t, e) {
403
- switch (t) {
404
- case fe.Timestamp:
405
- return e === qe.DateTime || e === qe.TimeOfDay ? Oe.Between : Oe.Equal;
406
- case fe.Bool:
407
- case fe.String:
408
- case fe.Numeric:
409
- return Oe.Equal;
410
- default:
411
- throw new Error(`Unsupported data type: ${t}`);
412
- }
413
- }
414
- function Y() {
415
- if (!T.value) {
416
- f.open({ message: i("report.section.filter.invalidSchema"), type: "error" });
417
- return;
418
- }
419
- if (!h.value) {
420
- f.open({ message: i("report.section.filter.invalidDimension"), type: "error" });
421
- return;
422
- }
423
- const t = W.value.filter((_) => _ ? !Me.value.some((O) => O.value.name === _.schemaName) : !0);
424
- if (t.length > 0) {
425
- const _ = t.filter((O) => !!O).map((O) => O.schemaName), V = t.some((O) => !O) ? `, ${i("report.section.filter.unknownFilters")}` : "";
426
- f.open({
427
- message: i("report.section.filter.invalidFiltersSchemaNotFound", {
428
- schemas: _.join(", "),
429
- unknownFiltersSuffix: V
430
- }),
431
- type: "error"
432
- });
433
- return;
434
- }
435
- if (!Se())
436
- return;
437
- const e = S.value && !oe.value ? U.value.map((_) => ({
438
- label: _.label.trim(),
439
- operator: _.operator ?? ge(),
440
- values: P(
441
- [..._.values],
442
- ye(_.operator)
443
- )
444
- })) : void 0, g = S.value && oe.value ? B.value.map((_) => ({
445
- name: _.name.trim(),
446
- startTime: _.startTime,
447
- endTime: _.endTime
448
- })) : void 0;
449
- c.value = {
450
- schemaName: T.value.name,
451
- name: h.value.name,
452
- label: le.value,
453
- operator: ue(
454
- h.value.type,
455
- h.value.type === fe.Timestamp ? x.value ?? qe.DateTime : null
456
- ),
457
- option: h.value.type === fe.Timestamp ? x.value : null,
458
- values: [],
459
- tileIds: [...$.value],
460
- filters: de(W.value),
461
- dataFormula: G.value ? E.value : void 0,
462
- customOptions: e,
463
- customTimeRanges: g
464
- }, p.value = !1;
465
- }
466
- function ve() {
467
- p.value = !1;
468
- }
469
- const De = v(() => {
470
- var t;
471
- return [
472
- (t = T.value) == null ? void 0 : t.name,
473
- ...W.value.map((e) => e.schemaName)
474
- ];
475
- });
476
- function C(t) {
477
- var O, X, re, ie;
478
- const e = q.tiles.find((j) => j.id === t.value), g = ((X = (O = e == null ? void 0 : e.widget) == null ? void 0 : O.config) == null ? void 0 : X.schemaNames) ?? [], _ = (((ie = (re = e == null ? void 0 : e.widget) == null ? void 0 : re.config) == null ? void 0 : ie.joinDatasources) ?? []).flatMap(
479
- (j) => j.schemaNames ?? []
480
- ), V = [...g, ..._];
481
- return De.value.filter((j) => !!j).some((j) => !V.includes(j));
482
- }
483
- return (t, e) => {
484
- const g = F("FmTextField"), _ = F("FmSelect"), V = F("FmCheckbox"), O = F("FmTimePicker"), X = F("FmButton"), re = F("FmTextarea"), ie = F("FmLabel"), j = F("FmIcon"), Le = F("FmTooltip"), s = F("FmForm"), o = F("FmDialog");
485
- return u(), k(o, {
486
- modelValue: p.value,
487
- "onUpdate:modelValue": e[11] || (e[11] = (I) => p.value = I),
488
- overlay: !0,
489
- "z-index": 10
490
- }, {
491
- "dialog-header": y(() => [
492
- Ae(L(l(i)("report.section.filter.globalFilter")), 1)
493
- ]),
494
- default: y(() => [
495
- r(s, {
496
- ref: "form",
497
- class: "flex flex-col gap-2 w-[490px]"
498
- }, {
499
- default: y(() => {
500
- var I;
501
- return [
502
- r(g, {
503
- modelValue: le.value,
504
- "onUpdate:modelValue": e[0] || (e[0] = (m) => le.value = m),
505
- placeholder: l(i)("report.section.filter.displayName"),
506
- label: l(i)("report.section.filter.displayName"),
507
- class: "mb-2"
508
- }, null, 8, ["modelValue", "placeholder", "label"]),
509
- r(et, {
510
- "model-value": T.value,
511
- items: Me.value,
512
- placeholder: l(i)("report.section.schema.title"),
513
- label: l(i)("report.section.schema.title"),
514
- "onUpdate:modelValue": e[1] || (e[1] = (m) => te(m))
515
- }, null, 8, ["model-value", "items", "placeholder", "label"]),
516
- r(et, {
517
- "model-value": h.value,
518
- items: n.value,
519
- placeholder: l(i)("report.section.dimension.title"),
520
- label: l(i)("report.section.dimension.title"),
521
- "onUpdate:modelValue": e[2] || (e[2] = (m) => Q(m))
522
- }, null, 8, ["model-value", "items", "placeholder", "label"]),
523
- ((I = h.value) == null ? void 0 : I.type) === l(fe).Timestamp ? (u(), k(_, {
524
- key: 0,
525
- modelValue: x.value,
526
- "onUpdate:modelValue": e[3] || (e[3] = (m) => x.value = m),
527
- items: d.value,
528
- placeholder: l(i)("report.section.filter.timeFormatter"),
529
- label: l(i)("report.section.filter.timeFormatter")
530
- }, null, 8, ["modelValue", "items", "placeholder", "label"])) : M("", !0),
531
- me.value ? (u(), k(V, {
532
- key: 1,
533
- modelValue: S.value,
534
- "onUpdate:modelValue": e[4] || (e[4] = (m) => S.value = m),
535
- label: l(i)("report.section.filter.customOptions"),
536
- value: !0
537
- }, null, 8, ["modelValue", "label"])) : M("", !0),
538
- me.value && S.value ? (u(), N("div", ol, [
539
- oe.value ? (u(!0), N(xe, { key: 0 }, Ee(B.value, (m, J) => (u(), N("div", {
540
- key: `custom-time-range-${J}`,
541
- class: "flex flex-col gap-2"
542
- }, [
543
- b("div", al, [
544
- r(g, {
545
- modelValue: m.name,
546
- "onUpdate:modelValue": (ae) => m.name = ae,
547
- label: l(i)("report.section.filter.label")
548
- }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
549
- r(O, {
550
- "model-value": w(m.startTime),
551
- label: l(i)("report.date.startingTime"),
552
- "onUpdate:modelValue": (ae) => Te(J, "startTime", ae)
553
- }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
554
- r(O, {
555
- "model-value": w(m.endTime),
556
- label: l(i)("report.date.endingTime"),
557
- "onUpdate:modelValue": (ae) => Te(J, "endTime", ae)
558
- }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
559
- B.value.length > 1 ? (u(), N("div", nl, [
560
- r(X, {
561
- icon: "delete",
562
- variant: "tertiary",
563
- onClick: (ae) => ke(J)
564
- }, null, 8, ["onClick"])
565
- ])) : M("", !0)
566
- ])
567
- ]))), 128)) : (u(), N(xe, { key: 1 }, [
568
- b("p", rl, L(l(i)("report.section.filter.operator")), 1),
569
- ce.value.length > 0 ? (u(), k(et, {
570
- key: 0,
571
- "model-value": se.value,
572
- items: ce.value,
573
- placeholder: l(i)("report.section.filter.operator"),
574
- "onUpdate:modelValue": e[5] || (e[5] = (m) => ee(m))
575
- }, null, 8, ["model-value", "items", "placeholder"])) : M("", !0),
576
- (u(!0), N(xe, null, Ee(U.value, (m, J) => (u(), N("div", {
577
- key: `custom-option-${J}`,
578
- class: "flex flex-col gap-2"
579
- }, [
580
- b("div", {
581
- class: Pe([
582
- "grid grid-cols-1 gap-2 p-2 sm:items-end text-fm-color-typo-primary fm-typo-en-body-lg-600 border-neutral-300 rounded-md border",
583
- "sm:grid-cols-[1fr_1.6fr_auto]"
584
- ])
585
- }, [
586
- b("span", il, L(l(i)("report.section.filter.label")), 1),
587
- r(g, {
588
- modelValue: m.label,
589
- "onUpdate:modelValue": (ae) => m.label = ae
590
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
591
- (u(), k(Ot, {
592
- key: `custom-option-value-${J}-${m.operator ?? ""}-${x.value ?? ""}`,
593
- modelValue: m.values,
594
- "onUpdate:modelValue": (ae) => m.values = ae,
595
- config: ye(m.operator),
596
- option: x.value
597
- }, null, 8, ["modelValue", "onUpdate:modelValue", "config", "option"])),
598
- U.value.length > 1 ? (u(), N("div", sl, [
599
- r(X, {
600
- icon: "delete",
601
- variant: "tertiary",
602
- onClick: (ae) => pe(J)
603
- }, null, 8, ["onClick"])
604
- ])) : M("", !0)
605
- ])
606
- ]))), 128))
607
- ], 64)),
608
- r(X, {
609
- class: "w-full",
610
- variant: "primary",
611
- icon: "add",
612
- "icon-position": "prepend",
613
- onClick: e[6] || (e[6] = (m) => oe.value ? Fe() : Ve())
614
- })
615
- ])) : M("", !0),
616
- r(V, {
617
- modelValue: G.value,
618
- "onUpdate:modelValue": e[7] || (e[7] = (m) => G.value = m),
619
- label: l(i)("report.section.filter.advance"),
620
- value: !0
621
- }, null, 8, ["modelValue", "label"]),
622
- G.value ? (u(), k(re, {
623
- key: 3,
624
- modelValue: E.value,
625
- "onUpdate:modelValue": e[8] || (e[8] = (m) => E.value = m),
626
- placeholder: l(i)("report.section.filter.dataFormula")
627
- }, null, 8, ["modelValue", "placeholder"])) : M("", !0),
628
- r(It, {
629
- modelValue: W.value,
630
- "onUpdate:modelValue": e[9] || (e[9] = (m) => W.value = m),
631
- options: ne.value
632
- }, null, 8, ["modelValue", "options"]),
633
- r(ie, { class: "mt-2 fm-typo-en-body-lg-600" }, {
634
- default: y(() => [
635
- Ae(L(l(i)("report.section.filter.applyWidget")), 1)
636
- ]),
637
- _: 1
638
- }),
639
- R.tiles.length > 0 ? (u(), N("div", ul, [
640
- (u(!0), N(xe, null, Ee(A.value, (m) => (u(), N("div", {
641
- key: m.value,
642
- class: "flex items-center"
643
- }, [
644
- r(V, {
645
- modelValue: $.value,
646
- "onUpdate:modelValue": e[10] || (e[10] = (J) => $.value = J),
647
- label: m.label,
648
- value: m.value
649
- }, null, 8, ["modelValue", "label", "value"]),
650
- C(m) ? (u(), k(Le, {
651
- key: 0,
652
- content: l(i)("report.section.filter.missingFilterSchema"),
653
- "z-index": 99,
654
- class: "ml-2"
655
- }, {
656
- default: y(() => [
657
- r(j, {
658
- name: "warning",
659
- class: "text-fm-color-system-error-300"
660
- })
661
- ]),
662
- _: 1
663
- }, 8, ["content"])) : M("", !0)
664
- ]))), 128))
665
- ])) : (u(), k(ie, {
666
- key: 5,
667
- class: "fm-typo-en-body-lg-400",
668
- label: l(i)("report.section.filter.noWidget")
669
- }, null, 8, ["label"]))
670
- ];
671
- }),
672
- _: 1
673
- }, 512)
674
- ]),
675
- "dialog-footer": y(() => [
676
- e[12] || (e[12] = b("div", { class: "grow" }, null, -1)),
677
- r(X, {
678
- label: l(i)("report.common.cancel"),
679
- variant: "tertiary",
680
- onClick: ve
681
- }, null, 8, ["label"]),
682
- r(X, {
683
- label: l(i)("report.common.confirm"),
684
- onClick: Y
685
- }, null, 8, ["label"])
686
- ]),
687
- _: 1
688
- }, 8, ["modelValue"]);
689
- };
690
- }
691
- }), ml = 8.4375, cl = 1024 ** 4, pl = {
692
- MY: { rate: 4, currency: "MYR", symbol: "RM" },
693
- TH: { rate: 33, currency: "THB", symbol: "฿" },
694
- SG: { rate: 1.29, currency: "SGD", symbol: "S$" },
695
- ID: { rate: 17900, currency: "IDR", symbol: "Rp" }
696
- }, vl = { rate: 1, currency: "USD", symbol: "$" };
697
- function dt(R, i) {
698
- const a = R / cl * ml, { rate: c, currency: p, symbol: f } = pl[i] ?? vl;
699
- return {
700
- amount: a * c,
701
- currency: p,
702
- symbol: f,
703
- costUsd: a
704
- };
705
- }
706
- function mt(R, i) {
707
- return R < 0.01 ? `< ${i}0.01` : `${i}${R.toFixed(2)}`;
708
- }
709
- const fl = { class: "flex flex-col gap-16" }, gl = {
710
- key: 0,
711
- class: "flex flex-col gap-8"
712
- }, bl = { class: "flex items-center gap-4 pb-8 border-b border-neutral-300" }, yl = ["title"], hl = {
713
- key: 1,
714
- class: "rounded-md border border-dashed border-neutral-300 p-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
715
- }, _l = ["onClick"], wl = ["title"], Fl = {
716
- key: 0,
717
- class: "text-fm-color-typo-secondary"
718
- }, xl = { class: "text-fm-color-system-error-300" }, Cl = { class: "w-full text-left" }, Vl = /* @__PURE__ */ Ce({
719
- __name: "TileDrillPanel",
720
- props: {
721
- report: {}
722
- },
723
- emits: ["add-widget"],
724
- setup(R, { emit: i }) {
725
- const a = R, c = i, { t: p, te: f } = ze(), q = nt(), le = rt(), { promptMessage: T } = it(), h = at(), x = v(() => {
726
- const n = [];
727
- let d = a.report.tiles;
728
- for (const A of Ue.value) {
729
- const ne = d.find((te) => te.id === A);
730
- if (!ne) break;
731
- n.push(ne), d = ne.tiles ?? [];
732
- }
733
- return n;
734
- });
735
- he(x, (n) => {
736
- n.length !== Ue.value.length && (Ue.value = n.map((d) => d.id));
737
- });
738
- const $ = v(() => x.value[x.value.length - 1] ?? null), W = v(() => x.value[x.value.length - 2] ?? null), E = v(
739
- () => $.value ? $.value.tiles ?? [] : a.report.tiles
740
- ), G = v(() => {
741
- var n;
742
- return ((n = $.value) == null ? void 0 : n.id) ?? null;
743
- }), S = v(() => x.value.length === 0), U = v(() => {
744
- var n;
745
- return ((n = $.value) == null ? void 0 : n.tab) === !0;
746
- }), B = v(() => {
747
- var n;
748
- return ((n = W.value) == null ? void 0 : n.tab) === !0;
749
- }), se = v(
750
- () => x.value.reduce((n, d) => d.tab ? n : n + 1, 1)
751
- ), de = v(() => !U.value && se.value < yt), K = v(() => S.value);
752
- function w(n) {
753
- n.widget || (Ue.value = [...Ue.value, n.id]);
754
- }
755
- function _e() {
756
- Ue.value = Ue.value.slice(0, -1);
757
- }
758
- function me(n) {
759
- if (!n) return "";
760
- const d = `report.widget.types.${n.toLowerCase()}`;
761
- return f(d) ? p(d) : Ge(p, f, n, "other");
762
- }
763
- function oe(n, d) {
764
- return n.widget ? n.widget.title ? me(n.widget.title) : p("report.editor.widget", { index: d + 1 }) : n.tabTitle !== void 0 ? n.tabTitle || p("report.editor.tab", { index: d + 1 }) : n.tab ? p("report.editor.tabGroup") : p("report.editor.group");
765
- }
766
- function ce(n, d) {
767
- return !n.widget && U.value ? n.tabTitle || p("report.editor.tab", { index: d + 1 }) : oe(n, d);
768
- }
769
- function ge(n) {
770
- var d;
771
- return ((d = n.tiles) == null ? void 0 : d.length) ?? 0;
772
- }
773
- const ye = v(
774
- () => x.value.map((n, d) => oe(n, d)).join(" › ")
775
- );
776
- function P(n, d) {
777
- bt.value = G.value, h.editingTileIndex = d, h.editingTile = JSON.parse(JSON.stringify(n)), q.push({ name: "tileEditor", query: le.query });
778
- }
779
- function H(n, d) {
780
- E.value.splice(d + 1, 0, Mt(n));
781
- }
782
- async function Z(n, d) {
783
- var te;
784
- if (!await T({
785
- title: p("report.editor.deleteWidget"),
786
- message: p("report.editor.deleteWidgetConfirm", { title: ce(n, d) })
787
- })) return;
788
- const ne = st(n);
789
- E.value.splice(d, 1), (te = a.report.globalFilters) == null || te.forEach((Q) => {
790
- var ue;
791
- Q.tileIds = (ue = Q.tileIds) == null ? void 0 : ue.filter((Y) => !ne.includes(Y));
792
- });
793
- }
794
- function be() {
795
- $.value && ($.value.tiles || ($.value.tiles = []), $.value.tiles.push(qt($.value.tiles.length + 1)));
796
- }
797
- function we() {
798
- E.value.push(Et());
799
- }
800
- function ee() {
801
- E.value.push(Pt());
802
- }
803
- function Ve(n) {
804
- var A;
805
- const d = Number((A = n.size) == null ? void 0 : A.width);
806
- n.size || (n.size = { width: 12, height: 12 }), !Number.isFinite(d) || d < 1 ? n.size.width = 1 : d > 12 && (n.size.width = 12);
807
- }
808
- function pe(n) {
809
- var A;
810
- const d = Number((A = n.size) == null ? void 0 : A.height);
811
- n.size || (n.size = { width: 12, height: 12 }), !Number.isFinite(d) || d < 1 ? n.size.height = 1 : d > 12 && (n.size.height = 12);
812
- }
813
- const Fe = z(!1), ke = z(null), Te = z([]);
814
- function $e(n) {
815
- const d = [
816
- { parentId: null, label: p("report.editor.topLevel"), level: 1 }
817
- ], A = (te, Q, ue) => {
818
- let Y = 0;
819
- te.forEach((ve) => {
820
- var De;
821
- if (!ve.widget)
822
- if (ve.tab) {
823
- const C = `${ue}${p("report.editor.tabGroup")}`;
824
- (De = ve.tiles) == null || De.forEach((t, e) => {
825
- const g = `${C} › ${t.tabTitle || p("report.editor.tab", { index: e + 1 })}`;
826
- d.push({ parentId: t.id, label: g, level: Q + 1 }), A(t.tiles ?? [], Q + 1, `${g} › `);
827
- });
828
- } else {
829
- Y += 1;
830
- const C = `${ue}${p("report.editor.group")} ${Y}`;
831
- d.push({ parentId: ve.id, label: C, level: Q + 1 }), A(ve.tiles ?? [], Q + 1, `${C} › `);
832
- }
833
- });
834
- };
835
- A(a.report.tiles, 1, "");
836
- const ne = new Set(st(n));
837
- return d.filter(
838
- (te) => te.parentId !== G.value && !(te.parentId && ne.has(te.parentId)) && Lt(n, te.level)
839
- );
840
- }
841
- function Se(n) {
842
- ke.value = n, Te.value = $e(n), Fe.value = !0;
843
- }
844
- function Me(n) {
845
- const d = ke.value;
846
- if (!d) return;
847
- const A = E.value.indexOf(d);
848
- A >= 0 && E.value.splice(A, 1), zt(a.report.tiles, n.parentId).push(d), Fe.value = !1, ke.value = null;
849
- }
850
- return (n, d) => {
851
- const A = F("FmButton"), ne = F("FmTextField"), te = F("FmIcon"), Q = F("FmMenuItem"), ue = F("FmMenu"), Y = F("FmList"), ve = F("FmListItem"), De = F("FmDialog");
852
- return u(), N("div", fl, [
853
- S.value ? M("", !0) : (u(), N("div", gl, [
854
- b("div", bl, [
855
- r(A, {
856
- icon: "arrow_back",
857
- variant: "tertiary",
858
- class: "-ml-8",
859
- onClick: _e
860
- }),
861
- b("p", {
862
- class: "fm-typo-en-body-md-600 line-clamp-1 overflow-hidden break-all min-w-0 grow text-left",
863
- title: ye.value
864
- }, L(ye.value), 9, yl)
865
- ]),
866
- B.value && $.value ? (u(), k(ne, {
867
- key: 0,
868
- modelValue: $.value.tabTitle,
869
- "onUpdate:modelValue": d[0] || (d[0] = (C) => $.value.tabTitle = C),
870
- label: l(p)("report.editor.tabName"),
871
- placeholder: l(p)("report.editor.tabName")
872
- }, null, 8, ["modelValue", "label", "placeholder"])) : M("", !0),
873
- !B.value && $.value ? (u(), k(ne, {
874
- key: 1,
875
- modelValue: $.value.size.width,
876
- "onUpdate:modelValue": d[1] || (d[1] = (C) => $.value.size.width = C),
877
- modelModifiers: { number: !0 },
878
- type: "number",
879
- label: l(p)("report.editor.width"),
880
- onBlur: d[2] || (d[2] = (C) => Ve($.value))
881
- }, null, 8, ["modelValue", "label"])) : M("", !0),
882
- !B.value && $.value ? (u(), k(ne, {
883
- key: 2,
884
- modelValue: $.value.size.height,
885
- "onUpdate:modelValue": d[3] || (d[3] = (C) => $.value.size.height = C),
886
- modelModifiers: { number: !0 },
887
- type: "number",
888
- label: l(p)("report.editor.height"),
889
- onBlur: d[4] || (d[4] = (C) => pe($.value))
890
- }, null, 8, ["modelValue", "label"])) : M("", !0)
891
- ])),
892
- E.value.length === 0 ? (u(), N("div", hl, L(l(p)("report.editor.emptyLevel")), 1)) : (u(), k(Y, { key: 2 }, {
893
- default: y(() => [
894
- r(l(gt), {
895
- list: E.value,
896
- "item-key": "id",
897
- class: "flex flex-col gap-2 cursor-grab",
898
- handle: ".handle"
899
- }, {
900
- item: y(({ element: C, index: t }) => [
901
- b("div", {
902
- class: Pe(["flex items-center gap-8 px-12 py-8 border rounded-md border-neutral-300 hover:bg-fm-color-opacity-sm", C.widget ? "cursor-grab" : "cursor-pointer"]),
903
- onClick: (e) => w(C)
904
- }, [
905
- r(te, {
906
- name: "drag_handle",
907
- class: "handle shrink-0 !cursor-grab"
908
- }),
909
- b("p", {
910
- class: "flex-1 min-w-0 truncate text-left fm-typo-en-body-lg-400",
911
- title: ce(C, t)
912
- }, [
913
- Ae(L(ce(C, t)) + " ", 1),
914
- C.widget ? M("", !0) : (u(), N("span", Fl, " · " + L(ge(C)), 1))
915
- ], 8, wl),
916
- C.widget ? M("", !0) : (u(), k(te, {
917
- key: 0,
918
- name: "chevron_right",
919
- class: "shrink-0"
920
- })),
921
- r(ue, {
922
- trigger: "click",
923
- shift: !0,
924
- "stop-click-propagation": !0,
925
- class: "shrink-0"
926
- }, {
927
- "menu-button": y(() => [
928
- r(A, {
929
- "append-icon": "more_vert",
930
- variant: "tertiary"
931
- })
932
- ]),
933
- default: y(() => [
934
- C.widget ? (u(), k(Q, {
935
- key: 0,
936
- label: l(p)("report.common.edit"),
937
- onClick: (e) => P(C, t)
938
- }, null, 8, ["label", "onClick"])) : M("", !0),
939
- C.tab ? M("", !0) : (u(), k(Q, {
940
- key: 1,
941
- label: l(p)("report.editor.moveTo"),
942
- onClick: (e) => Se(C)
943
- }, null, 8, ["label", "onClick"])),
944
- r(Q, {
945
- label: l(p)("report.common.duplicate"),
946
- onClick: (e) => H(C, t)
947
- }, null, 8, ["label", "onClick"]),
948
- r(Q, {
949
- onClick: (e) => Z(C, t)
950
- }, {
951
- label: y(() => [
952
- b("p", xl, L(l(p)("report.common.remove")), 1)
953
- ]),
954
- _: 2
955
- }, 1032, ["onClick"])
956
- ]),
957
- _: 2
958
- }, 1024)
959
- ], 10, _l)
960
- ]),
961
- _: 1
962
- }, 8, ["list"])
963
- ]),
964
- _: 1
965
- })),
966
- U.value ? (u(), k(A, {
967
- key: 3,
968
- label: l(p)("report.editor.addTab"),
969
- variant: "secondary",
970
- icon: "add",
971
- "icon-position": "prepend",
972
- "border-color": l(Ie).ColorPrimary,
973
- "text-color": l(Ie).ColorPrimary,
974
- onClick: be
975
- }, null, 8, ["label", "border-color", "text-color"])) : (u(), k(ue, {
976
- key: 4,
977
- trigger: "click",
978
- shift: !0
979
- }, {
980
- "menu-button": y(() => [
981
- r(A, {
982
- label: l(p)("report.common.add"),
983
- variant: "secondary",
984
- icon: "add",
985
- "icon-position": "prepend",
986
- class: "w-full",
987
- "border-color": l(Ie).ColorPrimary,
988
- "text-color": l(Ie).ColorPrimary
989
- }, null, 8, ["label", "border-color", "text-color"])
990
- ]),
991
- default: y(() => [
992
- r(Q, {
993
- label: l(p)("report.editor.addWidget"),
994
- onClick: d[5] || (d[5] = (C) => c("add-widget", G.value))
995
- }, null, 8, ["label"]),
996
- de.value ? (u(), k(Q, {
997
- key: 0,
998
- label: l(p)("report.editor.addGroup"),
999
- onClick: we
1000
- }, null, 8, ["label"])) : M("", !0),
1001
- K.value ? (u(), k(Q, {
1002
- key: 1,
1003
- label: l(p)("report.editor.addTabGroup"),
1004
- onClick: ee
1005
- }, null, 8, ["label"])) : M("", !0)
1006
- ]),
1007
- _: 1
1008
- })),
1009
- r(De, {
1010
- modelValue: Fe.value,
1011
- "onUpdate:modelValue": d[6] || (d[6] = (C) => Fe.value = C),
1012
- overlay: !0,
1013
- "z-index": 10
1014
- }, {
1015
- "dialog-header": y(() => [
1016
- Ae(L(l(p)("report.editor.moveTo")), 1)
1017
- ]),
1018
- default: y(() => [
1019
- r(Y, null, {
1020
- default: y(() => [
1021
- (u(!0), N(xe, null, Ee(Te.value, (C) => (u(), k(ve, {
1022
- key: C.parentId ?? "root",
1023
- onClick: (t) => Me(C)
1024
- }, {
1025
- default: y(() => [
1026
- b("p", Cl, L(C.label), 1)
1027
- ]),
1028
- _: 2
1029
- }, 1032, ["onClick"]))), 128))
1030
- ]),
1031
- _: 1
1032
- })
1033
- ]),
1034
- _: 1
1035
- }, 8, ["modelValue"])
1036
- ]);
1037
- };
1038
- }
1039
- }), kl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Tl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, $l = { class: "flex items-center gap-8" }, Sl = {
1040
- key: 2,
1041
- class: "flex flex-col gap-8 rounded-md border border-fm-color-border px-16 py-12"
1042
- }, Dl = { class: "fm-typo-en-body-sm-400" }, Ol = { class: "fm-typo-en-body-sm-400 font-bold" }, Il = { class: "space-y-1 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Nl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Rl = { class: "flex items-center gap-1 max-w-[195px] w-[195px]" }, Ul = { class: "line-clamp-2 overflow-hidden max-w-[195px] w-[195px]" }, ct = /* @__PURE__ */ Ce({
1043
- __name: "ReportEditorTab",
1044
- props: /* @__PURE__ */ Ne({
1045
- hideConfiguration: {
1046
- type: Boolean,
1047
- default: !1
1048
- }
1049
- }, {
1050
- modelValue: { required: !0 },
1051
- modelModifiers: {}
1052
- }),
1053
- emits: /* @__PURE__ */ Ne(["hideConfiguration"], ["update:modelValue"]),
1054
- setup(R, { emit: i }) {
1055
- const a = Re(R, "modelValue"), { breakpoints: c } = je(), p = R, f = i, q = nt(), le = rt(), T = z(), {
1056
- currentSelectWidgetType: h,
1057
- categories: x,
1058
- editingTile: $,
1059
- editingTileIndex: W,
1060
- editingGlobalFilter: E,
1061
- editingGlobalFilterIndex: G
1062
- } = Be(at()), { schemas: S } = Be(At()), { globalFilters: U } = Be(Ye()), { getGlobalFilterLabel: B } = Ye(), { promptMessage: se } = it(), de = z(!1), K = z(!1), { t: w, te: _e, locale: me } = ze(), oe = z(void 0), ce = v(() => {
1063
- const s = Xe(a.value.tiles).flatMap((o) => {
1064
- var J;
1065
- const I = o.widget.config.schemaNames ?? [], m = ((J = o.widget.config.joinDatasources) == null ? void 0 : J.flatMap((ae) => ae.schemaNames ?? [])) ?? [];
1066
- return [...I, ...m];
1067
- });
1068
- return [...new Set(s)].reduce((o, I) => {
1069
- const m = S.value.find((J) => J.name === I);
1070
- return m && o.push(m), o;
1071
- }, []);
1072
- }), ge = z(null);
1073
- function ye(s) {
1074
- ge.value = s, K.value = !0;
1075
- }
1076
- he(
1077
- () => h.value,
1078
- () => {
1079
- h.value !== void 0 && (oe.value = Nt(h.value), $.value = oe.value, W.value = -1, bt.value = ge.value, q.push({
1080
- name: "tileEditor",
1081
- query: le.query
1082
- }));
1083
- },
1084
- { immediate: !0 }
1085
- ), he(
1086
- () => a.value.tiles,
1087
- (s) => {
1088
- Gt(s);
1089
- },
1090
- { immediate: !0, deep: !0 }
1091
- );
1092
- const P = [
1093
- {
1094
- label: "report.common.edit",
1095
- selected: !1,
1096
- variant: "tertiary",
1097
- onClick: (s) => {
1098
- var o;
1099
- G.value = s, E.value = JSON.parse(JSON.stringify((o = a.value.globalFilters) == null ? void 0 : o[s])), de.value = !0;
1100
- }
1101
- },
1102
- {
1103
- label: "report.common.duplicate",
1104
- selected: !1,
1105
- variant: "tertiary",
1106
- onClick: (s) => {
1107
- var m;
1108
- const o = (m = a.value.globalFilters) == null ? void 0 : m[s];
1109
- if (!o) return;
1110
- const I = JSON.parse(JSON.stringify(o));
1111
- a.value.globalFilters || (a.value.globalFilters = []), a.value.globalFilters.push(I);
1112
- }
1113
- },
1114
- {
1115
- label: "report.common.remove",
1116
- selected: !1,
1117
- variant: "destructive",
1118
- onClick: async (s) => {
1119
- var m, J;
1120
- const o = (m = a.value.globalFilters) == null ? void 0 : m[s];
1121
- if (!o) return;
1122
- await se({
1123
- title: w("report.editor.deleteWidget"),
1124
- message: w("report.editor.deleteWidgetConfirm", {
1125
- title: B(o)
1126
- })
1127
- }) && ((J = a.value.globalFilters) == null || J.splice(s, 1));
1128
- }
1129
- }
1130
- ], H = v(() => x.value.map((s) => ({
1131
- label: w(`report.category.${s.name}`),
1132
- value: s.id
1133
- }))), { sessionUser: Z } = Kt(), be = v(
1134
- () => {
1135
- var s, o, I, m;
1136
- return ((o = (s = Z.value) == null ? void 0 : s.role) == null ? void 0 : o.isAdmin) === !0 || ((m = (I = Z.value) == null ? void 0 : I.role) == null ? void 0 : m.isStaff) === !0;
1137
- }
1138
- ), we = v({
1139
- get: () => a.value.queryVersion === "v2",
1140
- set: (s) => {
1141
- a.value.queryVersion = s ? "v2" : "v1", s ? a.value.queryDatasource = a.value.queryDatasource ?? He.Postgres : a.value.queryDatasource = void 0;
1142
- }
1143
- }), ee = [
1144
- { label: w("report.common.postgresql"), value: He.Postgres },
1145
- { label: w("report.common.bigquery"), value: He.BigQuery }
1146
- ], Ve = [
1147
- { label: w("report.common.noBatch"), value: "none" },
1148
- { label: w("report.common.days"), value: "days" },
1149
- { label: w("report.common.locations"), value: "locations" }
1150
- ], pe = v({
1151
- get: () => {
1152
- var s, o;
1153
- return (s = a.value.batch) != null && s.days ? "days" : (o = a.value.batch) != null && o.locations ? "locations" : "none";
1154
- },
1155
- set: (s) => {
1156
- var o, I;
1157
- s === "none" ? a.value.batch = void 0 : s === "days" ? a.value.batch = { days: ((o = a.value.batch) == null ? void 0 : o.days) || 1 } : s === "locations" && (a.value.batch = { locations: ((I = a.value.batch) == null ? void 0 : I.locations) || 10 });
1158
- }
1159
- }), Fe = v({
1160
- get: () => {
1161
- var s, o;
1162
- if (pe.value === "days") return ((s = a.value.batch) == null ? void 0 : s.days) ?? 1;
1163
- if (pe.value === "locations") return ((o = a.value.batch) == null ? void 0 : o.locations) ?? 1;
1164
- },
1165
- set: (s) => {
1166
- s && (pe.value === "days" ? a.value.batch = { days: s } : pe.value === "locations" && (a.value.batch = { locations: s }));
1167
- }
1168
- }), ke = v({
1169
- get: () => Ge(w, _e, a.value.name, "other"),
1170
- set: (s) => {
1171
- a.value.name = s;
1172
- }
1173
- }), { country: Te } = Be(Qt()), {
1174
- dateRange: $e,
1175
- compareDateRange: Se,
1176
- timeRange: Me,
1177
- selectedLocationIds: n,
1178
- businessDataVersion: d,
1179
- restaurants: A,
1180
- warehouses: ne
1181
- } = Be(Yt()), { isAllGlobalFiltersLoaded: te } = Be(Ye()), Q = v(
1182
- () => a.value.queryVersion === "v2" && a.value.queryDatasource === He.BigQuery
1183
- ), ue = v(() => Q.value && be.value), Y = z(null), ve = z(!1), De = v(() => {
1184
- const s = $e.value.startDate ?? $e.value.endDate;
1185
- return s ? {
1186
- startDate: s,
1187
- endDate: s
1188
- } : $e.value;
1189
- }), C = v(() => {
1190
- const s = Se.value.startDate ?? Se.value.endDate;
1191
- return s ? {
1192
- startDate: s,
1193
- endDate: s
1194
- } : Se.value;
1195
- }), t = v(() => {
1196
- const s = a.value.batch;
1197
- if (!s) return 1;
1198
- if (s.locations) {
1199
- const o = A.value.length + ne.value.length;
1200
- return Math.max(1, Math.ceil(o / s.locations));
1201
- }
1202
- return 1;
1203
- }), e = v(() => {
1204
- if (Y.value == null || Y.value === 0) return null;
1205
- const s = Y.value * t.value;
1206
- return dt(s, Te.value);
1207
- }), g = v(() => Y.value == null || Y.value === 0 ? null : dt(Y.value, Te.value)), _ = v(() => e.value ? mt(e.value.amount, e.value.symbol) : ""), V = v(() => g.value ? mt(g.value.amount, g.value.symbol) : ""), O = v(() => t.value === 1 ? w("report.common.estimatedCostBatchSingular") : w("report.common.estimatedCostBatchPlural")), X = v(() => ve.value ? "..." : !_.value || !V.value ? "--" : w("report.common.estimatedCostFormula", {
1208
- batchCount: t.value,
1209
- batchLabel: O.value,
1210
- baseCost: V.value,
1211
- totalCost: _.value
1212
- }));
1213
- let re = [];
1214
- const ie = Xt(async () => {
1215
- if (!ue.value) return;
1216
- const s = Xe(a.value.tiles).filter(
1217
- (o) => {
1218
- var I;
1219
- return ((I = o.widget.config.schemaNames) == null ? void 0 : I.length) > 0;
1220
- }
1221
- );
1222
- if (s.length === 0) {
1223
- Y.value = null;
1224
- return;
1225
- }
1226
- ve.value = !0, re.forEach((o) => o.abort()), re = [];
1227
- try {
1228
- const o = await Promise.all(
1229
- s.map((I) => {
1230
- const m = new AbortController();
1231
- return re.push(m), Wt({
1232
- widget: I.widget,
1233
- signal: m.signal,
1234
- tileId: I.id,
1235
- scopedDateRange: De.value,
1236
- scopedCompareDateRange: C.value
1237
- });
1238
- })
1239
- );
1240
- Y.value = o.reduce((I, m) => I + (m.totalBytesProcessed ?? 0), 0);
1241
- } catch (o) {
1242
- o.code !== "ERR_CANCELED" && (Y.value = null);
1243
- } finally {
1244
- ve.value = !1;
1245
- }
1246
- }, 1e3);
1247
- he(
1248
- [
1249
- () => a.value.tiles,
1250
- () => a.value.queryVersion,
1251
- () => a.value.queryDatasource,
1252
- () => a.value.batch,
1253
- () => $e.value,
1254
- () => Me.value,
1255
- () => Se.value,
1256
- () => n.value,
1257
- () => d.value,
1258
- () => te.value
1259
- ],
1260
- () => {
1261
- ie();
1262
- },
1263
- { deep: !0 }
1264
- ), vt(() => {
1265
- ie();
1266
- }), Tt(() => {
1267
- re.forEach((s) => s.abort());
1268
- });
1269
- function j(s) {
1270
- var o;
1271
- return !((o = s.tileIds) != null && o.length);
1272
- }
1273
- function Le(s) {
1274
- return !ce.value.find((o) => o.name === s.schemaName);
1275
- }
1276
- return he(
1277
- () => a.value.globalFilters,
1278
- (s) => {
1279
- U.value = JSON.parse(JSON.stringify(s || []));
1280
- },
1281
- { deep: !0, immediate: !0 }
1282
- ), (s, o) => {
1283
- const I = F("FmTextField"), m = F("FmSelect"), J = F("FmSwitch"), ae = F("FmButton"), Je = F("FmIcon"), Ke = F("FmTooltip"), _t = F("FmMenuItem"), wt = F("FmMenu"), Ft = F("FmListItem"), xt = F("FmList"), Ct = F("FmForm");
1284
- return u(), k($t(l(c).lg || l(c).md ? tl : ll), {
1285
- "model-value": p.hideConfiguration,
1286
- "onUpdate:modelValue": o[12] || (o[12] = (D) => f("hideConfiguration", D))
1287
- }, {
1288
- default: y(() => [
1289
- r(dl, {
1290
- "is-open": de.value,
1291
- "onUpdate:isOpen": o[0] || (o[0] = (D) => de.value = D),
1292
- "global-filter": l(E),
1293
- tiles: l(Xe)(a.value.tiles),
1294
- schemas: ce.value,
1295
- "onUpdate:globalFilter": o[1] || (o[1] = (D) => {
1296
- D && (a.value.globalFilters || (a.value.globalFilters = []), typeof l(G) == "number" && l(G) >= 0 ? a.value.globalFilters[l(G)] = D : a.value.globalFilters.push(D));
1297
- })
1298
- }, null, 8, ["is-open", "global-filter", "tiles", "schemas"]),
1299
- r(Zt, {
1300
- modelValue: l(h),
1301
- "onUpdate:modelValue": o[2] || (o[2] = (D) => ft(h) ? h.value = D : null),
1302
- "is-open": K.value,
1303
- "onUpdate:isOpen": o[3] || (o[3] = (D) => K.value = D)
1304
- }, null, 8, ["modelValue", "is-open"]),
1305
- r(Ct, {
1306
- ref_key: "form",
1307
- ref: T,
1308
- class: "px-6 py-16 flex flex-col gap-24 overflow-y-auto overflow-x-hidden"
1309
- }, {
1310
- default: y(() => [
1311
- r(We, { class: "border-solid" }, {
1312
- header: y(() => [
1313
- b("p", null, L(l(w)("report.editor.reportInfo")), 1),
1314
- o[13] || (o[13] = b("div", { class: "grow" }, null, -1))
1315
- ]),
1316
- content: y(() => [
1317
- b("div", kl, [
1318
- r(I, {
1319
- modelValue: ke.value,
1320
- "onUpdate:modelValue": o[4] || (o[4] = (D) => ke.value = D),
1321
- label: l(w)("report.common.name"),
1322
- placeholder: l(w)("report.common.name")
1323
- }, null, 8, ["modelValue", "label", "placeholder"]),
1324
- (u(), k(m, {
1325
- key: `category-${l(me)}`,
1326
- modelValue: a.value.category,
1327
- "onUpdate:modelValue": o[5] || (o[5] = (D) => a.value.category = D),
1328
- label: l(w)("report.common.category"),
1329
- items: H.value
1330
- }, null, 8, ["modelValue", "label", "items"])),
1331
- r(I, {
1332
- modelValue: a.value.description,
1333
- "onUpdate:modelValue": o[6] || (o[6] = (D) => a.value.description = D),
1334
- label: l(w)("report.common.description"),
1335
- placeholder: l(w)("report.common.description")
1336
- }, null, 8, ["modelValue", "label", "placeholder"])
1337
- ])
1338
- ]),
1339
- _: 1
1340
- }),
1341
- r(We, {
1342
- class: "border-solid",
1343
- "is-open": !1
1344
- }, {
1345
- header: y(() => [
1346
- b("p", null, L(l(w)("report.editor.advancedUsage")), 1),
1347
- o[14] || (o[14] = b("div", { class: "grow" }, null, -1))
1348
- ]),
1349
- content: y(() => [
1350
- b("div", Tl, [
1351
- b("div", $l, [
1352
- o[15] || (o[15] = b("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, "V2", -1)),
1353
- r(J, {
1354
- modelValue: we.value,
1355
- "onUpdate:modelValue": o[7] || (o[7] = (D) => we.value = D)
1356
- }, null, 8, ["modelValue"])
1357
- ]),
1358
- we.value && be.value ? (u(), k(m, {
1359
- key: 0,
1360
- modelValue: a.value.queryDatasource,
1361
- "onUpdate:modelValue": o[8] || (o[8] = (D) => a.value.queryDatasource = D),
1362
- label: l(w)("report.common.queryDatasource"),
1363
- items: ee
1364
- }, null, 8, ["modelValue", "label"])) : M("", !0),
1365
- r(m, {
1366
- modelValue: pe.value,
1367
- "onUpdate:modelValue": o[9] || (o[9] = (D) => pe.value = D),
1368
- label: l(w)("report.common.batch"),
1369
- items: Ve
1370
- }, null, 8, ["modelValue", "label"]),
1371
- pe.value !== "none" ? (u(), k(I, {
1372
- key: 1,
1373
- modelValue: Fe.value,
1374
- "onUpdate:modelValue": o[10] || (o[10] = (D) => Fe.value = D),
1375
- modelModifiers: { number: !0 },
1376
- label: pe.value === "days" ? l(w)("report.common.days") : l(w)("report.common.locations"),
1377
- type: "number"
1378
- }, null, 8, ["modelValue", "label"])) : M("", !0),
1379
- ue.value ? (u(), N("div", Sl, [
1380
- b("span", Dl, L(l(w)("report.common.estimatedBqCost")), 1),
1381
- b("p", Ol, L(X.value), 1),
1382
- b("div", Il, [
1383
- b("div", null, "* " + L(l(w)("report.common.estimatedCostGuidelineBigQuery")), 1),
1384
- b("div", null, "* " + L(l(w)("report.common.estimatedCostGuidelineDateRange")), 1),
1385
- b("div", null, "* " + L(l(w)("report.common.estimatedCostGuidelineLocationBatch")), 1)
1386
- ])
1387
- ])) : M("", !0)
1388
- ])
1389
- ]),
1390
- _: 1
1391
- }),
1392
- r(We, {
1393
- class: "border-solid",
1394
- "is-open": !1
1395
- }, {
1396
- header: y(() => [
1397
- b("p", null, L(l(w)("report.section.filter.globalFilter")), 1),
1398
- o[16] || (o[16] = b("div", { class: "grow" }, null, -1))
1399
- ]),
1400
- content: y(() => [
1401
- b("div", Nl, [
1402
- r(ae, {
1403
- label: l(w)("report.section.filter.addGlobalFilter"),
1404
- variant: "secondary",
1405
- icon: "add",
1406
- "icon-position": "prepend",
1407
- "border-color": l(Ie).ColorPrimary,
1408
- "text-color": l(Ie).ColorPrimary,
1409
- onClick: o[11] || (o[11] = () => {
1410
- G.value = null, E.value = null, de.value = !0;
1411
- })
1412
- }, null, 8, ["label", "border-color", "text-color"]),
1413
- r(xt, null, {
1414
- default: y(() => [
1415
- r(l(gt), {
1416
- list: a.value.globalFilters,
1417
- "item-key": "`${element.schemaName}-${element.name}`",
1418
- class: "flex flex-col gap-2 cursor-grab",
1419
- handle: ".handle"
1420
- }, {
1421
- item: y(({ element: D, index: Vt }) => [
1422
- r(Ft, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
1423
- default: y(() => [
1424
- r(Je, {
1425
- name: "drag_handle",
1426
- class: "handle"
1427
- }),
1428
- b("div", Rl, [
1429
- r(Ke, {
1430
- "z-index": 99,
1431
- content: l(B)(D),
1432
- class: "handle"
1433
- }, {
1434
- default: y(() => [
1435
- b("p", Ul, L(l(B)(D)), 1)
1436
- ]),
1437
- _: 2
1438
- }, 1032, ["content"]),
1439
- Le(D) ? (u(), k(Ke, {
1440
- key: 0,
1441
- content: l(w)("report.section.filter.missingSchema"),
1442
- "z-index": 99
1443
- }, {
1444
- default: y(() => [
1445
- r(Je, {
1446
- name: "warning",
1447
- class: "text-fm-color-system-error-300"
1448
- })
1449
- ]),
1450
- _: 1
1451
- }, 8, ["content"])) : j(D) ? (u(), k(Ke, {
1452
- key: 1,
1453
- content: l(w)("report.section.filter.missingTileIds"),
1454
- "z-index": 99
1455
- }, {
1456
- default: y(() => [
1457
- r(Je, {
1458
- name: "warning",
1459
- class: "text-fm-color-system-warning-300"
1460
- })
1461
- ]),
1462
- _: 1
1463
- }, 8, ["content"])) : M("", !0)
1464
- ]),
1465
- o[17] || (o[17] = b("div", { class: "grow" }, null, -1)),
1466
- r(wt, {
1467
- trigger: "click",
1468
- shift: !0,
1469
- "stop-click-propagation": !0
1470
- }, {
1471
- "menu-button": y(() => [
1472
- r(ae, {
1473
- "append-icon": "more_vert",
1474
- variant: "tertiary"
1475
- })
1476
- ]),
1477
- default: y(() => [
1478
- (u(), N(xe, null, Ee(P, (Qe, kt) => r(_t, {
1479
- key: kt,
1480
- onClick: (Yl) => Qe.onClick(Vt)
1481
- }, {
1482
- label: y(() => [
1483
- b("p", {
1484
- class: Pe(
1485
- Qe.variant === "destructive" ? " text-fm-color-system-error-300" : ""
1486
- )
1487
- }, L(l(w)(Qe.label)), 3)
1488
- ]),
1489
- _: 2
1490
- }, 1032, ["onClick"])), 64))
1491
- ]),
1492
- _: 2
1493
- }, 1024)
1494
- ]),
1495
- _: 2
1496
- }, 1024)
1497
- ]),
1498
- _: 1
1499
- }, 8, ["list"])
1500
- ]),
1501
- _: 1
1502
- })
1503
- ])
1504
- ]),
1505
- _: 1
1506
- }),
1507
- r(We, { class: "border-solid" }, {
1508
- header: y(() => [
1509
- b("p", null, L(l(w)("report.editor.widgets")), 1),
1510
- o[18] || (o[18] = b("div", { class: "grow" }, null, -1))
1511
- ]),
1512
- content: y(() => [
1513
- r(Vl, {
1514
- report: a.value,
1515
- onAddWidget: ye
1516
- }, null, 8, ["report"])
1517
- ]),
1518
- _: 1
1519
- })
1520
- ]),
1521
- _: 1
1522
- }, 512)
1523
- ]),
1524
- _: 1
1525
- }, 8, ["model-value"]);
1526
- };
1527
- }
1528
- }), Bl = { class: "h-full w-full overflow-x-hidden" }, Ml = { class: "flex flex-col bg-fm-color-neutral-white w-[400px]" }, ql = { class: "flex bg-fm-color-neutral-white w-[88px]" }, El = {
1529
- key: 1,
1530
- class: "w-full overflow-y-auto"
1531
- }, Pl = {
1532
- key: 0,
1533
- class: "w-full grid grid-cols-12 gap-[24px] p-24"
1534
- }, zl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Ll = { key: 2 }, Al = {
1535
- key: 0,
1536
- class: "grid grid-cols-12 gap-[16px]"
1537
- }, Gl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Wl = {
1538
- key: 3,
1539
- class: "h-full w-full flex items-start justify-center bg-fm-color-neutral-white py-24",
1540
- style: { backgroundColor: "#F6F8FC" }
1541
- }, Hl = {
1542
- key: 0,
1543
- class: "w-full grid grid-cols-12 gap-[24px] p-24"
1544
- }, jl = /* @__PURE__ */ Ce({
1545
- __name: "ReportEditorViewport",
1546
- props: /* @__PURE__ */ Ne({
1547
- hideConfiguration: { type: Boolean, required: !1, default: !1 },
1548
- previewWidth: { type: Number, required: !0 },
1549
- previewHeight: { type: Number, required: !0 },
1550
- previewScale: { type: Number, required: !0 }
1551
- }, {
1552
- modelValue: { required: !0, default: () => {
1553
- } },
1554
- modelModifiers: {}
1555
- }),
1556
- emits: /* @__PURE__ */ Ne(["hideConfiguration"], ["update:modelValue"]),
1557
- setup(R, { emit: i }) {
1558
- const { breakpoints: a } = je(), c = Re(R, "modelValue"), p = v(() => {
1559
- var h;
1560
- return Ht((h = c.value) == null ? void 0 : h.tiles);
1561
- }), f = R, q = v(() => f.previewWidth > 0 && f.previewHeight > 0), le = v(() => a.value.sm || a.value.xs), T = i;
1562
- return (h, x) => {
1563
- const $ = F("FmCircularProgress"), W = F("FmButton"), E = F("FmMenuDivider"), G = F("FmCard");
1564
- return u(), N("div", Bl, [
1565
- c.value ? (u(), N(xe, { key: 1 }, [
1566
- q.value ? M("", !0) : (u(), k(Rt, {
1567
- key: 0,
1568
- "model-value": !f.hideConfiguration
1569
- }, {
1570
- right: y(() => [
1571
- b("div", Ml, [
1572
- c.value ? (u(), k(ct, {
1573
- key: 0,
1574
- modelValue: c.value,
1575
- "onUpdate:modelValue": x[0] || (x[0] = (S) => c.value = S),
1576
- "hide-configuration": f.hideConfiguration,
1577
- onHideConfiguration: x[1] || (x[1] = (S) => T("hideConfiguration", S))
1578
- }, null, 8, ["modelValue", "hide-configuration"])) : M("", !0)
1579
- ])
1580
- ]),
1581
- left: y(() => [
1582
- b("div", ql, [
1583
- r(W, {
1584
- variant: "secondary",
1585
- icon: "keyboard_double_arrow_right",
1586
- "border-color": l(Ie).ColorPrimary,
1587
- "text-color": l(Ie).ColorPrimary,
1588
- class: "m-24 my-16",
1589
- size: "md",
1590
- onClick: x[2] || (x[2] = (S) => T("hideConfiguration", !f.hideConfiguration))
1591
- }, null, 8, ["border-color", "text-color"])
1592
- ])
1593
- ]),
1594
- _: 1
1595
- }, 8, ["model-value"])),
1596
- r(E, {
1597
- vertical: "",
1598
- style: { margin: "0px" }
1599
- }),
1600
- !le.value && !q.value ? (u(), N("div", El, [
1601
- c.value.tiles.length > 0 ? (u(), N("div", Pl, [
1602
- b("div", zl, [
1603
- r(ut)
1604
- ]),
1605
- r(Ze, {
1606
- tiles: c.value.tiles,
1607
- "report-id": c.value.id || "editing",
1608
- "leaf-index-by-id": p.value,
1609
- "hide-export": !0
1610
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1611
- ])) : (u(), k(tt, { key: 1 }))
1612
- ])) : le.value && !q.value ? (u(), N("div", Ll, [
1613
- r(G, { class: "px-5 pb-28" }, {
1614
- default: y(() => [
1615
- c.value.tiles.length > 0 ? (u(), N("div", Al, [
1616
- b("div", Gl, [
1617
- r(ut)
1618
- ]),
1619
- r(Ze, {
1620
- tiles: c.value.tiles,
1621
- "report-id": c.value.id || "editing",
1622
- "leaf-index-by-id": p.value,
1623
- "hide-export": !0
1624
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1625
- ])) : (u(), k(tt, { key: 1 }))
1626
- ]),
1627
- _: 1
1628
- }),
1629
- c.value ? (u(), k(ct, {
1630
- key: 0,
1631
- modelValue: c.value,
1632
- "onUpdate:modelValue": x[3] || (x[3] = (S) => c.value = S),
1633
- "hide-configuration": f.hideConfiguration,
1634
- onHideConfiguration: x[4] || (x[4] = (S) => {
1635
- T("hideConfiguration", S);
1636
- })
1637
- }, null, 8, ["modelValue", "hide-configuration"])) : M("", !0)
1638
- ])) : (u(), N("div", Wl, [
1639
- b("div", {
1640
- style: lt({
1641
- transformOrigin: "top center",
1642
- transform: `scale(${f.previewScale})`
1643
- })
1644
- }, [
1645
- b("div", {
1646
- class: "overflow-y-auto bg-white rounded-lg",
1647
- style: lt({
1648
- width: f.previewWidth + "px",
1649
- height: f.previewHeight + "px"
1650
- })
1651
- }, [
1652
- c.value.tiles.length > 0 ? (u(), N("div", Hl, [
1653
- r(Ze, {
1654
- tiles: c.value.tiles,
1655
- "report-id": c.value.id || "editing",
1656
- "leaf-index-by-id": p.value,
1657
- "hide-export": !0,
1658
- "custom-screen-width": f.previewWidth
1659
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id", "custom-screen-width"])
1660
- ])) : (u(), k(tt, { key: 1 }))
1661
- ], 4)
1662
- ], 4)
1663
- ]))
1664
- ], 64)) : (u(), k($, { key: 0 }))
1665
- ]);
1666
- };
1667
- }
1668
- }), Jl = { class: "flex items-center gap-4" }, Kl = { class: "flex justify-center items-center gap-2 w-full" }, Ql = { class: "flex gap-4" }, po = /* @__PURE__ */ Ce({
1669
- __name: "ReportEditor",
1670
- setup(R) {
1671
- const i = nt(), a = rt(), c = at(), { promptLoader: p } = Jt(), { t: f, te: q } = ze(), { currentReport: le, editingReport: T } = Be(c), { breakpoints: h } = je(), x = v(() => {
1672
- var P;
1673
- return !((P = T.value) != null && P.editable);
1674
- }), $ = v(() => {
1675
- var P;
1676
- return ((P = T.value) == null ? void 0 : P.name) ?? f("report.editor.newReport");
1677
- }), W = v(() => Ge(f, q, $.value, "other")), E = ht(), { promptMessage: G } = it(), S = z(!1), U = v(() => [
1678
- { label: f("report.common.cancel"), value: "cancel", isPrimary: !1 },
1679
- { label: f("report.common.save"), value: "save", isPrimary: !0, prependIcon: "download" }
1680
- ]);
1681
- async function B() {
1682
- if (!T.value || T.value.tiles.length === 0) {
1683
- E.open({ message: f("report.messages.noWidget"), type: "error" });
1684
- return;
1685
- }
1686
- if (jt(T.value.tiles) > yt) {
1687
- E.open({ message: f("report.messages.tooDeepNesting"), type: "error" });
1688
- return;
1689
- }
1690
- const P = x.value ? f("report.common.clone") : f("report.common.save");
1691
- if (await G({
1692
- title: `${f("report.messages.saveReport")}`,
1693
- message: f("report.messages.confirmAction", { action: P, name: W.value })
1694
- }))
1695
- try {
1696
- await p(async () => {
1697
- if (x.value) {
1698
- const Z = JSON.parse(JSON.stringify(T.value));
1699
- Z.editable = !0, Z.id = "", Z.name = `${Z.name} ${f("report.common.duplicate")}`, Z.isDefault = !1, await c.createOrUpdateReport(Z);
1700
- } else
1701
- T.value && await c.createOrUpdateReport(T.value);
1702
- i.push({
1703
- name: "reportView",
1704
- query: a.query
1705
- });
1706
- });
1707
- } catch (Z) {
1708
- console.log(Z), E.open({
1709
- message: f("report.messages.failedToAction", { action: P }),
1710
- type: "error"
1711
- });
1712
- }
1713
- }
1714
- async function se() {
1715
- var H;
1716
- if (!T.value) return;
1717
- await G({
1718
- title: f("report.common.report", 1),
1719
- message: f("report.editor.notSaved", { name: (H = T.value) == null ? void 0 : H.name })
1720
- }) && (T.value = JSON.parse(JSON.stringify(le.value)), i.back());
1721
- }
1722
- vt(() => {
1723
- T.value || i.push({ name: "reports" });
1724
- });
1725
- const de = [
1726
- {
1727
- labelKey: "report.common.default",
1728
- width: void 0,
1729
- height: void 0
1730
- },
1731
- {
1732
- labelKey: "report.editor.devices.desktop",
1733
- width: 1920,
1734
- height: 1080
1735
- },
1736
- {
1737
- labelKey: "report.editor.devices.tablet",
1738
- width: 820,
1739
- height: 1180
1740
- },
1741
- {
1742
- labelKey: "report.editor.devices.phone",
1743
- width: 390,
1744
- height: 859
1745
- }
1746
- ], K = z(de[0]), w = z(!1), _e = v(() => w.value ? Math.max(K.value.width || 0, K.value.height || 0) : Math.min(K.value.width || 0, K.value.height || 0)), me = v(() => w.value ? Math.min(K.value.width || 0, K.value.height || 0) : Math.max(K.value.width || 0, K.value.height || 0)), oe = v(() => window.innerHeight - 72 - 56), ce = v(() => {
1747
- if (!_e.value) return 1;
1748
- let P = (oe.value - 48) / _e.value, H = me.value * P;
1749
- return H > window.innerWidth && (P = window.innerWidth / me.value, H = me.value * P), P > 1 ? 1 : P;
1750
- });
1751
- function ge(P) {
1752
- K.value = P;
1753
- }
1754
- function ye() {
1755
- w.value = !w.value;
1756
- }
1757
- return (P, H) => {
1758
- const Z = F("FmTooltip"), be = F("FmButton"), we = F("FmPageHead");
1759
- return u(), k(Ut, null, {
1760
- default: y(() => [
1761
- r(we, {
1762
- "data-editor-header": "true",
1763
- actions: U.value,
1764
- "onClick:action": H[0] || (H[0] = (ee) => {
1765
- ee === "cancel" && se(), ee === "save" && B();
1766
- })
1767
- }, {
1768
- title: y(() => [
1769
- b("div", Jl, [
1770
- r(Z, {
1771
- content: W.value,
1772
- placement: "bottom"
1773
- }, {
1774
- default: y(() => [
1775
- b("p", {
1776
- class: Pe(`${l(h).sm || l(h).xs ? "hidden" : ""} text-ellipsis overflow-hidden text-nowrap fm-typo-en-title-md-600 w-[250px]`)
1777
- }, L(W.value), 3)
1778
- ]),
1779
- _: 1
1780
- }, 8, ["content"]),
1781
- b("div", Kl, [
1782
- b("div", Ql, [
1783
- (u(), N(xe, null, Ee(de, (ee) => {
1784
- var Ve;
1785
- return r(be, {
1786
- key: ee.labelKey,
1787
- label: l(f)(ee.labelKey),
1788
- variant: ((Ve = K.value) == null ? void 0 : Ve.labelKey) === ee.labelKey ? "primary" : "secondary",
1789
- size: "md",
1790
- onClick: (pe) => ge(ee)
1791
- }, null, 8, ["label", "variant", "onClick"]);
1792
- }), 64))
1793
- ]),
1794
- r(be, {
1795
- icon: "screen_rotation",
1796
- variant: "tertiary",
1797
- size: "md",
1798
- class: "text-fm-color-typo-primary",
1799
- onClick: ye
1800
- })
1801
- ])
1802
- ])
1803
- ]),
1804
- _: 1
1805
- }, 8, ["actions"]),
1806
- l(T) ? (u(), k(jl, {
1807
- key: 0,
1808
- modelValue: l(T),
1809
- "onUpdate:modelValue": H[1] || (H[1] = (ee) => ft(T) ? T.value = ee : null),
1810
- style: lt({ height: oe.value + "px" }),
1811
- class: Pe(l(h).lg || l(h).md ? "flex" : ""),
1812
- "hide-configuration": S.value,
1813
- "preview-width": me.value,
1814
- "preview-height": _e.value,
1815
- "preview-scale": ce.value,
1816
- onHideConfiguration: H[2] || (H[2] = (ee) => S.value = ee)
1817
- }, null, 8, ["modelValue", "style", "class", "hide-configuration", "preview-width", "preview-height", "preview-scale"])) : M("", !0)
1818
- ]),
1819
- _: 1
1820
- });
1821
- };
1822
- }
1823
- });
1824
- export {
1825
- po as default
1826
- };