@enerex/template-studio 1.1.35 → 1.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -63
- package/dist/enerex-template-editor.es.js +615 -501
- package/dist/enerex-template-editor.umd.js +3 -3
- package/dist/types/component/editor/index.d.ts +1 -0
- package/dist/types/component/template-form/index.d.ts +1 -0
- package/dist/types/context/configuration-provider.d.ts +9 -0
- package/dist/types/queries/mark_favourite.mutation.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { QueryClient as
|
|
4
|
-
import
|
|
5
|
-
import { Spinner as
|
|
6
|
-
import { Controller as
|
|
7
|
-
import
|
|
1
|
+
import { jsx as l, jsxs as $, Fragment as De } from "react/jsx-runtime";
|
|
2
|
+
import O, { useContext as we, useState as S, useRef as qe, useEffect as v } from "react";
|
|
3
|
+
import { QueryClient as $e, QueryClientProvider as Re, useQuery as J, useMutation as ve, useQueryClient as Be } from "@tanstack/react-query";
|
|
4
|
+
import me from "axios";
|
|
5
|
+
import { Spinner as Y, Form as H, Card as ue, Row as ke, Col as M, Button as se } from "react-bootstrap";
|
|
6
|
+
import { Controller as Ue, useForm as Me } from "react-hook-form";
|
|
7
|
+
import fe, { components as He } from "react-select";
|
|
8
8
|
const z = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
|
|
9
9
|
<html\r
|
|
10
10
|
dir="ltr"\r
|
|
@@ -361,155 +361,159 @@ const z = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
361
361
|
</div>\r
|
|
362
362
|
</body>\r
|
|
363
363
|
</html>\r
|
|
364
|
-
`,
|
|
364
|
+
`, xe = O.createContext(
|
|
365
365
|
void 0
|
|
366
|
-
),
|
|
367
|
-
children:
|
|
368
|
-
configs:
|
|
366
|
+
), Fe = ({
|
|
367
|
+
children: t,
|
|
368
|
+
configs: s
|
|
369
369
|
}) => {
|
|
370
|
-
const [
|
|
371
|
-
|
|
372
|
-
), [
|
|
373
|
-
|
|
370
|
+
const [o, i] = O.useState(s.clientId), [r, e] = O.useState(s.apiKey), [a, c] = O.useState(
|
|
371
|
+
s.enerexIdentifier
|
|
372
|
+
), [T, y] = O.useState(s.projectId), [C, f] = O.useState(s.userEmail), [_, P] = O.useState(s.isAdmin), [x, g] = O.useState(s.meBaseUrl), [h, u] = O.useState(
|
|
373
|
+
s.defaultSelector
|
|
374
|
+
), m = (b) => {
|
|
375
|
+
e(b.apiKey), i(b.clientId), y(b.projectId), c(b.enerexIdentifier), f(b.userEmail), P(b.isAdmin), u(b.defaultSelector), g(b.meBaseUrl);
|
|
374
376
|
};
|
|
375
|
-
return /* @__PURE__ */
|
|
376
|
-
|
|
377
|
+
return /* @__PURE__ */ l(
|
|
378
|
+
xe.Provider,
|
|
377
379
|
{
|
|
378
380
|
value: {
|
|
379
|
-
clientId:
|
|
380
|
-
apiKey:
|
|
381
|
-
setConfiguration:
|
|
382
|
-
enerexIdentifier:
|
|
383
|
-
projectId:
|
|
384
|
-
userEmail:
|
|
381
|
+
clientId: o,
|
|
382
|
+
apiKey: r,
|
|
383
|
+
setConfiguration: m,
|
|
384
|
+
enerexIdentifier: a,
|
|
385
|
+
projectId: T,
|
|
386
|
+
userEmail: C,
|
|
387
|
+
isAdmin: _,
|
|
388
|
+
defaultSelector: h,
|
|
389
|
+
meBaseUrl: x
|
|
385
390
|
},
|
|
386
|
-
children:
|
|
391
|
+
children: t
|
|
387
392
|
}
|
|
388
393
|
);
|
|
389
|
-
},
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
394
|
+
}, R = () => {
|
|
395
|
+
const t = we(xe);
|
|
396
|
+
if (!t)
|
|
392
397
|
throw new Error("widgetConfig must be used within a ConfigProvider");
|
|
393
|
-
return
|
|
394
|
-
},
|
|
398
|
+
return t;
|
|
399
|
+
}, Se = (t = "", s) => ({ get: async (r, e) => {
|
|
395
400
|
try {
|
|
396
|
-
const
|
|
397
|
-
`${
|
|
398
|
-
|
|
401
|
+
const a = await me.get(
|
|
402
|
+
`${t}${r}`,
|
|
403
|
+
e ?? s
|
|
399
404
|
);
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
402
|
-
} catch (
|
|
403
|
-
throw
|
|
405
|
+
if (a.status === 200)
|
|
406
|
+
return a.data;
|
|
407
|
+
} catch (a) {
|
|
408
|
+
throw a;
|
|
404
409
|
}
|
|
405
|
-
}, post: async (
|
|
410
|
+
}, post: async (r, e, a) => {
|
|
406
411
|
try {
|
|
407
|
-
const
|
|
408
|
-
`${
|
|
409
|
-
|
|
410
|
-
|
|
412
|
+
const c = await me.post(
|
|
413
|
+
`${t}${r}`,
|
|
414
|
+
e,
|
|
415
|
+
a ?? s
|
|
411
416
|
);
|
|
412
|
-
if (
|
|
413
|
-
return
|
|
414
|
-
} catch (
|
|
415
|
-
throw
|
|
417
|
+
if (c.status === 200)
|
|
418
|
+
return c.data;
|
|
419
|
+
} catch (c) {
|
|
420
|
+
throw c;
|
|
416
421
|
}
|
|
417
|
-
} }),
|
|
418
|
-
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
419
|
-
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
420
|
-
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da",
|
|
421
|
-
API_BASE_URL: "https://dev-socket.enerex.com/common/api"
|
|
422
|
-
//API_BASE_URL: "https://localhost:44338/api",
|
|
423
|
-
// more env variables...
|
|
424
|
-
}, fe = R.createContext({
|
|
422
|
+
} }), Ce = O.createContext({
|
|
425
423
|
get: () => {
|
|
426
424
|
throw new Error("HttpClientContext.get not implemented");
|
|
427
425
|
},
|
|
428
426
|
post: () => {
|
|
429
427
|
throw new Error("HttpClientContext.post not implemented");
|
|
430
428
|
}
|
|
431
|
-
}),
|
|
432
|
-
const { clientId:
|
|
429
|
+
}), Ge = ({ children: t }) => {
|
|
430
|
+
const { clientId: s, apiKey: o, isAdmin: i, meBaseUrl: r } = R(), e = {
|
|
433
431
|
headers: {
|
|
434
|
-
client_id:
|
|
435
|
-
"x-api-key":
|
|
432
|
+
client_id: s,
|
|
433
|
+
"x-api-key": o,
|
|
434
|
+
"Security-Context": i ? "admin" : "viewer"
|
|
436
435
|
}
|
|
437
|
-
}, { get:
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
},
|
|
440
|
-
const
|
|
441
|
-
return /* @__PURE__ */
|
|
442
|
-
},
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
}, { get: a, post: c } = Se(r, e);
|
|
437
|
+
return /* @__PURE__ */ l(Ce.Provider, { value: { get: a, post: c }, children: t });
|
|
438
|
+
}, Ve = ({ children: t }) => {
|
|
439
|
+
const s = new $e();
|
|
440
|
+
return /* @__PURE__ */ l(Ge, { children: /* @__PURE__ */ l(Re, { client: s, children: t }) });
|
|
441
|
+
}, ie = {
|
|
442
|
+
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
443
|
+
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
444
|
+
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
|
|
445
|
+
}, Ke = (t) => {
|
|
446
|
+
const s = Array.from(new Set(t.map((i) => i.category))), o = [];
|
|
447
|
+
return s.forEach((i) => {
|
|
448
|
+
const r = t.filter((e) => e.category === i).map((e) => ({
|
|
449
|
+
label: e.label,
|
|
450
|
+
value: e.value,
|
|
451
|
+
hint: e.hint,
|
|
452
|
+
hidden: e.hidden
|
|
450
453
|
}));
|
|
451
|
-
|
|
452
|
-
}),
|
|
453
|
-
},
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
return
|
|
454
|
+
o.push({ category: i, entries: r });
|
|
455
|
+
}), o;
|
|
456
|
+
}, G = () => {
|
|
457
|
+
const t = we(Ce);
|
|
458
|
+
if (t)
|
|
459
|
+
return t;
|
|
457
460
|
throw new Error("useHttpClient must be used within a HttpClientProvider");
|
|
458
|
-
},
|
|
461
|
+
}, V = {
|
|
459
462
|
Template_list: "/Template/list/",
|
|
460
463
|
Template: "/Template/GetTemplate/",
|
|
461
464
|
MergeTags: "/Template/TemplateMergeTags/",
|
|
462
465
|
ExcludeCategory: "/Template/GetExcludeCategories/",
|
|
463
466
|
SaveTemplate: "/Template/save-update/",
|
|
464
467
|
TemplateTypes: "/Template/TemplateTypes/"
|
|
465
|
-
},
|
|
466
|
-
const
|
|
467
|
-
return
|
|
468
|
+
}, Qe = () => {
|
|
469
|
+
const t = G(), { enerexIdentifier: s, projectId: o } = R();
|
|
470
|
+
return J({
|
|
468
471
|
queryKey: ["getTemplateTags"],
|
|
469
|
-
queryFn: async (
|
|
470
|
-
`${
|
|
472
|
+
queryFn: async (r) => await t.get(
|
|
473
|
+
`${V.MergeTags}${o}/${s}`
|
|
471
474
|
)
|
|
472
475
|
});
|
|
473
|
-
},
|
|
474
|
-
const
|
|
475
|
-
return
|
|
476
|
+
}, We = () => {
|
|
477
|
+
const t = G(), { enerexIdentifier: s, projectId: o } = R();
|
|
478
|
+
return J({
|
|
476
479
|
queryKey: ["getExcludeCategory"],
|
|
477
|
-
queryFn: async (
|
|
478
|
-
`${
|
|
480
|
+
queryFn: async (r) => await t.get(
|
|
481
|
+
`${V.ExcludeCategory}${o}/${s}`
|
|
479
482
|
)
|
|
480
483
|
});
|
|
481
|
-
},
|
|
482
|
-
templateHTML:
|
|
483
|
-
className:
|
|
484
|
-
loading:
|
|
484
|
+
}, Ye = ({
|
|
485
|
+
templateHTML: t,
|
|
486
|
+
className: s = "",
|
|
487
|
+
loading: o = !1,
|
|
488
|
+
onEditorInitialized: i
|
|
485
489
|
}) => {
|
|
486
|
-
const { post:
|
|
487
|
-
|
|
488
|
-
), { userEmail:
|
|
489
|
-
|
|
490
|
-
(async () => (await
|
|
491
|
-
}, [
|
|
492
|
-
async function
|
|
493
|
-
window.Zone || await new Promise((
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
|
|
490
|
+
const { post: r } = Se(), { data: e } = Qe(), { data: a } = We(), [c, T] = S(
|
|
491
|
+
t ?? { html: z, css: "" }
|
|
492
|
+
), { userEmail: y } = R(), C = qe(null), f = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", _ = "https://plugins.stripo.email/api/v1/auth";
|
|
493
|
+
v(() => {
|
|
494
|
+
(async () => (await P(), e && a && await x(ie.EDITOR_SCRIPT_URL)))();
|
|
495
|
+
}, [e, a]);
|
|
496
|
+
async function P() {
|
|
497
|
+
window.Zone || await new Promise((h, u) => {
|
|
498
|
+
const m = document.createElement("script");
|
|
499
|
+
m.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
|
|
500
|
+
const b = document.querySelector("script[nonce]")?.nonce;
|
|
501
|
+
b && m.setAttribute("nonce", b), m.onload = () => h(), m.onerror = () => u(new Error("Failed to load zone.js")), document.head.appendChild(m);
|
|
498
502
|
});
|
|
499
503
|
}
|
|
500
|
-
async function
|
|
501
|
-
let
|
|
504
|
+
async function x(h) {
|
|
505
|
+
let u = document.getElementById(
|
|
502
506
|
"UiEditorScript"
|
|
503
507
|
);
|
|
504
|
-
|
|
505
|
-
await
|
|
506
|
-
}, document.body.appendChild(
|
|
507
|
-
(
|
|
508
|
+
u || (u = document.createElement("script"), u.id = "UiEditorScript", u.src = h, u.onload = async () => {
|
|
509
|
+
await g();
|
|
510
|
+
}, document.body.appendChild(u)), await new Promise(
|
|
511
|
+
(m) => u.addEventListener("load", () => m(), { once: !0 })
|
|
508
512
|
);
|
|
509
513
|
}
|
|
510
|
-
const
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
514
|
+
const g = async () => {
|
|
515
|
+
const h = C.current;
|
|
516
|
+
if (!h) {
|
|
513
517
|
console.error("Missing #stripoEditorContainer in DOM");
|
|
514
518
|
return;
|
|
515
519
|
}
|
|
@@ -517,177 +521,181 @@ const z = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
517
521
|
console.error("UIEditor script not loaded or not exposing initEditor");
|
|
518
522
|
return;
|
|
519
523
|
}
|
|
520
|
-
const
|
|
521
|
-
html:
|
|
522
|
-
css:
|
|
523
|
-
modulesExcludedCategories:
|
|
524
|
+
const u = {
|
|
525
|
+
html: c.html,
|
|
526
|
+
css: c.css,
|
|
527
|
+
modulesExcludedCategories: a ?? [],
|
|
524
528
|
forceRecreate: !0,
|
|
525
529
|
metadata: {
|
|
526
|
-
emailId:
|
|
530
|
+
emailId: y,
|
|
527
531
|
userId: "1",
|
|
528
532
|
// username: userName,
|
|
529
|
-
avatarUrl:
|
|
533
|
+
avatarUrl: f
|
|
530
534
|
},
|
|
531
535
|
locale: "en",
|
|
532
|
-
onTokenRefreshRequest: async (
|
|
533
|
-
const
|
|
534
|
-
pluginId:
|
|
535
|
-
secretKey:
|
|
536
|
-
userId:
|
|
536
|
+
onTokenRefreshRequest: async (m) => {
|
|
537
|
+
const b = {
|
|
538
|
+
pluginId: ie.EDITOR_PLUGIN_ID,
|
|
539
|
+
secretKey: ie.EDITOR_SECRET_KEY,
|
|
540
|
+
userId: y,
|
|
537
541
|
role: "user"
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
|
|
542
|
+
}, B = await r(
|
|
543
|
+
_,
|
|
544
|
+
b
|
|
541
545
|
);
|
|
542
|
-
|
|
546
|
+
B?.token && m(B.token);
|
|
547
|
+
},
|
|
548
|
+
onTemplateLoaded: () => {
|
|
549
|
+
i && i(!0);
|
|
543
550
|
},
|
|
544
|
-
mergeTags:
|
|
551
|
+
mergeTags: Ke(e ?? [])
|
|
545
552
|
};
|
|
546
|
-
for (const [
|
|
553
|
+
for (const [m, b] of Object.entries({
|
|
547
554
|
codeEditorButtonSelector: "#codeEditor",
|
|
548
555
|
undoButtonSelector: "#undoButton",
|
|
549
556
|
redoButtonSelector: "#redoButton",
|
|
550
557
|
mobileViewButtonSelector: "#mobileViewButton",
|
|
551
558
|
desktopViewButtonSelector: "#desktopViewButton"
|
|
552
559
|
}))
|
|
553
|
-
|
|
554
|
-
await window.UIEditor.initEditor(
|
|
560
|
+
h.ownerDocument && h.getRootNode() instanceof ShadowRoot && h.getRootNode().querySelector(b) && (u[m] = b);
|
|
561
|
+
await window.UIEditor.initEditor(h, u);
|
|
555
562
|
};
|
|
556
|
-
return /* @__PURE__ */
|
|
557
|
-
|
|
558
|
-
|
|
563
|
+
return /* @__PURE__ */ l("div", { className: "position-relative", children: /* @__PURE__ */ $("div", { className: `editor-container ${s}`, children: [
|
|
564
|
+
o && /* @__PURE__ */ l("div", { className: "loading-overlay", children: /* @__PURE__ */ l(
|
|
565
|
+
Y,
|
|
559
566
|
{
|
|
560
567
|
animation: "border",
|
|
561
568
|
style: { width: "11px", height: "11px" },
|
|
562
569
|
size: "sm",
|
|
563
570
|
role: "status",
|
|
564
|
-
className: "me-1"
|
|
571
|
+
className: "me-1",
|
|
572
|
+
children: /* @__PURE__ */ l("span", { className: "visually-hidden", children: "Loading..." })
|
|
565
573
|
}
|
|
566
574
|
) }),
|
|
567
|
-
/* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
575
|
+
/* @__PURE__ */ l("div", { id: "externalSystemContainer" }),
|
|
576
|
+
/* @__PURE__ */ l("div", { id: "stripoEditorContainer", ref: C })
|
|
569
577
|
] }) });
|
|
570
|
-
},
|
|
571
|
-
label:
|
|
572
|
-
register:
|
|
573
|
-
validation:
|
|
574
|
-
required:
|
|
575
|
-
name:
|
|
576
|
-
error:
|
|
577
|
-
className:
|
|
578
|
-
...
|
|
579
|
-
}) => /* @__PURE__ */
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
578
|
+
}, ye = ({
|
|
579
|
+
label: t,
|
|
580
|
+
register: s,
|
|
581
|
+
validation: o,
|
|
582
|
+
required: i = !1,
|
|
583
|
+
name: r,
|
|
584
|
+
error: e,
|
|
585
|
+
className: a = "",
|
|
586
|
+
...c
|
|
587
|
+
}) => /* @__PURE__ */ $(H.Group, { className: a + " mb-1", children: [
|
|
588
|
+
t ? /* @__PURE__ */ $(H.Label, { className: "mb-3 d-block form-label", children: [
|
|
589
|
+
t,
|
|
590
|
+
i && /* @__PURE__ */ l("label", { className: "text-danger", children: "*" })
|
|
583
591
|
] }) : null,
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
|
|
592
|
+
/* @__PURE__ */ l(
|
|
593
|
+
H.Control,
|
|
586
594
|
{
|
|
587
|
-
name:
|
|
595
|
+
name: r,
|
|
588
596
|
type: "text",
|
|
589
|
-
...
|
|
590
|
-
isInvalid: !!(
|
|
591
|
-
...
|
|
592
|
-
...
|
|
597
|
+
...c,
|
|
598
|
+
isInvalid: !!(e && e[r]),
|
|
599
|
+
...s ? s(r, {
|
|
600
|
+
...o
|
|
593
601
|
}) : {},
|
|
594
|
-
className: `react-select__control ${
|
|
602
|
+
className: `react-select__control ${e && e[r] && "border border-danger"}`
|
|
595
603
|
}
|
|
596
604
|
),
|
|
597
|
-
|
|
598
|
-
] }),
|
|
599
|
-
const
|
|
600
|
-
return
|
|
605
|
+
e && e[r] ? /* @__PURE__ */ l(H.Control.Feedback, { type: "invalid", children: e[r].message }) : null
|
|
606
|
+
] }), ze = () => {
|
|
607
|
+
const t = G(), { enerexIdentifier: s, projectId: o } = R();
|
|
608
|
+
return J({
|
|
601
609
|
queryKey: ["getTemplatesList"],
|
|
602
|
-
queryFn: async (
|
|
603
|
-
`${
|
|
610
|
+
queryFn: async (r) => await t.get(
|
|
611
|
+
`${V.Template_list}${o}/${s}`
|
|
604
612
|
)
|
|
605
613
|
});
|
|
606
614
|
};
|
|
607
|
-
function
|
|
608
|
-
return
|
|
615
|
+
function le(t) {
|
|
616
|
+
return t.sort((s, o) => s.name.localeCompare(o.name));
|
|
609
617
|
}
|
|
610
|
-
function
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
let
|
|
614
|
-
for (;
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
(
|
|
619
|
-
),
|
|
618
|
+
function Je(t) {
|
|
619
|
+
const s = /* @__PURE__ */ new Map(), o = [];
|
|
620
|
+
t.forEach((e) => s.set(e.id, e));
|
|
621
|
+
let i = t.filter((e) => e.parent_id === 0), r = 0;
|
|
622
|
+
for (; i.length > 0; ) {
|
|
623
|
+
o.push({ level: r, data: i });
|
|
624
|
+
const e = i.map((c) => c.id);
|
|
625
|
+
i = t.filter(
|
|
626
|
+
(c) => e.includes(c.parent_id)
|
|
627
|
+
), r++;
|
|
620
628
|
}
|
|
621
|
-
return
|
|
629
|
+
return o;
|
|
622
630
|
}
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
return
|
|
631
|
+
function ae(t, s) {
|
|
632
|
+
const i = Je(t).find((r) => r.level === s);
|
|
633
|
+
return i ? i.data : [];
|
|
626
634
|
}
|
|
627
|
-
const
|
|
628
|
-
const
|
|
629
|
-
return
|
|
635
|
+
const Xe = () => {
|
|
636
|
+
const t = G(), { enerexIdentifier: s, projectId: o } = R();
|
|
637
|
+
return ve({
|
|
630
638
|
mutationKey: ["getTemplate"],
|
|
631
|
-
mutationFn: async ({ id:
|
|
632
|
-
if (
|
|
633
|
-
return await
|
|
634
|
-
`${
|
|
639
|
+
mutationFn: async ({ id: r }) => {
|
|
640
|
+
if (r)
|
|
641
|
+
return await t.get(
|
|
642
|
+
`${V.Template}${s}/${r}/${o}`
|
|
635
643
|
);
|
|
636
644
|
}
|
|
637
645
|
});
|
|
638
|
-
},
|
|
639
|
-
const
|
|
640
|
-
return
|
|
646
|
+
}, Ze = () => {
|
|
647
|
+
const t = G(), { enerexIdentifier: s, projectId: o } = R();
|
|
648
|
+
return J({
|
|
641
649
|
queryKey: ["getTemplateTypes"],
|
|
642
|
-
queryFn: async (
|
|
643
|
-
`${
|
|
650
|
+
queryFn: async (r) => await t.get(
|
|
651
|
+
`${V.TemplateTypes}${s}/${o}`
|
|
644
652
|
)
|
|
645
653
|
});
|
|
646
654
|
};
|
|
647
|
-
function
|
|
648
|
-
return
|
|
655
|
+
function et(t) {
|
|
656
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
649
657
|
}
|
|
650
|
-
var
|
|
658
|
+
var oe = { exports: {} };
|
|
651
659
|
/*!
|
|
652
660
|
Copyright (c) 2018 Jed Watson.
|
|
653
661
|
Licensed under the MIT License (MIT), see
|
|
654
662
|
http://jedwatson.github.io/classnames
|
|
655
663
|
*/
|
|
656
|
-
var
|
|
657
|
-
function
|
|
658
|
-
return
|
|
664
|
+
var ge;
|
|
665
|
+
function tt() {
|
|
666
|
+
return ge || (ge = 1, function(t) {
|
|
659
667
|
(function() {
|
|
660
|
-
var
|
|
661
|
-
function
|
|
662
|
-
for (var
|
|
663
|
-
var
|
|
664
|
-
|
|
668
|
+
var s = {}.hasOwnProperty;
|
|
669
|
+
function o() {
|
|
670
|
+
for (var e = "", a = 0; a < arguments.length; a++) {
|
|
671
|
+
var c = arguments[a];
|
|
672
|
+
c && (e = r(e, i(c)));
|
|
665
673
|
}
|
|
666
|
-
return
|
|
674
|
+
return e;
|
|
667
675
|
}
|
|
668
|
-
function
|
|
669
|
-
if (typeof
|
|
670
|
-
return
|
|
671
|
-
if (typeof
|
|
676
|
+
function i(e) {
|
|
677
|
+
if (typeof e == "string" || typeof e == "number")
|
|
678
|
+
return e;
|
|
679
|
+
if (typeof e != "object")
|
|
672
680
|
return "";
|
|
673
|
-
if (Array.isArray(
|
|
674
|
-
return
|
|
675
|
-
if (
|
|
676
|
-
return
|
|
677
|
-
var
|
|
678
|
-
for (var
|
|
679
|
-
|
|
680
|
-
return
|
|
681
|
+
if (Array.isArray(e))
|
|
682
|
+
return o.apply(null, e);
|
|
683
|
+
if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
|
|
684
|
+
return e.toString();
|
|
685
|
+
var a = "";
|
|
686
|
+
for (var c in e)
|
|
687
|
+
s.call(e, c) && e[c] && (a = r(a, c));
|
|
688
|
+
return a;
|
|
681
689
|
}
|
|
682
|
-
function
|
|
683
|
-
return
|
|
690
|
+
function r(e, a) {
|
|
691
|
+
return a ? e ? e + " " + a : e + a : e;
|
|
684
692
|
}
|
|
685
|
-
|
|
693
|
+
t.exports ? (o.default = o, t.exports = o) : window.classNames = o;
|
|
686
694
|
})();
|
|
687
|
-
}(
|
|
695
|
+
}(oe)), oe.exports;
|
|
688
696
|
}
|
|
689
|
-
var
|
|
690
|
-
const
|
|
697
|
+
var nt = tt();
|
|
698
|
+
const he = /* @__PURE__ */ et(nt), be = (t) => t.data.isSeparator ? /* @__PURE__ */ l("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ l(
|
|
691
699
|
"hr",
|
|
692
700
|
{
|
|
693
701
|
style: {
|
|
@@ -697,34 +705,34 @@ const oe = /* @__PURE__ */ Ge(Ke), ae = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
697
705
|
margin: 0
|
|
698
706
|
}
|
|
699
707
|
}
|
|
700
|
-
) }) : /* @__PURE__ */
|
|
701
|
-
name:
|
|
702
|
-
control:
|
|
703
|
-
options:
|
|
704
|
-
multiple:
|
|
705
|
-
placeholder:
|
|
706
|
-
validation:
|
|
707
|
-
labelKey:
|
|
708
|
-
disabled:
|
|
709
|
-
isInvalid:
|
|
710
|
-
value:
|
|
711
|
-
onChange:
|
|
712
|
-
uncontrolled:
|
|
713
|
-
menuPlacement:
|
|
714
|
-
closeOnSelect:
|
|
708
|
+
) }) : /* @__PURE__ */ l(He.Option, { ...t }), rt = ({
|
|
709
|
+
name: t = "",
|
|
710
|
+
control: s,
|
|
711
|
+
options: o,
|
|
712
|
+
multiple: i = !1,
|
|
713
|
+
placeholder: r,
|
|
714
|
+
validation: e,
|
|
715
|
+
labelKey: a = "name",
|
|
716
|
+
disabled: c,
|
|
717
|
+
isInvalid: T,
|
|
718
|
+
value: y,
|
|
719
|
+
onChange: C,
|
|
720
|
+
uncontrolled: f,
|
|
721
|
+
menuPlacement: _ = "auto",
|
|
722
|
+
closeOnSelect: P = !0
|
|
715
723
|
}) => {
|
|
716
|
-
const
|
|
717
|
-
control: (
|
|
718
|
-
...
|
|
724
|
+
const x = {
|
|
725
|
+
control: (g) => ({
|
|
726
|
+
...g,
|
|
719
727
|
minHeight: "33px",
|
|
720
728
|
// state.isFocused can display different borderColor if you need it
|
|
721
|
-
borderColor:
|
|
722
|
-
backgroundImage:
|
|
729
|
+
borderColor: T ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
|
|
730
|
+
backgroundImage: T ? 'url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27 width=%2712%27 height=%2712%27 fill=%27none%27 stroke=%27%23fa5c7c%27%3e%3ccircle cx=%276%27 cy=%276%27 r=%274.5%27/%3e%3cpath stroke-linejoin=%27round%27 d=%27M5.8 3.6h.4L6 6.5z%27/%3e%3ccircle cx=%276%27 cy=%278.2%27 r=%27.6%27 fill=%27%23fa5c7c%27 stroke=%27none%27/%3e%3c/svg%3e")' : "none",
|
|
723
731
|
backgroundRepeat: "no-repeat",
|
|
724
732
|
backgroundPosition: "right calc(0.375em + 0.225rem) center",
|
|
725
733
|
backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
|
|
726
734
|
"&:hover": {
|
|
727
|
-
borderColor:
|
|
735
|
+
borderColor: T ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
|
|
728
736
|
},
|
|
729
737
|
"& .react-select__single-value": {
|
|
730
738
|
color: "var(--ct-input-color) !important"
|
|
@@ -736,324 +744,400 @@ const oe = /* @__PURE__ */ Ge(Ke), ae = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
736
744
|
display: "none"
|
|
737
745
|
}
|
|
738
746
|
}),
|
|
739
|
-
menu: (
|
|
740
|
-
...
|
|
747
|
+
menu: (g) => ({
|
|
748
|
+
...g,
|
|
741
749
|
marginTop: 0,
|
|
742
750
|
width: "max-content",
|
|
743
751
|
minWidth: "100%"
|
|
744
752
|
}),
|
|
745
|
-
menuPortal: (
|
|
746
|
-
...
|
|
753
|
+
menuPortal: (g) => ({
|
|
754
|
+
...g,
|
|
747
755
|
zIndex: 9999
|
|
748
756
|
}),
|
|
749
|
-
multiValueRemove: (
|
|
750
|
-
...
|
|
751
|
-
display:
|
|
757
|
+
multiValueRemove: (g) => ({
|
|
758
|
+
...g,
|
|
759
|
+
display: c ? "none" : "block"
|
|
752
760
|
})
|
|
753
761
|
};
|
|
754
|
-
return
|
|
755
|
-
|
|
762
|
+
return f ? /* @__PURE__ */ l(
|
|
763
|
+
fe,
|
|
756
764
|
{
|
|
757
|
-
components: { Option:
|
|
758
|
-
isOptionDisabled: (
|
|
759
|
-
className:
|
|
760
|
-
"is-invalid":
|
|
765
|
+
components: { Option: be },
|
|
766
|
+
isOptionDisabled: (g) => !!g.isSeparator,
|
|
767
|
+
className: he({
|
|
768
|
+
"is-invalid": T
|
|
761
769
|
}),
|
|
762
|
-
styles:
|
|
770
|
+
styles: x,
|
|
763
771
|
classNamePrefix: "react-select",
|
|
764
|
-
isMulti:
|
|
765
|
-
options:
|
|
766
|
-
onChange:
|
|
767
|
-
placeholder:
|
|
772
|
+
isMulti: i,
|
|
773
|
+
options: o,
|
|
774
|
+
onChange: C,
|
|
775
|
+
placeholder: r,
|
|
768
776
|
menuPortalTarget: document.body,
|
|
769
|
-
value:
|
|
770
|
-
getOptionLabel: typeof
|
|
771
|
-
getOptionValue: (
|
|
772
|
-
isDisabled:
|
|
773
|
-
menuPlacement:
|
|
774
|
-
closeMenuOnSelect:
|
|
777
|
+
value: y,
|
|
778
|
+
getOptionLabel: typeof a == "string" ? (g) => g[a] : a,
|
|
779
|
+
getOptionValue: (g) => g.id,
|
|
780
|
+
isDisabled: c,
|
|
781
|
+
menuPlacement: _,
|
|
782
|
+
closeMenuOnSelect: P
|
|
775
783
|
}
|
|
776
|
-
) : /* @__PURE__ */
|
|
777
|
-
|
|
784
|
+
) : /* @__PURE__ */ l(
|
|
785
|
+
Ue,
|
|
778
786
|
{
|
|
779
|
-
control:
|
|
780
|
-
name:
|
|
781
|
-
rules:
|
|
782
|
-
render: ({ field: { onChange:
|
|
783
|
-
|
|
787
|
+
control: s,
|
|
788
|
+
name: t,
|
|
789
|
+
rules: e,
|
|
790
|
+
render: ({ field: { onChange: g, value: h, onBlur: u } }) => /* @__PURE__ */ l(
|
|
791
|
+
fe,
|
|
784
792
|
{
|
|
785
|
-
components: { Option:
|
|
786
|
-
isOptionDisabled: (
|
|
787
|
-
className:
|
|
788
|
-
"is-invalid":
|
|
793
|
+
components: { Option: be },
|
|
794
|
+
isOptionDisabled: (m) => !!m.isSeparator,
|
|
795
|
+
className: he({
|
|
796
|
+
"is-invalid": T
|
|
789
797
|
}),
|
|
790
|
-
styles:
|
|
798
|
+
styles: x,
|
|
791
799
|
classNamePrefix: "react-select",
|
|
792
|
-
isMulti:
|
|
793
|
-
options:
|
|
794
|
-
onBlur:
|
|
795
|
-
onChange:
|
|
796
|
-
placeholder:
|
|
800
|
+
isMulti: i,
|
|
801
|
+
options: o,
|
|
802
|
+
onBlur: u,
|
|
803
|
+
onChange: g,
|
|
804
|
+
placeholder: r,
|
|
797
805
|
menuPortalTarget: document.body,
|
|
798
|
-
value:
|
|
799
|
-
getOptionLabel: typeof
|
|
800
|
-
getOptionValue: (
|
|
801
|
-
isDisabled:
|
|
802
|
-
menuPlacement:
|
|
803
|
-
closeMenuOnSelect:
|
|
806
|
+
value: h,
|
|
807
|
+
getOptionLabel: typeof a == "string" ? (m) => m[a] : a,
|
|
808
|
+
getOptionValue: (m) => m.id,
|
|
809
|
+
isDisabled: c,
|
|
810
|
+
menuPlacement: _,
|
|
811
|
+
closeMenuOnSelect: P
|
|
804
812
|
},
|
|
805
|
-
|
|
813
|
+
h ? JSON.stringify(h) : "reset"
|
|
806
814
|
)
|
|
807
815
|
}
|
|
808
816
|
);
|
|
809
|
-
},
|
|
810
|
-
label:
|
|
811
|
-
name:
|
|
812
|
-
validation:
|
|
813
|
-
control:
|
|
814
|
-
error:
|
|
815
|
-
...
|
|
816
|
-
}) => /* @__PURE__ */
|
|
817
|
-
|
|
818
|
-
|
|
817
|
+
}, W = ({
|
|
818
|
+
label: t,
|
|
819
|
+
name: s,
|
|
820
|
+
validation: o,
|
|
821
|
+
control: i,
|
|
822
|
+
error: r,
|
|
823
|
+
...e
|
|
824
|
+
}) => /* @__PURE__ */ $(H.Group, { className: "mb-1", children: [
|
|
825
|
+
t && /* @__PURE__ */ $(H.Label, { className: "mb-3 d-block form-label", children: [
|
|
826
|
+
t,
|
|
819
827
|
" ",
|
|
820
|
-
|
|
828
|
+
e.required && /* @__PURE__ */ l("span", { className: "text-danger", children: "*" })
|
|
821
829
|
] }),
|
|
822
|
-
/* @__PURE__ */
|
|
823
|
-
|
|
830
|
+
/* @__PURE__ */ l(
|
|
831
|
+
rt,
|
|
824
832
|
{
|
|
825
|
-
control:
|
|
826
|
-
disabled:
|
|
827
|
-
options:
|
|
828
|
-
validation:
|
|
829
|
-
isInvalid:
|
|
830
|
-
name:
|
|
833
|
+
control: i,
|
|
834
|
+
disabled: e.disabled,
|
|
835
|
+
options: e.options ?? [],
|
|
836
|
+
validation: o,
|
|
837
|
+
isInvalid: r && !!r[s],
|
|
838
|
+
name: s
|
|
831
839
|
}
|
|
832
840
|
),
|
|
833
|
-
|
|
834
|
-
] }),
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
const { enerexIdentifier:
|
|
838
|
-
return
|
|
841
|
+
r && r[s] ? /* @__PURE__ */ l(H.Control.Feedback, { type: "invalid", children: r[s].message }) : null
|
|
842
|
+
] }), st = () => {
|
|
843
|
+
const t = G();
|
|
844
|
+
Be();
|
|
845
|
+
const { enerexIdentifier: s, projectId: o } = R();
|
|
846
|
+
return ve({
|
|
839
847
|
mutationKey: ["saveTemplate"],
|
|
840
|
-
mutationFn: async (
|
|
841
|
-
`${
|
|
842
|
-
|
|
848
|
+
mutationFn: async (r) => (r.enerexIdentifier = s ?? "", r.projectId = o ?? "", await t.post(
|
|
849
|
+
`${V.SaveTemplate}`,
|
|
850
|
+
r
|
|
843
851
|
))
|
|
844
852
|
});
|
|
845
|
-
},
|
|
853
|
+
}, K = {
|
|
846
854
|
id: "",
|
|
847
855
|
name: "New (Blank)"
|
|
848
|
-
},
|
|
856
|
+
}, Te = {
|
|
849
857
|
id: "",
|
|
850
858
|
name: "Separator",
|
|
851
859
|
isSeparator: !0
|
|
852
|
-
},
|
|
853
|
-
onSelectItem:
|
|
854
|
-
templateLoading:
|
|
855
|
-
onReset:
|
|
860
|
+
}, it = ({
|
|
861
|
+
onSelectItem: t,
|
|
862
|
+
templateLoading: s,
|
|
863
|
+
onReset: o,
|
|
864
|
+
editorInitialized: i
|
|
856
865
|
}) => {
|
|
857
|
-
const {
|
|
858
|
-
register:
|
|
859
|
-
handleSubmit:
|
|
860
|
-
clearErrors:
|
|
861
|
-
setValue:
|
|
862
|
-
control:
|
|
863
|
-
watch:
|
|
864
|
-
reset:
|
|
865
|
-
setError:
|
|
866
|
-
formState: { errors:
|
|
867
|
-
} =
|
|
866
|
+
const { isAdmin: r, defaultSelector: e } = R(), {
|
|
867
|
+
register: a,
|
|
868
|
+
handleSubmit: c,
|
|
869
|
+
clearErrors: T,
|
|
870
|
+
setValue: y,
|
|
871
|
+
control: C,
|
|
872
|
+
watch: f,
|
|
873
|
+
reset: _,
|
|
874
|
+
setError: P,
|
|
875
|
+
formState: { errors: x }
|
|
876
|
+
} = Me({
|
|
868
877
|
defaultValues: {
|
|
869
878
|
templateName: "",
|
|
870
879
|
subTemplateType: void 0,
|
|
871
880
|
subTemplateType2: void 0,
|
|
872
881
|
subject: "",
|
|
873
882
|
templateType: void 0,
|
|
874
|
-
template:
|
|
883
|
+
template: K
|
|
875
884
|
},
|
|
876
885
|
mode: "onChange"
|
|
877
886
|
}), {
|
|
878
|
-
data:
|
|
879
|
-
refetch:
|
|
880
|
-
isLoading:
|
|
881
|
-
} =
|
|
882
|
-
|
|
887
|
+
data: g,
|
|
888
|
+
refetch: h,
|
|
889
|
+
isLoading: u
|
|
890
|
+
} = ze(), [m, b] = S([]), [B, Ee] = S(!1), [k, X] = S(), [Q, F] = S(), { mutateAsync: Z, isPending: E } = Xe(), { mutateAsync: de, isPending: I } = st(), { data: U, isLoading: D } = Ze(), [ee, Ie] = S([]), [L, te] = S([]), [j, ne] = S([]);
|
|
891
|
+
v(() => {
|
|
883
892
|
if (U) {
|
|
884
|
-
let
|
|
885
|
-
|
|
893
|
+
let n = U.filter((p) => p.id != null), d = ae(n, 0);
|
|
894
|
+
Ie(le(d));
|
|
886
895
|
}
|
|
887
896
|
}, [U]);
|
|
888
|
-
const
|
|
889
|
-
let
|
|
890
|
-
return
|
|
891
|
-
|
|
892
|
-
}),
|
|
897
|
+
const Ne = (n, d) => {
|
|
898
|
+
let p = [];
|
|
899
|
+
return n.forEach((N, w) => {
|
|
900
|
+
d.includes(w) && w !== 0 && p.push(Te), p.push(N);
|
|
901
|
+
}), p;
|
|
893
902
|
};
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
}, [
|
|
897
|
-
|
|
898
|
-
}, [
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
+
v(() => {
|
|
904
|
+
s(!!(u || E || I || D || !i));
|
|
905
|
+
}, [u, E, I, D, i]), v(() => {
|
|
906
|
+
g?.sort((n, d) => n.readonly !== d.readonly ? (n.readonly ? 0 : 1) - (d.readonly ? 0 : 1) : n.name.localeCompare(d.name)), b(g ?? []);
|
|
907
|
+
}, [g]);
|
|
908
|
+
const _e = async (n) => {
|
|
909
|
+
X(n), n && (r || !n.readonly) ? (y("templateName", n?.name), T()) : (y("templateName", ""), y("subject", ""));
|
|
910
|
+
const d = await Z({ id: n?.id });
|
|
911
|
+
F(d || void 0);
|
|
903
912
|
};
|
|
904
|
-
|
|
905
|
-
if (
|
|
906
|
-
let
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
(
|
|
913
|
+
v(() => {
|
|
914
|
+
if ((e === void 0 || e.templateId === void 0 || B) && y("template", K), f("templateType")) {
|
|
915
|
+
let n = U?.filter((p) => p.id !== void 0) ?? [], d = ae(n, 1);
|
|
916
|
+
te(
|
|
917
|
+
le(
|
|
918
|
+
d.filter(
|
|
919
|
+
(p) => p.parent_id.toString() === `${f("templateType")?.id}`
|
|
911
920
|
)
|
|
912
921
|
)
|
|
913
|
-
),
|
|
922
|
+
), y("subTemplateType", void 0), y("subTemplateType2", void 0);
|
|
914
923
|
}
|
|
915
|
-
}, [
|
|
916
|
-
if (
|
|
917
|
-
let
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
(
|
|
924
|
+
}, [f("templateType")]), v(() => {
|
|
925
|
+
if ((e === void 0 || e.templateId === void 0) && y("template", K), f("subTemplateType")) {
|
|
926
|
+
let n = U?.filter((p) => p.id !== void 0) ?? [], d = ae(n, 2);
|
|
927
|
+
ne(
|
|
928
|
+
le(
|
|
929
|
+
d.filter(
|
|
930
|
+
(p) => p.parent_id.toString() === `${f("subTemplateType")?.id}`
|
|
922
931
|
)
|
|
923
932
|
)
|
|
924
|
-
),
|
|
933
|
+
), y("subTemplateType2", void 0);
|
|
925
934
|
}
|
|
926
|
-
}, [
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
}, [
|
|
930
|
-
let
|
|
931
|
-
|
|
932
|
-
}, [
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
935
|
+
}, [f("subTemplateType")]), v(() => {
|
|
936
|
+
const n = pe();
|
|
937
|
+
n.length > 0 && n[0].id !== "" ? (e === void 0 || e.templateId === void 0 || B) && y("template", n[0]) : (e === void 0 || e.templateId === void 0 || B) && y("template", K);
|
|
938
|
+
}, [f("subTemplateType2")]), v(() => {
|
|
939
|
+
let n = m.find((d) => d.id === f("template")?.id);
|
|
940
|
+
_e(n);
|
|
941
|
+
}, [f("template")]);
|
|
942
|
+
const [Ae, ce] = S(!1);
|
|
943
|
+
v(() => {
|
|
944
|
+
Ae || (Q && k && i ? (ce(!0), t(Q), y("subject", Q.subject ?? ""), setTimeout(() => {
|
|
945
|
+
ce(!1);
|
|
946
|
+
}, 1e3)) : t(void 0));
|
|
947
|
+
}, [Q, k, t, i]);
|
|
948
|
+
const pe = () => {
|
|
949
|
+
let n = [K], d = "templateType";
|
|
950
|
+
j.length > 0 ? d = "subTemplateType2" : L.length > 0 && (d = "subTemplateType");
|
|
951
|
+
let p = m.filter(
|
|
952
|
+
(w) => (w.type?.toString() === f(d)?.id.toString() || w.type === null) && f(d)?.id != null
|
|
953
|
+
), N = Ne(p, [p.findIndex((w) => !w.readonly)]);
|
|
954
|
+
return N.length > 0 && (N[0].readonly === !0 && !r ? n = [] : n.push(Te), n = [
|
|
955
|
+
...n,
|
|
956
|
+
...N.map((A) => ({
|
|
957
|
+
id: A.id,
|
|
958
|
+
name: Le(p, A.id),
|
|
959
|
+
isSeparator: A.isSeparator
|
|
947
960
|
}))
|
|
948
|
-
]),
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
961
|
+
]), n.length ? n : [];
|
|
962
|
+
};
|
|
963
|
+
v(() => {
|
|
964
|
+
if (e && e.type1) {
|
|
965
|
+
const n = ee?.find(
|
|
966
|
+
(d) => `${d.id}` === e.type1
|
|
967
|
+
);
|
|
968
|
+
y("templateType", n);
|
|
969
|
+
}
|
|
970
|
+
}, [U, ee]), v(() => {
|
|
971
|
+
if (e && e.type2) {
|
|
972
|
+
const n = L?.find(
|
|
973
|
+
(d) => `${d.id}` === e.type2
|
|
974
|
+
);
|
|
975
|
+
y("subTemplateType", n);
|
|
976
|
+
}
|
|
977
|
+
}, [U, L]), v(() => {
|
|
978
|
+
if (e && e.type3) {
|
|
979
|
+
const n = j?.find(
|
|
980
|
+
(d) => `${d.id}` === e.type3
|
|
981
|
+
);
|
|
982
|
+
y("subTemplateType2", n);
|
|
983
|
+
}
|
|
984
|
+
}, [U, j]), v(() => {
|
|
985
|
+
if (e && e.templateId && m && m.length > 0 && !B && i) {
|
|
986
|
+
const n = m?.find(
|
|
987
|
+
(d) => `${d.id}` === e.templateId
|
|
988
|
+
);
|
|
989
|
+
Ee(!0), n && (X(n), y("template", n));
|
|
990
|
+
}
|
|
991
|
+
}, [m, i]);
|
|
992
|
+
const Le = (n, d) => {
|
|
993
|
+
let p = n.find((N) => N.id === d);
|
|
994
|
+
return p ? `${p.displayName}` : "";
|
|
995
|
+
}, je = (n) => {
|
|
953
996
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
954
|
-
async (
|
|
955
|
-
let
|
|
956
|
-
|
|
957
|
-
let
|
|
958
|
-
(
|
|
997
|
+
async (d) => {
|
|
998
|
+
let p = n.template.id, N = "";
|
|
999
|
+
k?.readonly && (p = "", N = n.template.id);
|
|
1000
|
+
let w = m.find(
|
|
1001
|
+
(q) => q.name === n.templateName.trim()
|
|
959
1002
|
);
|
|
960
|
-
if (
|
|
961
|
-
|
|
1003
|
+
if (w && w.id !== p) {
|
|
1004
|
+
P("templateName", {
|
|
962
1005
|
type: "validate",
|
|
963
1006
|
message: "Template name already exists. Please choose a different name."
|
|
964
1007
|
});
|
|
965
1008
|
return;
|
|
966
1009
|
}
|
|
967
|
-
let
|
|
968
|
-
|
|
969
|
-
const
|
|
1010
|
+
let A = n.templateType.id;
|
|
1011
|
+
j && j.length > 0 ? A = n.subTemplateType2.id : L && L.length > 0 && (A = n.subTemplateType.id);
|
|
1012
|
+
const re = {
|
|
970
1013
|
enerexIdentifier: "",
|
|
971
1014
|
projectId: "",
|
|
972
|
-
templateId:
|
|
973
|
-
templateType:
|
|
974
|
-
name:
|
|
975
|
-
html:
|
|
976
|
-
css:
|
|
977
|
-
subject:
|
|
978
|
-
parent_id:
|
|
1015
|
+
templateId: p,
|
|
1016
|
+
templateType: A,
|
|
1017
|
+
name: n.templateName.trim(),
|
|
1018
|
+
html: d.html,
|
|
1019
|
+
css: d.css,
|
|
1020
|
+
subject: n.templateType.id === "2" ? n?.subject ?? "" : "",
|
|
1021
|
+
parent_id: N
|
|
979
1022
|
};
|
|
980
|
-
|
|
1023
|
+
if (await de(re)) {
|
|
1024
|
+
if (T(), k?.readonly && !r)
|
|
1025
|
+
_(), te([]), ne([]);
|
|
1026
|
+
else {
|
|
1027
|
+
const q = await Z({ id: p });
|
|
1028
|
+
F(q || void 0);
|
|
1029
|
+
}
|
|
1030
|
+
h();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
);
|
|
1034
|
+
}, Oe = (n) => {
|
|
1035
|
+
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1036
|
+
async (d) => {
|
|
1037
|
+
let p = n.template.id, N = "", w = m.find(
|
|
1038
|
+
(q) => q.name === n.templateName.trim()
|
|
1039
|
+
);
|
|
1040
|
+
if (w && w.id !== p) {
|
|
1041
|
+
P("templateName", {
|
|
1042
|
+
type: "validate",
|
|
1043
|
+
message: "Template name already exists. Please choose a different name."
|
|
1044
|
+
});
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
let A = n.templateType.id;
|
|
1048
|
+
j && j.length > 0 ? A = n.subTemplateType2.id : L && L.length > 0 && (A = n.subTemplateType.id);
|
|
1049
|
+
const re = {
|
|
1050
|
+
enerexIdentifier: "",
|
|
1051
|
+
projectId: "",
|
|
1052
|
+
templateId: p,
|
|
1053
|
+
templateType: A,
|
|
1054
|
+
name: n.templateName.trim(),
|
|
1055
|
+
html: d.html,
|
|
1056
|
+
css: d.css,
|
|
1057
|
+
subject: n.templateType.id === "2" ? n?.subject ?? "" : "",
|
|
1058
|
+
parent_id: N
|
|
1059
|
+
};
|
|
1060
|
+
if (await de(re)) {
|
|
1061
|
+
T();
|
|
1062
|
+
const q = await Z({ id: p });
|
|
1063
|
+
F(q || void 0), h();
|
|
1064
|
+
}
|
|
981
1065
|
}
|
|
982
1066
|
);
|
|
983
1067
|
};
|
|
984
|
-
return /* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
|
|
1068
|
+
return /* @__PURE__ */ l(ue, { className: "border border-0 text-start", children: /* @__PURE__ */ l(ue.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ l("form", { children: /* @__PURE__ */ l("div", { className: "template-list-container gap-3", children: /* @__PURE__ */ $(ke, { children: [
|
|
1069
|
+
/* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1070
|
+
W,
|
|
987
1071
|
{
|
|
988
1072
|
label: "Category",
|
|
989
|
-
control:
|
|
990
|
-
error:
|
|
991
|
-
options:
|
|
1073
|
+
control: C,
|
|
1074
|
+
error: x,
|
|
1075
|
+
options: ee,
|
|
992
1076
|
required: !0,
|
|
993
|
-
disabled:
|
|
1077
|
+
disabled: u || E || I || D || !i,
|
|
994
1078
|
validation: {
|
|
995
1079
|
required: {
|
|
996
1080
|
value: !0,
|
|
997
1081
|
message: "Select a category"
|
|
998
1082
|
}
|
|
999
1083
|
},
|
|
1000
|
-
...
|
|
1084
|
+
...a("templateType")
|
|
1001
1085
|
}
|
|
1002
1086
|
) }),
|
|
1003
|
-
|
|
1004
|
-
|
|
1087
|
+
L && L.length > 0 && /* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1088
|
+
W,
|
|
1005
1089
|
{
|
|
1006
1090
|
label: "Type",
|
|
1007
|
-
control:
|
|
1008
|
-
error:
|
|
1009
|
-
options:
|
|
1091
|
+
control: C,
|
|
1092
|
+
error: x,
|
|
1093
|
+
options: L,
|
|
1010
1094
|
required: !0,
|
|
1011
|
-
disabled:
|
|
1095
|
+
disabled: u || E || I || D || !i,
|
|
1012
1096
|
validation: {
|
|
1013
1097
|
required: {
|
|
1014
1098
|
value: !0,
|
|
1015
1099
|
message: "Select a type"
|
|
1016
1100
|
}
|
|
1017
1101
|
},
|
|
1018
|
-
...
|
|
1102
|
+
...a("subTemplateType")
|
|
1019
1103
|
}
|
|
1020
1104
|
) }),
|
|
1021
|
-
|
|
1022
|
-
|
|
1105
|
+
j && j.length > 0 && /* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1106
|
+
W,
|
|
1023
1107
|
{
|
|
1024
1108
|
label: "Sub Type",
|
|
1025
|
-
control:
|
|
1026
|
-
error:
|
|
1027
|
-
options:
|
|
1109
|
+
control: C,
|
|
1110
|
+
error: x,
|
|
1111
|
+
options: j,
|
|
1028
1112
|
required: !0,
|
|
1029
|
-
disabled:
|
|
1113
|
+
disabled: u || E || I || D || !i,
|
|
1030
1114
|
validation: {
|
|
1031
1115
|
required: {
|
|
1032
1116
|
value: !0,
|
|
1033
1117
|
message: "Select a subtype"
|
|
1034
1118
|
}
|
|
1035
1119
|
},
|
|
1036
|
-
...
|
|
1120
|
+
...a("subTemplateType2")
|
|
1037
1121
|
}
|
|
1038
1122
|
) }),
|
|
1039
|
-
/* @__PURE__ */
|
|
1040
|
-
|
|
1123
|
+
/* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1124
|
+
W,
|
|
1041
1125
|
{
|
|
1042
1126
|
label: "Template",
|
|
1043
|
-
control:
|
|
1044
|
-
error:
|
|
1045
|
-
disabled:
|
|
1046
|
-
options:
|
|
1127
|
+
control: C,
|
|
1128
|
+
error: x,
|
|
1129
|
+
disabled: u || E || I || D || !i,
|
|
1130
|
+
options: pe(),
|
|
1047
1131
|
required: !1,
|
|
1048
|
-
...
|
|
1132
|
+
...a("template")
|
|
1049
1133
|
}
|
|
1050
1134
|
) }),
|
|
1051
|
-
/* @__PURE__ */
|
|
1052
|
-
|
|
1135
|
+
/* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1136
|
+
ye,
|
|
1053
1137
|
{
|
|
1054
1138
|
label: "Name",
|
|
1055
|
-
register:
|
|
1056
|
-
error:
|
|
1139
|
+
register: a,
|
|
1140
|
+
error: x,
|
|
1057
1141
|
required: !0,
|
|
1058
1142
|
name: "templateName",
|
|
1059
1143
|
validation: {
|
|
@@ -1064,80 +1148,109 @@ const oe = /* @__PURE__ */ Ge(Ke), ae = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1064
1148
|
}
|
|
1065
1149
|
}
|
|
1066
1150
|
) }),
|
|
1067
|
-
|
|
1068
|
-
|
|
1151
|
+
f("templateType")?.id === "2" && /* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1152
|
+
ye,
|
|
1069
1153
|
{
|
|
1070
1154
|
label: "Subject",
|
|
1071
|
-
register:
|
|
1072
|
-
error:
|
|
1155
|
+
register: a,
|
|
1156
|
+
error: x,
|
|
1073
1157
|
required: !1,
|
|
1074
1158
|
name: "subject"
|
|
1075
1159
|
}
|
|
1076
1160
|
) }),
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
|
|
1161
|
+
/* @__PURE__ */ $(M, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
|
|
1162
|
+
/* @__PURE__ */ l(
|
|
1163
|
+
se,
|
|
1080
1164
|
{
|
|
1081
1165
|
style: { width: "70px" },
|
|
1082
1166
|
variant: "primary",
|
|
1083
|
-
disabled:
|
|
1167
|
+
disabled: u || E || I || D || !i,
|
|
1084
1168
|
onClick: () => {
|
|
1085
|
-
|
|
1169
|
+
X(void 0), _(), te([]), ne([]), o();
|
|
1086
1170
|
},
|
|
1087
|
-
children:
|
|
1088
|
-
|
|
1171
|
+
children: E || I ? /* @__PURE__ */ l(
|
|
1172
|
+
Y,
|
|
1089
1173
|
{
|
|
1090
1174
|
animation: "border",
|
|
1091
1175
|
style: { width: "11px", height: "11px" },
|
|
1092
1176
|
size: "sm",
|
|
1093
1177
|
role: "status",
|
|
1094
1178
|
className: "me-1",
|
|
1095
|
-
children: /* @__PURE__ */
|
|
1179
|
+
children: /* @__PURE__ */ l("span", { className: "visually-hidden", children: "Loading..." })
|
|
1096
1180
|
}
|
|
1097
1181
|
) : "Clear"
|
|
1098
1182
|
}
|
|
1099
1183
|
),
|
|
1100
|
-
(
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1184
|
+
(f("templateType")?.id.toString() !== "2" || (f("templateType")?.id.toString() === "2" && (k?.id ?? "")) !== "") && /* @__PURE__ */ $(De, { children: [
|
|
1185
|
+
!(k?.readonly && r) && /* @__PURE__ */ l(
|
|
1186
|
+
se,
|
|
1187
|
+
{
|
|
1188
|
+
type: "button",
|
|
1189
|
+
onClick: c(je),
|
|
1190
|
+
variant: "primary",
|
|
1191
|
+
style: { width: "80px" },
|
|
1192
|
+
disabled: u || E || I || D || !i,
|
|
1193
|
+
children: E || I ? /* @__PURE__ */ l(
|
|
1194
|
+
Y,
|
|
1195
|
+
{
|
|
1196
|
+
animation: "border",
|
|
1197
|
+
style: { width: "11px", height: "11px" },
|
|
1198
|
+
size: "sm",
|
|
1199
|
+
role: "status",
|
|
1200
|
+
className: "me-1",
|
|
1201
|
+
children: /* @__PURE__ */ l("span", { className: "visually-hidden", children: "Loading..." })
|
|
1202
|
+
}
|
|
1203
|
+
) : k?.readonly ? "Save as" : "Save"
|
|
1204
|
+
}
|
|
1205
|
+
),
|
|
1206
|
+
k?.readonly && r && /* @__PURE__ */ l(
|
|
1207
|
+
se,
|
|
1208
|
+
{
|
|
1209
|
+
type: "button",
|
|
1210
|
+
onClick: c(Oe),
|
|
1211
|
+
variant: "primary",
|
|
1212
|
+
style: { width: "80px" },
|
|
1213
|
+
disabled: u || E || I || D || !i,
|
|
1214
|
+
children: E || I ? /* @__PURE__ */ l(
|
|
1215
|
+
Y,
|
|
1216
|
+
{
|
|
1217
|
+
animation: "border",
|
|
1218
|
+
style: { width: "11px", height: "11px" },
|
|
1219
|
+
size: "sm",
|
|
1220
|
+
role: "status",
|
|
1221
|
+
className: "me-1",
|
|
1222
|
+
children: /* @__PURE__ */ l("span", { className: "visually-hidden", children: "Loading..." })
|
|
1223
|
+
}
|
|
1224
|
+
) : "Save"
|
|
1225
|
+
}
|
|
1226
|
+
)
|
|
1227
|
+
] })
|
|
1120
1228
|
] })
|
|
1121
1229
|
] }) }) }) }) });
|
|
1122
|
-
},
|
|
1123
|
-
const [
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1230
|
+
}, ut = ({ config: t }) => {
|
|
1231
|
+
const [s, o] = S(!1), [i, r] = S(), [e, a] = S(!1);
|
|
1232
|
+
v(() => {
|
|
1233
|
+
t.isAdmin || a(!0);
|
|
1234
|
+
}, []);
|
|
1235
|
+
const [c, T] = S(!1);
|
|
1236
|
+
return /* @__PURE__ */ l(Fe, { configs: t, children: /* @__PURE__ */ l(Ve, { children: /* @__PURE__ */ $("div", { className: "root-widget", children: [
|
|
1237
|
+
/* @__PURE__ */ l(
|
|
1238
|
+
it,
|
|
1127
1239
|
{
|
|
1128
|
-
templateLoading:
|
|
1129
|
-
onSelectItem: (
|
|
1130
|
-
if (
|
|
1131
|
-
let
|
|
1240
|
+
templateLoading: T,
|
|
1241
|
+
onSelectItem: (f) => {
|
|
1242
|
+
if (r(f), t.isAdmin && a(!0), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
|
|
1243
|
+
let _ = z;
|
|
1132
1244
|
window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1133
|
-
|
|
1134
|
-
|
|
1245
|
+
f?.html ?? _,
|
|
1246
|
+
f?.css ?? "",
|
|
1135
1247
|
""
|
|
1136
1248
|
);
|
|
1137
1249
|
}
|
|
1138
1250
|
},
|
|
1251
|
+
editorInitialized: s,
|
|
1139
1252
|
onReset: () => {
|
|
1140
|
-
|
|
1253
|
+
T(!1), r(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1141
1254
|
z,
|
|
1142
1255
|
"",
|
|
1143
1256
|
""
|
|
@@ -1145,19 +1258,20 @@ const oe = /* @__PURE__ */ Ge(Ke), ae = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1145
1258
|
}
|
|
1146
1259
|
}
|
|
1147
1260
|
),
|
|
1148
|
-
/* @__PURE__ */
|
|
1149
|
-
|
|
1261
|
+
e && /* @__PURE__ */ l(
|
|
1262
|
+
Ye,
|
|
1150
1263
|
{
|
|
1264
|
+
onEditorInitialized: o,
|
|
1151
1265
|
templateHTML: {
|
|
1152
|
-
css:
|
|
1153
|
-
html:
|
|
1266
|
+
css: i?.css ?? "",
|
|
1267
|
+
html: i?.html ?? z
|
|
1154
1268
|
},
|
|
1155
|
-
loading:
|
|
1269
|
+
loading: c,
|
|
1156
1270
|
className: "col-span-5"
|
|
1157
1271
|
}
|
|
1158
1272
|
)
|
|
1159
1273
|
] }) }) });
|
|
1160
1274
|
};
|
|
1161
1275
|
export {
|
|
1162
|
-
|
|
1276
|
+
ut as EditorWidget
|
|
1163
1277
|
};
|