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