@openbkn/workshop 0.2.2-rc.5 → 0.2.2
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 +83 -13
- package/component.d.ts +10 -0
- package/dist/ActionConfirm-DJ91X3ml.js +236 -0
- package/dist/ActionFailure-ZgPt_3B-.js +37 -0
- package/dist/AgentChat-CRYai8ge.js +1062 -0
- package/dist/AppFormModal-D73ucaHK.js +4282 -0
- package/dist/AppListPage-D87piiOw.js +1364 -0
- package/dist/AskDrawer-BUMYsRnt.js +38 -0
- package/dist/ComputedView-CgYrDbx1.js +3221 -0
- package/dist/ConclusionApply-sjGfoEBY.js +153 -0
- package/dist/CypherEditor-lus6FA5L.js +485 -0
- package/dist/LandingList-6JI6864C.js +230 -0
- package/dist/MenuUnfoldOutlined-Cdg24l2h.js +27 -0
- package/dist/ModelTrial-ClHFGTpQ.js +359 -0
- package/dist/PageRenderer-DBd_g6mN.js +85480 -0
- package/dist/README-DjRyTQSR.js +76 -0
- package/dist/ScenarioApply-DtW_hh47.js +590 -0
- package/dist/SimulateForm-C-i08Jjd.js +153 -0
- package/dist/Subgraph-CnrkH9AN.js +32586 -0
- package/dist/WorkshopLabPage-DiVXQL9e.js +11364 -0
- package/dist/WorkshopRunPage-6hjRUf64.js +253 -0
- package/dist/abnfDiagram-WEYOIA3C-beRNhN3c.js +87 -0
- package/dist/action-type-tool.service-B2B74fKC.js +1060 -0
- package/dist/actionButton-DA5CNEzx.js +94 -0
- package/dist/actionButton.en-US-qjeqA7hs.js +94 -0
- package/dist/agentChat-EoDznd58.js +116 -0
- package/dist/agentChat.en-US-B6-pFd9Y.js +116 -0
- package/dist/alertList-DqditwM8.js +84 -0
- package/dist/alertList.en-US-BAXAgltP.js +84 -0
- package/dist/architectureDiagram-ZHVYKT53-DY2l1qxx.js +4779 -0
- package/dist/asOfSlider-QPvHWUMV.js +83 -0
- package/dist/asOfSlider.en-US-BI4jVfSn.js +83 -0
- package/dist/bkn-agent-execution.service-DVh-SHyl.js +205 -0
- package/dist/blockDiagram-RJAE7QA3-DR0mjN2h.js +1435 -0
- package/dist/c4Diagram-XDPPPE54-DH5zsGug.js +1518 -0
- package/dist/channel-B034hcOF.js +5 -0
- package/dist/china-C6m7zXIv.js +9 -0
- package/dist/chunk-2E7WHVMD-Ba3svxgx.js +664 -0
- package/dist/chunk-2Q5K7J3B-rT4eU6_y.js +15 -0
- package/dist/chunk-4EMNKR2T-C1kQZYHK.js +262 -0
- package/dist/chunk-55XCU76K-dcpLOktb.js +68 -0
- package/dist/chunk-5VM5RSS4-BdpQuzmO.js +19 -0
- package/dist/chunk-JWPE2WC7-CDBrSjU7.js +8 -0
- package/dist/chunk-VQ5W62QI-BiVKc40w.js +19 -0
- package/dist/chunk-XXDRQBXY-CPYrcdVW.js +8 -0
- package/dist/chunk-ZCHMQSOR-BG8OLpvb.js +451 -0
- package/dist/classDiagram-v2-4MYWR3UA-DqbpQpwI.js +1564 -0
- package/dist/component.d-DFoMKuUv.js +179 -0
- package/dist/cose-bilkent-JH36ORCC-CdXk4sPf.js +2609 -0
- package/dist/customComponents-DasaZ6pq.js +4 -0
- package/dist/customComponents.en-US-CkabuCXg.js +79 -0
- package/dist/customParseFormat-C0uLEpdq.js +182 -0
- package/dist/cynefin-EF2NZ3EQ-D7MVnMHu.js +21746 -0
- package/dist/cynefinDiagram-WF24UDRP-BYT_KpDL.js +299 -0
- package/dist/cytoscape.esm-BCV9V6aO.js +18760 -0
- package/dist/d3-scale-DA8IHmf0.js +1841 -0
- package/dist/dagre-NK4GIZVX-l-ghPdM8.js +2154 -0
- package/dist/dateRange-BbkLMg8L.js +79 -0
- package/dist/dateRange.en-US-CV12Q02G.js +79 -0
- package/dist/dayjs.min-DZ-YV8Mv.js +284 -0
- package/dist/diagram-CBK3MWTC-Bt3HiwvA.js +542 -0
- package/dist/diagram-I5XIIV2D-DcbqfBjx.js +150 -0
- package/dist/diagram-ODIL2UCW-9PC1n3n5.js +346 -0
- package/dist/diagram-PFBEJUXE-DGhr2kc7.js +478 -0
- package/dist/diagram-RJA3I4VV-DwzpOjZ_.js +219 -0
- package/dist/diagram-TYUNFSNR-B3Bd3TDU.js +2583 -0
- package/dist/dropdownFilter-DOi_8-ZT.js +76 -0
- package/dist/dropdownFilter.en-US-BiXpvXtF.js +76 -0
- package/dist/ebnfDiagram-V4P3TTPT-E5NN2oKc.js +109 -0
- package/dist/elk-QONTBCTQ-dFjcujl_.js +49170 -0
- package/dist/erDiagram-KYQIGQAA-BMrasBzB.js +1061 -0
- package/dist/eventList-CnsAwfDS.js +115 -0
- package/dist/eventList.en-US-Cof3rCLq.js +115 -0
- package/dist/eventReport-XS-HegnH.js +76 -0
- package/dist/eventReport.en-US-DTx4vzWT.js +76 -0
- package/dist/flowDiagram-IUGLLWBU-BGIBH0q0.js +1769 -0
- package/dist/ganttChart-DEeSvTJA.js +77 -0
- package/dist/ganttChart.en-US-SwRKrnoD.js +77 -0
- package/dist/ganttDiagram-R7GPNTJY-C0tb1Lpp.js +1741 -0
- package/dist/generateCypher-Ch9_lQa6.js +399 -0
- package/dist/gitGraphDiagram-PDYL7XHY-DBqcOa-c.js +815 -0
- package/dist/graph-CKJmgLki.js +1541 -0
- package/dist/index-BA-GzCXt.js +441 -0
- package/dist/infoDiagram-MVDRKAX5-Bwuki4JA.js +24 -0
- package/dist/ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js +622 -0
- package/dist/journeyDiagram-BOSHW7O7-C99m34Bb.js +834 -0
- package/dist/kanban-definition-FNSA4HC5-mdqjODsT.js +724 -0
- package/dist/katex-BsrBVQKd.js +11314 -0
- package/dist/manifest-BjV1PJ6u.js +41 -0
- package/dist/mermaid.core-yQghUlIz.js +17642 -0
- package/dist/metricCards-CSb-_cT2.js +104 -0
- package/dist/metricCards.en-US-BLLhRsQU.js +104 -0
- package/dist/mindmap-definition-6OY57UG3-BZhO2wX4.js +834 -0
- package/dist/modelTrial-Bvb-RhGt.js +137 -0
- package/dist/modelTrial.en-US-DYcuor-G.js +137 -0
- package/dist/models-DekiCOuZ.js +6 -0
- package/dist/object-metric-numeric-vs3BeDkH.js +42 -0
- package/dist/object-metric.service-flZgBMRX.js +233 -0
- package/dist/objectDetail-SQUbp4Py.js +117 -0
- package/dist/objectDetail.en-US-DW3mlONM.js +117 -0
- package/dist/objectList-D99wPtJH.js +97 -0
- package/dist/objectList.en-US-PBBNyVLW.js +97 -0
- package/dist/objectTable-0jsFFMN3.js +127 -0
- package/dist/objectTable.en-US-yWEs8qc_.js +127 -0
- package/dist/pegDiagram-ECIUJNBX-BDa5RfZt.js +95 -0
- package/dist/pieDiagram-GNMPY74T-DNVtzXPv.js +165 -0
- package/dist/pivotTable-CHmQw18-.js +102 -0
- package/dist/pivotTable.en-US-B4uv4P08.js +102 -0
- package/dist/prompt-DYrjlEFr.js +373 -0
- package/dist/quadrantDiagram-D57K4MC3-vK0f2OvQ.js +1023 -0
- package/dist/railroadDiagram-Y72NRBL7-j6ZrTmRp.js +77 -0
- package/dist/regionMap-Cme-JyV_.js +128 -0
- package/dist/regionMap.en-US-Bwr2_p32.js +128 -0
- package/dist/requirementDiagram-EQYSW5RA-DgfEyljA.js +886 -0
- package/dist/sankeyDiagram-SY24JHO5-CImx-IX0.js +1160 -0
- package/dist/scenarioBar-BV43p7n-.js +122 -0
- package/dist/scenarioBar.en-US-5KqMQ2Bg.js +122 -0
- package/dist/scheduleGantt-CTYO-zYP.js +180 -0
- package/dist/scheduleGantt.en-US-hE7mvVUW.js +180 -0
- package/dist/searchBox-Ca7w0f_6.js +67 -0
- package/dist/searchBox.en-US-ArS_XBvB.js +67 -0
- package/dist/segmentedFilter-MhjVcWo0.js +80 -0
- package/dist/segmentedFilter.en-US-BxNrQO5T.js +80 -0
- package/dist/sequenceDiagram-BLEHNHQU-nWmjd1ci.js +2969 -0
- package/dist/sizeCapture-INFHLROL-D3jlbt7h.js +46 -0
- package/dist/stageChain-BxBafwjD.js +74 -0
- package/dist/stageChain.en-US-CP0G27n8.js +74 -0
- package/dist/stateDiagram-v2-A6IESKWZ-DG1ZetEu.js +1514 -0
- package/dist/subgraph-7n4SwliR.js +71 -0
- package/dist/subgraph.en-US-BNvY18IW.js +71 -0
- package/dist/swimlanes-B3ENRKFQ-cCmJE8AU.js +4991 -0
- package/dist/swimlanesDiagram-AYQRV4AK-CtuhyguU.js +14 -0
- package/dist/taskInbox-DGWYeI2b.js +118 -0
- package/dist/taskInbox.en-US-B-OzDmVl.js +118 -0
- package/dist/text-BqSVQKS6.js +78 -0
- package/dist/text.en-US-BhAxy_LE.js +78 -0
- package/dist/timeline-definition-JXYKGLGB-Cc-INsOv.js +1057 -0
- package/dist/trendChart-BjEeRS5_.js +135 -0
- package/dist/trendChart.en-US-BBGqWUKM.js +135 -0
- package/dist/useLabData-Df-jEHKs.js +20470 -0
- package/dist/usecaseDiagram-WPOLBNNX-r8wVjopm.js +7920 -0
- package/dist/vennDiagram-Q3Y3IDCW-BZiOcgrj.js +1579 -0
- package/dist/wardleyDiagram-IVAIDKWA-16jd07C_.js +675 -0
- package/dist/workshop-app-DnHNjBqy.js +86038 -0
- package/dist/workshop-app.css +1 -0
- package/dist/workshop-app.js +4 -0
- package/dist/world-Djau1JyJ.js +9 -0
- package/dist/xychartDiagram-4URNHDU4-C8DwWQNh.js +1460 -0
- package/dist-cli/workshop.js +341 -218
- package/example/host.js +109 -0
- package/example/index.html +93 -0
- package/example/server.mjs +237 -0
- package/index.d.ts +48 -0
- package/lib/validate.js +47 -1
- package/package.json +17 -5
- package/runtime/frame-runtime.js +13 -1
- package/workshop-component.js +32 -12
- package/workshop.js +2 -0
|
@@ -0,0 +1,3221 @@
|
|
|
1
|
+
import { Q as ea, $ as Me, C as aa, u as _, j as e, i as F, a as $, I, a0 as sa, a1 as Ae, r as A, c as ge, _ as xe, a2 as Le, a3 as Q, a4 as te, a5 as _e, y as me, a6 as ye, x as oa, V as la, X as ue, a7 as ta, b as na, a8 as fe, a9 as q, aa as Ie, ab as je, ac as ra, ad as ia, ae as ca, af as pa, ag as da, ah as ma, z as de } from "./workshop-app-DnHNjBqy.js";
|
|
2
|
+
import { M as ua, e as Re, d as ha, w as ba } from "./generateCypher-Ch9_lQa6.js";
|
|
3
|
+
import { X as n, T as G, R as Y, a6 as K, a7 as ee, a8 as ka, a9 as ja, aa as U, ab as ke, ac as wa, ad as ga, i as xa, a3 as he, ae as fa, F as De, af as va } from "./PageRenderer-DBd_g6mN.js";
|
|
4
|
+
import { ap as P, p as ne, as as La, a as be, at as ya, au as Na, M as ae, av as Be, aw as Sa, ax as Ca, ay as Ta, A as re, T as J, az as za, aA as $a, aB as Oa, aC as Fa, aD as Pa, aE as Ea, aF as Ma, aG as Aa, aH as Ne, aI as Se, aJ as _a, aK as Ia, aL as Ce, ab as He, aM as Ra, aN as Ve, aO as Da, aP as Ba, aQ as Ha, aR as Va, aS as Ua, aT as Ga, aU as Xa, aV as Wa, u as Ka, b as Ja } from "./useLabData-Df-jEHKs.js";
|
|
5
|
+
function Za(a, i) {
|
|
6
|
+
const t = a.fields.map((w) => {
|
|
7
|
+
const p = a.samples[w.name];
|
|
8
|
+
return `- ${w.name}:${w.type}(${w.label})${p?.length ? `,取值如:${p.join("、")}` : ""}`;
|
|
9
|
+
}).join(`
|
|
10
|
+
`);
|
|
11
|
+
return `你为业务应用的数据源「${a.sourceLabel}」(对象类 ${a.context.objectType})写一个计算列。
|
|
12
|
+
|
|
13
|
+
${aa}
|
|
14
|
+
|
|
15
|
+
规则可以读的字段(名称:类型(中文名)):
|
|
16
|
+
${t}
|
|
17
|
+
|
|
18
|
+
${i}
|
|
19
|
+
字段名、关系 id、属性名一律照清单原样写,不要猜;和文本值比较时用上面列出的取值。
|
|
20
|
+
关联统计(related)用下面网络里的关系:
|
|
21
|
+
|
|
22
|
+
${ha(a.context.kn)}
|
|
23
|
+
|
|
24
|
+
只输出 JSON:{"field": { name, label, kind, ... }, "explanation": "一句话说明规则"}。`;
|
|
25
|
+
}
|
|
26
|
+
function qa(a) {
|
|
27
|
+
const i = ba(a).match(/\{[\s\S]*\}/);
|
|
28
|
+
if (!i) throw new Error("回复里没有找到 JSON");
|
|
29
|
+
const t = JSON.parse(i[0]);
|
|
30
|
+
if (typeof t.field != "object" || t.field === null) throw new Error("回复里没有 field");
|
|
31
|
+
return {
|
|
32
|
+
field: t.field,
|
|
33
|
+
explanation: typeof t.explanation == "string" ? t.explanation : ""
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function Qa(a) {
|
|
37
|
+
const { model: i, scope: t, instruction: w, current: p, taken: k, signal: c, onStep: s } = a, o = a.maxAttempts ?? 3, d = p?.name || void 0, h = d ? `字段名固定为 ${d}。` : `字段名自拟(字母开头的英文标识),不能用:${k.join("、") || "(无)"}。`, r = [
|
|
38
|
+
{
|
|
39
|
+
role: "user",
|
|
40
|
+
content: p?.label ? `当前字段:
|
|
41
|
+
${JSON.stringify(p)}
|
|
42
|
+
|
|
43
|
+
修改要求:${w}` : w
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
let u = "";
|
|
47
|
+
for (let l = 1; l <= o; l++) {
|
|
48
|
+
s?.({ kind: "generating", attempt: l });
|
|
49
|
+
const { text: j } = await ea({
|
|
50
|
+
model: i,
|
|
51
|
+
system: Za(t, h),
|
|
52
|
+
messages: r,
|
|
53
|
+
maxOutputTokens: ua,
|
|
54
|
+
maxRetries: 0,
|
|
55
|
+
abortSignal: c
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
const g = qa(j), b = {
|
|
59
|
+
...g.field,
|
|
60
|
+
...d ? { name: d } : {}
|
|
61
|
+
};
|
|
62
|
+
if (!d && k.includes(b.name))
|
|
63
|
+
throw new Error(`字段名 ${b.name} 已被占用`);
|
|
64
|
+
const T = Me([b], t.fields, "field", t.context);
|
|
65
|
+
if (T.length > 0) throw new Error(T.slice(0, 6).join(";"));
|
|
66
|
+
return { ok: !0, field: b, explanation: g.explanation, attempts: l };
|
|
67
|
+
} catch (g) {
|
|
68
|
+
if (c?.aborted) throw g;
|
|
69
|
+
u = Re(g), s?.({ kind: "failed", error: u }), r.push(
|
|
70
|
+
{ role: "assistant", content: j },
|
|
71
|
+
{ role: "user", content: `校验未通过:${u}
|
|
72
|
+
请对照字段清单修正,仍只输出 JSON。` }
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { ok: !1, error: u, attempts: o };
|
|
77
|
+
}
|
|
78
|
+
function Ya(a, i, t = 12) {
|
|
79
|
+
const w = {};
|
|
80
|
+
for (const p of i) {
|
|
81
|
+
if (p.type !== "text") continue;
|
|
82
|
+
const k = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const c of a) {
|
|
84
|
+
const s = c[p.name];
|
|
85
|
+
if (!(s == null || s === "") && (k.add(String(s)), k.size > t))
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
k.size > 0 && k.size <= t && (w[p.name] = [...k]);
|
|
89
|
+
}
|
|
90
|
+
return w;
|
|
91
|
+
}
|
|
92
|
+
function es({ source: a, fields: i, save: t, onClose: w }) {
|
|
93
|
+
const { t: p } = _(), k = a.formats ?? {}, c = Object.keys(k), s = i.filter((l) => !c.includes(l.name)), o = (l) => i.find((j) => j.name === l)?.label ?? l, d = (l) => i.find((j) => j.name === l)?.type, h = (l, j) => {
|
|
94
|
+
const g = { ...k };
|
|
95
|
+
j === null ? delete g[l] : g[l] = j, t({ ...a, formats: Object.keys(g).length > 0 ? g : void 0 });
|
|
96
|
+
}, r = (l, j) => {
|
|
97
|
+
const g = { ...k[l], ...j };
|
|
98
|
+
for (const b of Object.keys(g))
|
|
99
|
+
(g[b] === void 0 || Array.isArray(g[b]) && g[b].length === 0) && delete g[b];
|
|
100
|
+
h(l, g);
|
|
101
|
+
}, u = (l, j) => {
|
|
102
|
+
const g = j.trim() || void 0;
|
|
103
|
+
g !== k[l]?.unit && r(l, { unit: g });
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.formats, children: [
|
|
106
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.formatsHead, children: [
|
|
107
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: p("workshopLab.formats.title") }),
|
|
108
|
+
/* @__PURE__ */ e.jsx(
|
|
109
|
+
F,
|
|
110
|
+
{
|
|
111
|
+
size: "small",
|
|
112
|
+
showSearch: !0,
|
|
113
|
+
optionFilterProp: "label",
|
|
114
|
+
className: n.fieldSelect,
|
|
115
|
+
value: null,
|
|
116
|
+
placeholder: p("workshopLab.formats.add"),
|
|
117
|
+
options: s.map((l) => ({ value: l.name, label: l.label })),
|
|
118
|
+
onChange: (l) => h(l, {})
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
c.length === 0 && w && /* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: w, children: p("workshopLab.blocks.cancel") })
|
|
122
|
+
] }),
|
|
123
|
+
c.map((l) => {
|
|
124
|
+
const j = k[l], g = j.colors ?? [];
|
|
125
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.formatItem, children: [
|
|
126
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
127
|
+
/* @__PURE__ */ e.jsx("b", { children: o(l) }),
|
|
128
|
+
/* @__PURE__ */ e.jsx("span", { className: n.mono, children: l }),
|
|
129
|
+
d(l) === "number" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
130
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.formats.unit") }),
|
|
131
|
+
/* @__PURE__ */ e.jsx(
|
|
132
|
+
I,
|
|
133
|
+
{
|
|
134
|
+
size: "small",
|
|
135
|
+
className: n.unitInput,
|
|
136
|
+
maxLength: 8,
|
|
137
|
+
defaultValue: j.unit ?? "",
|
|
138
|
+
onBlur: (b) => u(l, b.target.value),
|
|
139
|
+
onPressEnter: (b) => !b.nativeEvent.isComposing && u(l, b.currentTarget.value)
|
|
140
|
+
},
|
|
141
|
+
j.unit ?? ""
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.formats.decimals") }),
|
|
144
|
+
/* @__PURE__ */ e.jsx(
|
|
145
|
+
G,
|
|
146
|
+
{
|
|
147
|
+
size: "small",
|
|
148
|
+
min: 0,
|
|
149
|
+
max: sa,
|
|
150
|
+
value: j.decimals ?? null,
|
|
151
|
+
onChange: (b) => r(l, { decimals: b ?? void 0 })
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
156
|
+
/* @__PURE__ */ e.jsx(
|
|
157
|
+
$,
|
|
158
|
+
{
|
|
159
|
+
size: "small",
|
|
160
|
+
type: "link",
|
|
161
|
+
icon: /* @__PURE__ */ e.jsx(ne, {}),
|
|
162
|
+
onClick: () => r(l, { colors: [...g, { when: [], tone: "danger" }] }),
|
|
163
|
+
children: p("workshopLab.formats.addColor")
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, onClick: () => h(l, null), children: p("workshopLab.formats.remove") })
|
|
167
|
+
] }),
|
|
168
|
+
g.map((b, T) => /* @__PURE__ */ e.jsxs("div", { className: n.colorRule, children: [
|
|
169
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
170
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.formats.when") }),
|
|
171
|
+
/* @__PURE__ */ e.jsx(
|
|
172
|
+
F,
|
|
173
|
+
{
|
|
174
|
+
size: "small",
|
|
175
|
+
value: b.tone,
|
|
176
|
+
options: Ae.map((v) => ({
|
|
177
|
+
value: v,
|
|
178
|
+
label: p(`workshopLab.computed.tones.${v}`)
|
|
179
|
+
})),
|
|
180
|
+
onChange: (v) => r(l, {
|
|
181
|
+
colors: g.map((C, S) => S === T ? { ...C, tone: v } : C)
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ e.jsx(
|
|
186
|
+
$,
|
|
187
|
+
{
|
|
188
|
+
size: "small",
|
|
189
|
+
type: "text",
|
|
190
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
191
|
+
"aria-label": p("workshopLab.formats.removeColor"),
|
|
192
|
+
onClick: () => r(l, { colors: g.filter((v, C) => C !== T) })
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ e.jsx(
|
|
197
|
+
K,
|
|
198
|
+
{
|
|
199
|
+
value: b.when,
|
|
200
|
+
fields: i,
|
|
201
|
+
source: a,
|
|
202
|
+
onChange: (v) => r(l, {
|
|
203
|
+
colors: g.map((C, S) => S === T ? { ...C, when: v } : C)
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] }, T))
|
|
208
|
+
] }, l);
|
|
209
|
+
})
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
const Te = ["number", "date", "text"], ze = /* @__PURE__ */ new Set(["sum", "avg", "min", "max"]), we = (a, i) => {
|
|
213
|
+
for (let t = 1; ; t++) if (!a.includes(`${i}${t}`)) return `${i}${t}`;
|
|
214
|
+
};
|
|
215
|
+
function as({
|
|
216
|
+
source: a,
|
|
217
|
+
network: i,
|
|
218
|
+
scenarioParams: t = [],
|
|
219
|
+
save: w,
|
|
220
|
+
adding: p = !1,
|
|
221
|
+
onClose: k
|
|
222
|
+
}) {
|
|
223
|
+
const { t: c } = _(), s = a.models ?? [], o = () => ({
|
|
224
|
+
index: s.length,
|
|
225
|
+
model: {
|
|
226
|
+
id: we(
|
|
227
|
+
s.map((u) => u.id),
|
|
228
|
+
"m"
|
|
229
|
+
),
|
|
230
|
+
label: "",
|
|
231
|
+
tool: { box: "", tool: "" },
|
|
232
|
+
inputs: [],
|
|
233
|
+
params: [],
|
|
234
|
+
outputs: [{ name: "result", label: "", type: "number" }],
|
|
235
|
+
measures: []
|
|
236
|
+
}
|
|
237
|
+
}), [d, h] = A.useState(
|
|
238
|
+
() => p && s.length === 0 ? o() : null
|
|
239
|
+
), r = (u) => w({ ...a, models: u.length > 0 ? u : void 0 });
|
|
240
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedItem, children: [
|
|
241
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedHead, children: [
|
|
242
|
+
/* @__PURE__ */ e.jsx("b", { children: c("workshopLab.models.title") }),
|
|
243
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
244
|
+
/* @__PURE__ */ e.jsx(
|
|
245
|
+
$,
|
|
246
|
+
{
|
|
247
|
+
size: "small",
|
|
248
|
+
icon: /* @__PURE__ */ e.jsx(ne, {}),
|
|
249
|
+
disabled: s.length >= La,
|
|
250
|
+
onClick: () => h(o()),
|
|
251
|
+
children: c("workshopLab.models.add")
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
] }),
|
|
255
|
+
s.map((u, l) => {
|
|
256
|
+
const j = u.action ? be(i, u.action.id) : void 0;
|
|
257
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.operationItem, children: [
|
|
258
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
259
|
+
/* @__PURE__ */ e.jsx("b", { children: u.label }),
|
|
260
|
+
" ",
|
|
261
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: u.tool.name ?? u.tool.tool })
|
|
262
|
+
] }),
|
|
263
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.models.summary", {
|
|
264
|
+
params: u.params.map((g) => g.label).join("、") || "—",
|
|
265
|
+
outputs: u.outputs.map((g) => g.label).join("、"),
|
|
266
|
+
measures: u.measures.map((g) => g.label).join("、")
|
|
267
|
+
}) }),
|
|
268
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: j ? c("workshopLab.models.actionText", { name: j.name }) : c("workshopLab.models.noAction") }),
|
|
269
|
+
/* @__PURE__ */ e.jsxs(P, { size: 4, children: [
|
|
270
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: () => h({ index: l, model: u }), children: c("workshopLab.computed.edit") }),
|
|
271
|
+
/* @__PURE__ */ e.jsx(
|
|
272
|
+
ee,
|
|
273
|
+
{
|
|
274
|
+
title: c("workshopLab.models.removeConfirm", { name: u.label }),
|
|
275
|
+
onConfirm: () => r(s.filter((g, b) => b !== l)),
|
|
276
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: c("workshopLab.computed.remove") })
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] })
|
|
280
|
+
] }, u.id);
|
|
281
|
+
}),
|
|
282
|
+
d && /* @__PURE__ */ e.jsx(
|
|
283
|
+
ss,
|
|
284
|
+
{
|
|
285
|
+
initial: d.model,
|
|
286
|
+
source: a,
|
|
287
|
+
network: i,
|
|
288
|
+
scenarioParams: t,
|
|
289
|
+
others: s.filter((u, l) => l !== d.index),
|
|
290
|
+
onCancel: () => {
|
|
291
|
+
h(null), s.length === 0 && k?.();
|
|
292
|
+
},
|
|
293
|
+
onSave: (u) => {
|
|
294
|
+
const l = [...s];
|
|
295
|
+
l[d.index] = u, r(l) && h(null);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
] });
|
|
300
|
+
}
|
|
301
|
+
function ss({
|
|
302
|
+
initial: a,
|
|
303
|
+
source: i,
|
|
304
|
+
network: t,
|
|
305
|
+
scenarioParams: w,
|
|
306
|
+
others: p,
|
|
307
|
+
onCancel: k,
|
|
308
|
+
onSave: c
|
|
309
|
+
}) {
|
|
310
|
+
const { t: s } = _(), [o, d] = A.useState(a), h = (m) => d({ ...o, ...m }), { boxes: r, tools: u } = ka(o.tool.box), l = ge(i, t), j = t.objectTypes[i.objectType]?.properties ?? [], g = ya(i, t, o), b = (t.actionTypes ?? []).filter(
|
|
311
|
+
(m) => m.objectType === i.objectType
|
|
312
|
+
), T = o.action ? be(t, o.action.id) : void 0, v = {
|
|
313
|
+
...o,
|
|
314
|
+
label: o.label.trim(),
|
|
315
|
+
...o.description?.trim() ? { description: o.description.trim() } : {}
|
|
316
|
+
};
|
|
317
|
+
v.description || delete v.description;
|
|
318
|
+
const C = v.label ? Na([...p, v], i, t, "model").filter(
|
|
319
|
+
(m) => m.startsWith(`model[${p.length}]`)
|
|
320
|
+
) : [s("workshopLab.models.needLabel")], S = (m, x, y) => h({
|
|
321
|
+
[m]: o[m].map(
|
|
322
|
+
(R, M) => M === x ? { ...R, ...y } : R
|
|
323
|
+
)
|
|
324
|
+
}), N = (m, x) => h({ [m]: o[m].filter((y, R) => R !== x) }), O = (m, x) => {
|
|
325
|
+
if (!o.action) return;
|
|
326
|
+
const y = { ...o.action.params };
|
|
327
|
+
x ? y[m] = x : delete y[m], h({ action: { ...o.action, params: y } });
|
|
328
|
+
}, L = (m) => m ? m.from === "const" ? "const" : `${m.from}:${m.name}` : void 0;
|
|
329
|
+
return /* @__PURE__ */ e.jsx(
|
|
330
|
+
ae,
|
|
331
|
+
{
|
|
332
|
+
open: !0,
|
|
333
|
+
width: 760,
|
|
334
|
+
title: a.label ? s("workshopLab.models.editTitle", { name: a.label }) : s("workshopLab.models.newTitle"),
|
|
335
|
+
okText: s("workshopLab.computed.save"),
|
|
336
|
+
okButtonProps: { disabled: C.length > 0 },
|
|
337
|
+
onOk: () => c(v),
|
|
338
|
+
onCancel: k,
|
|
339
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
340
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.hint") }),
|
|
341
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
342
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.models.label") }),
|
|
343
|
+
/* @__PURE__ */ e.jsx(
|
|
344
|
+
I,
|
|
345
|
+
{
|
|
346
|
+
size: "small",
|
|
347
|
+
className: n.fieldSelect,
|
|
348
|
+
maxLength: 30,
|
|
349
|
+
placeholder: s("workshopLab.models.labelHint"),
|
|
350
|
+
value: o.label,
|
|
351
|
+
onChange: (m) => h({ label: m.target.value })
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
] }),
|
|
355
|
+
/* @__PURE__ */ e.jsx(
|
|
356
|
+
I,
|
|
357
|
+
{
|
|
358
|
+
size: "small",
|
|
359
|
+
placeholder: s("workshopLab.models.description"),
|
|
360
|
+
value: o.description ?? "",
|
|
361
|
+
onChange: (m) => h({ description: m.target.value })
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.tool") }),
|
|
365
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.toolHint") }),
|
|
366
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
367
|
+
/* @__PURE__ */ e.jsx(
|
|
368
|
+
F,
|
|
369
|
+
{
|
|
370
|
+
size: "small",
|
|
371
|
+
showSearch: !0,
|
|
372
|
+
optionFilterProp: "label",
|
|
373
|
+
className: n.fieldSelect,
|
|
374
|
+
"aria-label": s("workshopLab.models.box"),
|
|
375
|
+
placeholder: s("workshopLab.models.box"),
|
|
376
|
+
loading: r === null,
|
|
377
|
+
value: o.tool.box || void 0,
|
|
378
|
+
options: [
|
|
379
|
+
...(r ?? []).map((m) => ({ value: m.boxId, label: m.boxName })),
|
|
380
|
+
// A box saved before but not listed now still shows, by its id.
|
|
381
|
+
...o.tool.box && r && !r.some((m) => m.boxId === o.tool.box) ? [{ value: o.tool.box, label: o.tool.box }] : []
|
|
382
|
+
],
|
|
383
|
+
onChange: (m) => h({ tool: { box: m, tool: "" } })
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
/* @__PURE__ */ e.jsx(
|
|
387
|
+
F,
|
|
388
|
+
{
|
|
389
|
+
size: "small",
|
|
390
|
+
showSearch: !0,
|
|
391
|
+
optionFilterProp: "label",
|
|
392
|
+
className: n.fieldSelect,
|
|
393
|
+
"aria-label": s("workshopLab.models.toolName"),
|
|
394
|
+
placeholder: s("workshopLab.models.toolName"),
|
|
395
|
+
disabled: !o.tool.box,
|
|
396
|
+
loading: !!o.tool.box && u === null,
|
|
397
|
+
value: o.tool.tool || void 0,
|
|
398
|
+
options: [
|
|
399
|
+
...(u ?? []).map((m) => ({ value: m.toolId, label: m.toolName })),
|
|
400
|
+
...o.tool.tool && u && !u.some((m) => m.toolId === o.tool.tool) ? [{ value: o.tool.tool, label: o.tool.name ?? o.tool.tool }] : []
|
|
401
|
+
],
|
|
402
|
+
onChange: (m) => {
|
|
403
|
+
const x = u?.find((y) => y.toolId === m)?.toolName;
|
|
404
|
+
h({ tool: { box: o.tool.box, tool: m, ...x ? { name: x } : {} } });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
] }),
|
|
409
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.inputs") }),
|
|
410
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.inputsHint") }),
|
|
411
|
+
/* @__PURE__ */ e.jsx(
|
|
412
|
+
F,
|
|
413
|
+
{
|
|
414
|
+
size: "small",
|
|
415
|
+
mode: "multiple",
|
|
416
|
+
"aria-label": s("workshopLab.models.inputs"),
|
|
417
|
+
value: o.inputs,
|
|
418
|
+
options: l.map((m) => ({ value: m.name, label: m.label })),
|
|
419
|
+
onChange: (m) => h({ inputs: m })
|
|
420
|
+
}
|
|
421
|
+
),
|
|
422
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.params") }),
|
|
423
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.paramsHint") }),
|
|
424
|
+
o.params.map((m, x) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
425
|
+
/* @__PURE__ */ e.jsx(
|
|
426
|
+
I,
|
|
427
|
+
{
|
|
428
|
+
size: "small",
|
|
429
|
+
className: n.fieldSelect,
|
|
430
|
+
"aria-label": s("workshopLab.models.paramName"),
|
|
431
|
+
placeholder: s("workshopLab.models.paramName"),
|
|
432
|
+
value: m.name,
|
|
433
|
+
onChange: (y) => S("params", x, { name: y.target.value.trim() })
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ e.jsx(
|
|
437
|
+
I,
|
|
438
|
+
{
|
|
439
|
+
size: "small",
|
|
440
|
+
className: n.fieldSelect,
|
|
441
|
+
"aria-label": s("workshopLab.models.paramLabel"),
|
|
442
|
+
placeholder: s("workshopLab.models.paramLabel"),
|
|
443
|
+
value: m.label,
|
|
444
|
+
onChange: (y) => S("params", x, { label: y.target.value })
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
/* @__PURE__ */ e.jsx(
|
|
448
|
+
F,
|
|
449
|
+
{
|
|
450
|
+
size: "small",
|
|
451
|
+
"aria-label": s("workshopLab.models.paramType"),
|
|
452
|
+
value: m.type,
|
|
453
|
+
options: Te.map((y) => ({
|
|
454
|
+
value: y,
|
|
455
|
+
label: s(`workshopLab.operations.types.${y}`)
|
|
456
|
+
})),
|
|
457
|
+
onChange: (y) => S("params", x, {
|
|
458
|
+
type: y,
|
|
459
|
+
min: void 0,
|
|
460
|
+
max: void 0,
|
|
461
|
+
default: void 0,
|
|
462
|
+
scenarioParam: void 0
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
/* @__PURE__ */ e.jsx(
|
|
467
|
+
F,
|
|
468
|
+
{
|
|
469
|
+
size: "small",
|
|
470
|
+
allowClear: !0,
|
|
471
|
+
className: n.fieldSelect,
|
|
472
|
+
"aria-label": s("workshopLab.models.scenarioParam"),
|
|
473
|
+
placeholder: s("workshopLab.models.scenarioParam"),
|
|
474
|
+
value: m.scenarioParam,
|
|
475
|
+
options: w.filter((y) => y.type === m.type).map((y) => ({ value: y.name, label: y.label })),
|
|
476
|
+
onChange: (y) => S("params", x, { scenarioParam: y })
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
m.type === "number" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
480
|
+
/* @__PURE__ */ e.jsx(
|
|
481
|
+
G,
|
|
482
|
+
{
|
|
483
|
+
size: "small",
|
|
484
|
+
placeholder: s("workshopLab.operations.min"),
|
|
485
|
+
value: m.min ?? null,
|
|
486
|
+
onChange: (y) => S("params", x, { min: y ?? void 0 })
|
|
487
|
+
}
|
|
488
|
+
),
|
|
489
|
+
/* @__PURE__ */ e.jsx(
|
|
490
|
+
G,
|
|
491
|
+
{
|
|
492
|
+
size: "small",
|
|
493
|
+
placeholder: s("workshopLab.operations.max"),
|
|
494
|
+
value: m.max ?? null,
|
|
495
|
+
onChange: (y) => S("params", x, { max: y ?? void 0 })
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ e.jsx(
|
|
499
|
+
G,
|
|
500
|
+
{
|
|
501
|
+
size: "small",
|
|
502
|
+
placeholder: s("workshopLab.operations.default"),
|
|
503
|
+
value: typeof m.default == "number" ? m.default : null,
|
|
504
|
+
onChange: (y) => S("params", x, { default: y ?? void 0 })
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
] }) : /* @__PURE__ */ e.jsx(
|
|
508
|
+
I,
|
|
509
|
+
{
|
|
510
|
+
size: "small",
|
|
511
|
+
className: n.fieldSelect,
|
|
512
|
+
type: m.type === "date" ? "date" : "text",
|
|
513
|
+
placeholder: s("workshopLab.operations.default"),
|
|
514
|
+
value: typeof m.default == "string" ? m.default : "",
|
|
515
|
+
onChange: (y) => S("params", x, { default: y.target.value || void 0 })
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ e.jsx(
|
|
519
|
+
$,
|
|
520
|
+
{
|
|
521
|
+
size: "small",
|
|
522
|
+
type: "text",
|
|
523
|
+
danger: !0,
|
|
524
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
525
|
+
"aria-label": s("workshopLab.config.removeItem"),
|
|
526
|
+
onClick: () => N("params", x)
|
|
527
|
+
}
|
|
528
|
+
)
|
|
529
|
+
] }, x)),
|
|
530
|
+
/* @__PURE__ */ e.jsx(
|
|
531
|
+
$,
|
|
532
|
+
{
|
|
533
|
+
size: "small",
|
|
534
|
+
disabled: o.params.length >= Be,
|
|
535
|
+
onClick: () => h({
|
|
536
|
+
params: [
|
|
537
|
+
...o.params,
|
|
538
|
+
{
|
|
539
|
+
name: we(
|
|
540
|
+
o.params.map((m) => m.name),
|
|
541
|
+
"p"
|
|
542
|
+
),
|
|
543
|
+
label: "",
|
|
544
|
+
type: "number"
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
}),
|
|
548
|
+
children: s("workshopLab.operations.addParam")
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.outputs") }),
|
|
552
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.outputsHint") }),
|
|
553
|
+
o.outputs.map((m, x) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
554
|
+
/* @__PURE__ */ e.jsx(
|
|
555
|
+
I,
|
|
556
|
+
{
|
|
557
|
+
size: "small",
|
|
558
|
+
className: n.fieldSelect,
|
|
559
|
+
"aria-label": s("workshopLab.models.outputName"),
|
|
560
|
+
placeholder: s("workshopLab.models.outputName"),
|
|
561
|
+
value: m.name,
|
|
562
|
+
onChange: (y) => S("outputs", x, { name: y.target.value.trim() })
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ e.jsx(
|
|
566
|
+
I,
|
|
567
|
+
{
|
|
568
|
+
size: "small",
|
|
569
|
+
className: n.fieldSelect,
|
|
570
|
+
"aria-label": s("workshopLab.models.outputLabel"),
|
|
571
|
+
placeholder: s("workshopLab.models.outputLabel"),
|
|
572
|
+
value: m.label,
|
|
573
|
+
onChange: (y) => S("outputs", x, { label: y.target.value })
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
/* @__PURE__ */ e.jsx(
|
|
577
|
+
F,
|
|
578
|
+
{
|
|
579
|
+
size: "small",
|
|
580
|
+
"aria-label": s("workshopLab.models.outputType"),
|
|
581
|
+
value: m.type,
|
|
582
|
+
options: Te.map((y) => ({
|
|
583
|
+
value: y,
|
|
584
|
+
label: s(`workshopLab.operations.types.${y}`)
|
|
585
|
+
})),
|
|
586
|
+
onChange: (y) => S("outputs", x, { type: y })
|
|
587
|
+
}
|
|
588
|
+
),
|
|
589
|
+
/* @__PURE__ */ e.jsx(
|
|
590
|
+
$,
|
|
591
|
+
{
|
|
592
|
+
size: "small",
|
|
593
|
+
type: "text",
|
|
594
|
+
danger: !0,
|
|
595
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
596
|
+
"aria-label": s("workshopLab.config.removeItem"),
|
|
597
|
+
disabled: o.outputs.length <= 1,
|
|
598
|
+
onClick: () => N("outputs", x)
|
|
599
|
+
}
|
|
600
|
+
)
|
|
601
|
+
] }, x)),
|
|
602
|
+
/* @__PURE__ */ e.jsx(
|
|
603
|
+
$,
|
|
604
|
+
{
|
|
605
|
+
size: "small",
|
|
606
|
+
disabled: o.outputs.length >= Sa,
|
|
607
|
+
onClick: () => h({
|
|
608
|
+
outputs: [
|
|
609
|
+
...o.outputs,
|
|
610
|
+
{
|
|
611
|
+
name: we(
|
|
612
|
+
o.outputs.map((m) => m.name),
|
|
613
|
+
"result"
|
|
614
|
+
),
|
|
615
|
+
label: "",
|
|
616
|
+
type: "number"
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
}),
|
|
620
|
+
children: s("workshopLab.models.addOutput")
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.measures") }),
|
|
624
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.measuresHint") }),
|
|
625
|
+
o.measures.map((m, x) => /* @__PURE__ */ e.jsxs("div", { className: n.computedItem, children: [
|
|
626
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
627
|
+
/* @__PURE__ */ e.jsx(
|
|
628
|
+
I,
|
|
629
|
+
{
|
|
630
|
+
size: "small",
|
|
631
|
+
className: n.fieldSelect,
|
|
632
|
+
"aria-label": s("workshopLab.models.measureLabel"),
|
|
633
|
+
placeholder: s("workshopLab.models.measureLabel"),
|
|
634
|
+
value: m.label,
|
|
635
|
+
onChange: (y) => S("measures", x, { label: y.target.value })
|
|
636
|
+
}
|
|
637
|
+
),
|
|
638
|
+
/* @__PURE__ */ e.jsx(
|
|
639
|
+
F,
|
|
640
|
+
{
|
|
641
|
+
size: "small",
|
|
642
|
+
"aria-label": s("workshopLab.models.measureAggregate"),
|
|
643
|
+
value: m.aggregate,
|
|
644
|
+
options: Ca.map((y) => ({
|
|
645
|
+
value: y,
|
|
646
|
+
label: s(`workshopLab.models.aggregates.${y}`)
|
|
647
|
+
})),
|
|
648
|
+
onChange: (y) => S("measures", x, {
|
|
649
|
+
aggregate: y,
|
|
650
|
+
...ze.has(y) ? {} : { valueField: void 0 }
|
|
651
|
+
})
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
ze.has(m.aggregate) && /* @__PURE__ */ e.jsx(
|
|
655
|
+
F,
|
|
656
|
+
{
|
|
657
|
+
size: "small",
|
|
658
|
+
className: n.fieldSelect,
|
|
659
|
+
"aria-label": s("workshopLab.models.valueField"),
|
|
660
|
+
placeholder: s("workshopLab.models.valueField"),
|
|
661
|
+
value: m.valueField,
|
|
662
|
+
options: g.filter((y) => y.type === "number").map((y) => ({ value: y.name, label: y.label || y.name })),
|
|
663
|
+
onChange: (y) => S("measures", x, { valueField: y })
|
|
664
|
+
}
|
|
665
|
+
),
|
|
666
|
+
/* @__PURE__ */ e.jsx(
|
|
667
|
+
$,
|
|
668
|
+
{
|
|
669
|
+
size: "small",
|
|
670
|
+
type: "text",
|
|
671
|
+
danger: !0,
|
|
672
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
673
|
+
"aria-label": s("workshopLab.config.removeItem"),
|
|
674
|
+
onClick: () => N("measures", x)
|
|
675
|
+
}
|
|
676
|
+
)
|
|
677
|
+
] }),
|
|
678
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.measureWhen") }),
|
|
679
|
+
/* @__PURE__ */ e.jsx(
|
|
680
|
+
K,
|
|
681
|
+
{
|
|
682
|
+
value: m.when,
|
|
683
|
+
onChange: (y) => S("measures", x, { when: y.length ? y : void 0 }),
|
|
684
|
+
fields: g,
|
|
685
|
+
source: i
|
|
686
|
+
}
|
|
687
|
+
)
|
|
688
|
+
] }, x)),
|
|
689
|
+
/* @__PURE__ */ e.jsx(
|
|
690
|
+
$,
|
|
691
|
+
{
|
|
692
|
+
size: "small",
|
|
693
|
+
disabled: o.measures.length >= Ta,
|
|
694
|
+
onClick: () => h({ measures: [...o.measures, { label: "", aggregate: "count" }] }),
|
|
695
|
+
children: s("workshopLab.models.addMeasure")
|
|
696
|
+
}
|
|
697
|
+
),
|
|
698
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.models.action") }),
|
|
699
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.models.actionHint") }),
|
|
700
|
+
/* @__PURE__ */ e.jsx(
|
|
701
|
+
F,
|
|
702
|
+
{
|
|
703
|
+
size: "small",
|
|
704
|
+
allowClear: !0,
|
|
705
|
+
"aria-label": s("workshopLab.models.action"),
|
|
706
|
+
placeholder: s("workshopLab.models.noAction"),
|
|
707
|
+
value: o.action?.id,
|
|
708
|
+
options: b.map((m) => ({ value: m.id, label: m.name })),
|
|
709
|
+
onChange: (m) => {
|
|
710
|
+
const x = { ...o };
|
|
711
|
+
m ? x.action = { id: m, params: {} } : delete x.action, d(x);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
),
|
|
715
|
+
T?.inputs.map((m) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
716
|
+
/* @__PURE__ */ e.jsx("span", { children: m.name }),
|
|
717
|
+
/* @__PURE__ */ e.jsx(
|
|
718
|
+
F,
|
|
719
|
+
{
|
|
720
|
+
size: "small",
|
|
721
|
+
className: n.fieldSelect,
|
|
722
|
+
allowClear: !0,
|
|
723
|
+
"aria-label": m.name,
|
|
724
|
+
placeholder: s("workshopLab.models.sameName"),
|
|
725
|
+
value: L(o.action?.params?.[m.name]),
|
|
726
|
+
options: [
|
|
727
|
+
...o.outputs.map((x) => ({
|
|
728
|
+
value: `output:${x.name}`,
|
|
729
|
+
label: s("workshopLab.models.fromOutput", { name: x.label || x.name })
|
|
730
|
+
})),
|
|
731
|
+
...o.params.map((x) => ({
|
|
732
|
+
value: `param:${x.name}`,
|
|
733
|
+
label: s("workshopLab.operations.fromParam", { name: x.label || x.name })
|
|
734
|
+
})),
|
|
735
|
+
...j.map((x) => ({
|
|
736
|
+
value: `field:${x.name}`,
|
|
737
|
+
label: s("workshopLab.models.fromField", { name: x.label })
|
|
738
|
+
})),
|
|
739
|
+
{ value: "const", label: s("workshopLab.operations.fromConst") }
|
|
740
|
+
],
|
|
741
|
+
onChange: (x) => {
|
|
742
|
+
if (!x) return O(m.name, void 0);
|
|
743
|
+
if (x === "const") return O(m.name, { from: "const", value: "" });
|
|
744
|
+
const [y, R] = x.split(/:(.*)/s);
|
|
745
|
+
O(m.name, { from: y, name: R });
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
),
|
|
749
|
+
o.action?.params?.[m.name]?.from === "const" && /* @__PURE__ */ e.jsx(
|
|
750
|
+
I,
|
|
751
|
+
{
|
|
752
|
+
size: "small",
|
|
753
|
+
className: n.fieldSelect,
|
|
754
|
+
"aria-label": `${m.name} ${s("workshopLab.operations.fromConst")}`,
|
|
755
|
+
value: String(
|
|
756
|
+
o.action.params[m.name].value ?? ""
|
|
757
|
+
),
|
|
758
|
+
onChange: (x) => O(m.name, { from: "const", value: x.target.value })
|
|
759
|
+
}
|
|
760
|
+
)
|
|
761
|
+
] }, m.name)),
|
|
762
|
+
C.length > 0 && v.label && /* @__PURE__ */ e.jsx(
|
|
763
|
+
re,
|
|
764
|
+
{
|
|
765
|
+
type: "warning",
|
|
766
|
+
showIcon: !0,
|
|
767
|
+
message: C.slice(0, 3).map((m) => m.replace(/^model\[\d+\]\.?/, "")).join(";")
|
|
768
|
+
}
|
|
769
|
+
)
|
|
770
|
+
] })
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
function $e() {
|
|
775
|
+
const { t: a } = _();
|
|
776
|
+
return /* @__PURE__ */ e.jsx(xe, { title: a("workshopLab.generated.tagHint"), children: /* @__PURE__ */ e.jsx(J, { color: "blue", children: a("workshopLab.generated.tag") }) });
|
|
777
|
+
}
|
|
778
|
+
function Ue(a, i, t) {
|
|
779
|
+
if (!a?.length) return t("workshopLab.dataView.allObjects");
|
|
780
|
+
const w = (p) => p === Q ? t("workshopLab.computed.asOf") : i.find((k) => k.name === p)?.label ?? p;
|
|
781
|
+
return a.map((p) => {
|
|
782
|
+
const k = p.ref !== void 0 ? w(p.ref) : p.values ? p.values.map((c) => Le(p.field, c)).join("、") : p.value !== void 0 ? Le(p.field, String(p.value)) : "";
|
|
783
|
+
return [w(p.field), t(`workshopLab.computed.ops.${p.op}`), k].filter(Boolean).join(" ");
|
|
784
|
+
}).join(",");
|
|
785
|
+
}
|
|
786
|
+
const Oe = { sources: /* @__PURE__ */ new Map(), columns: /* @__PURE__ */ new Map() };
|
|
787
|
+
function os(a, i, t) {
|
|
788
|
+
const w = a.scheduleModel;
|
|
789
|
+
if (!w) return Oe;
|
|
790
|
+
let p;
|
|
791
|
+
try {
|
|
792
|
+
p = ja(w, i);
|
|
793
|
+
} catch {
|
|
794
|
+
return Oe;
|
|
795
|
+
}
|
|
796
|
+
const k = new Map(a.sources.map((b) => [b.id, b])), c = (b) => i.objectTypes[b]?.name ?? b, s = (b) => k.get(b)?.label ?? p.sources.find((T) => T.id === b)?.label ?? b, o = (b) => b ? [
|
|
797
|
+
...i.objectTypes[b.objectType]?.properties ?? [],
|
|
798
|
+
...(b.computed ?? []).map(te)
|
|
799
|
+
] : [], d = (b, T) => o(b).find((v) => v.name === T)?.label ?? T, h = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), u = w.result === "record" ? w.record : void 0, l = k.get(U.task(0)), j = u?.active?.length ? U.activePlan : U.plan;
|
|
800
|
+
for (const b of p.sources) {
|
|
801
|
+
const T = k.get(b.id);
|
|
802
|
+
if (!T) continue;
|
|
803
|
+
const v = c(b.objectType), C = /^scheduleTask(\d+)$/.exec(b.id);
|
|
804
|
+
let S;
|
|
805
|
+
C && u ? S = t("workshopLab.generated.sources.demand", { type: v }) : C ? S = t("workshopLab.generated.sources.task", { type: v }) : b.id === U.unplanned ? S = t(
|
|
806
|
+
l?.computed?.some((O) => O.name === ke.open) ? "workshopLab.generated.sources.unplannedOpen" : "workshopLab.generated.sources.unplanned",
|
|
807
|
+
{ type: v }
|
|
808
|
+
) : b.id === U.plan ? S = t("workshopLab.generated.sources.plan", { type: v }) : b.id === U.activePlan ? S = t("workshopLab.generated.sources.activePlan", {
|
|
809
|
+
plan: s(U.plan),
|
|
810
|
+
when: Ue(T.from?.where, o(k.get(U.plan)), t)
|
|
811
|
+
}) : b.id === U.resource ? S = t("workshopLab.generated.sources.resource", { type: v }) : b.id.startsWith("scheduleCalendar") && (S = t("workshopLab.generated.sources.calendar", { type: v })), S && h.set(b.id, S);
|
|
812
|
+
const N = /* @__PURE__ */ new Map();
|
|
813
|
+
for (const O of b.computed ?? []) {
|
|
814
|
+
const L = T.computed?.find((x) => x.name === O.name);
|
|
815
|
+
if (!L) continue;
|
|
816
|
+
const m = g(L, T);
|
|
817
|
+
m && N.set(L.name, m);
|
|
818
|
+
}
|
|
819
|
+
N.size > 0 && r.set(b.id, N);
|
|
820
|
+
}
|
|
821
|
+
return { sources: h, columns: r };
|
|
822
|
+
function g(b, T) {
|
|
823
|
+
if (b.kind === "matched") {
|
|
824
|
+
const v = b.pairs.map((S) => d(T, S.field)).join(t("workshopLab.scheduleModel.wizard.listJoiner")), C = s(
|
|
825
|
+
b.source === U.plan && b.where?.length ? j : b.source
|
|
826
|
+
);
|
|
827
|
+
return b.field ? t("workshopLab.generated.columns.matchedValue", { label: b.label, pairs: v, from: C }) : t("workshopLab.generated.columns.matchedCount", { label: b.label, pairs: v, from: C });
|
|
828
|
+
}
|
|
829
|
+
if (b.kind === "classify" && b.name === ke.scheduled) {
|
|
830
|
+
const v = b.cases.map((C) => C.value);
|
|
831
|
+
return t("workshopLab.generated.columns.planned", {
|
|
832
|
+
label: b.label,
|
|
833
|
+
yes: v[0] ?? "",
|
|
834
|
+
unknown: v[1] ?? "",
|
|
835
|
+
no: b.otherwise.value
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
if (b.kind === "classify" && b.name === ke.open)
|
|
839
|
+
return t("workshopLab.generated.columns.open", {
|
|
840
|
+
label: b.label,
|
|
841
|
+
done: b.cases[0]?.value ?? "",
|
|
842
|
+
open: b.otherwise.value
|
|
843
|
+
});
|
|
844
|
+
if (b.kind === "related" && b.name === U.groupName)
|
|
845
|
+
return t("workshopLab.generated.columns.groupName", { label: b.label });
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
const Fe = {
|
|
849
|
+
date: ["shiftDays", "fromAsOf", "set"],
|
|
850
|
+
number: ["add", "set"],
|
|
851
|
+
text: ["set"]
|
|
852
|
+
}, ls = (a, i) => a !== "set" ? ["number"] : i === "date" ? ["date", "datetime"] : [i === "number" ? "number" : "text"], Ge = (a, i) => {
|
|
853
|
+
for (let t = 1; ; t++) if (!a.includes(`${i}${t}`)) return `${i}${t}`;
|
|
854
|
+
};
|
|
855
|
+
function ts({
|
|
856
|
+
source: a,
|
|
857
|
+
network: i,
|
|
858
|
+
save: t,
|
|
859
|
+
adding: w = !1,
|
|
860
|
+
onClose: p
|
|
861
|
+
}) {
|
|
862
|
+
const { t: k } = _(), c = a.operations ?? [], s = () => ({
|
|
863
|
+
index: c.length,
|
|
864
|
+
operation: {
|
|
865
|
+
id: Ge(
|
|
866
|
+
c.map((j) => j.id),
|
|
867
|
+
"op"
|
|
868
|
+
),
|
|
869
|
+
label: "",
|
|
870
|
+
params: [{ name: "p1", label: "", type: "number" }],
|
|
871
|
+
effects: []
|
|
872
|
+
}
|
|
873
|
+
}), [o, d] = A.useState(
|
|
874
|
+
() => w && c.length === 0 ? s() : null
|
|
875
|
+
), h = i.objectTypes[a.objectType]?.properties ?? [], r = ge(a, i), u = (j) => r.find((g) => g.name === j)?.label ?? j, l = (j) => t({ ...a, operations: j.length > 0 ? j : void 0 });
|
|
876
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedItem, children: [
|
|
877
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedHead, children: [
|
|
878
|
+
/* @__PURE__ */ e.jsx("b", { children: k("workshopLab.operations.title") }),
|
|
879
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
880
|
+
/* @__PURE__ */ e.jsx(
|
|
881
|
+
$,
|
|
882
|
+
{
|
|
883
|
+
size: "small",
|
|
884
|
+
icon: /* @__PURE__ */ e.jsx(ne, {}),
|
|
885
|
+
disabled: c.length >= za,
|
|
886
|
+
onClick: () => d(s()),
|
|
887
|
+
children: k("workshopLab.operations.add")
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
] }),
|
|
891
|
+
c.map((j, g) => {
|
|
892
|
+
const b = j.action ? be(i, j.action.id) : void 0;
|
|
893
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.operationItem, children: [
|
|
894
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
895
|
+
/* @__PURE__ */ e.jsx("b", { children: j.label }),
|
|
896
|
+
" ",
|
|
897
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: k("workshopLab.operations.on", {
|
|
898
|
+
conditions: Ue(j.when, r, k)
|
|
899
|
+
}) })
|
|
900
|
+
] }),
|
|
901
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: j.effects.map(
|
|
902
|
+
(T) => k(`workshopLab.operations.effectText.${T.kind}`, {
|
|
903
|
+
field: u(T.field),
|
|
904
|
+
param: j.params.find((v) => v.name === T.param)?.label ?? T.param
|
|
905
|
+
})
|
|
906
|
+
).join(";") }),
|
|
907
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: b ? k("workshopLab.operations.actionText", { name: b.name }) : k("workshopLab.operations.noAction") }),
|
|
908
|
+
/* @__PURE__ */ e.jsxs(P, { size: 4, children: [
|
|
909
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: () => d({ index: g, operation: j }), children: k("workshopLab.computed.edit") }),
|
|
910
|
+
/* @__PURE__ */ e.jsx(
|
|
911
|
+
ee,
|
|
912
|
+
{
|
|
913
|
+
title: k("workshopLab.operations.removeConfirm", { name: j.label }),
|
|
914
|
+
onConfirm: () => l(c.filter((T, v) => v !== g)),
|
|
915
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: k("workshopLab.computed.remove") })
|
|
916
|
+
}
|
|
917
|
+
)
|
|
918
|
+
] })
|
|
919
|
+
] }, j.id);
|
|
920
|
+
}),
|
|
921
|
+
o && /* @__PURE__ */ e.jsx(
|
|
922
|
+
ns,
|
|
923
|
+
{
|
|
924
|
+
initial: o.operation,
|
|
925
|
+
source: a,
|
|
926
|
+
network: i,
|
|
927
|
+
properties: h,
|
|
928
|
+
others: c.filter((j, g) => g !== o.index),
|
|
929
|
+
onCancel: () => {
|
|
930
|
+
d(null), c.length === 0 && p?.();
|
|
931
|
+
},
|
|
932
|
+
onSave: (j) => {
|
|
933
|
+
const g = [...c];
|
|
934
|
+
g[o.index] = j, l(g) && d(null);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
)
|
|
938
|
+
] });
|
|
939
|
+
}
|
|
940
|
+
function ns({
|
|
941
|
+
initial: a,
|
|
942
|
+
source: i,
|
|
943
|
+
network: t,
|
|
944
|
+
properties: w,
|
|
945
|
+
others: p,
|
|
946
|
+
onCancel: k,
|
|
947
|
+
onSave: c
|
|
948
|
+
}) {
|
|
949
|
+
const { t: s } = _(), [o, d] = A.useState(a), h = (L) => d({ ...o, ...L }), r = ge(i, t), u = (L) => w.find((m) => m.name === L)?.type, l = (t.actionTypes ?? []).filter(
|
|
950
|
+
(L) => L.objectType === i.objectType
|
|
951
|
+
), j = o.action ? be(t, o.action.id) : void 0, g = t.objectTypes[i.objectType]?.primaryKeys ?? [], b = w.filter(
|
|
952
|
+
(L) => L.name !== i.key && !g.includes(L.name)
|
|
953
|
+
), T = {
|
|
954
|
+
...o,
|
|
955
|
+
label: o.label.trim(),
|
|
956
|
+
...o.when?.length ? { when: o.when } : { when: void 0 }
|
|
957
|
+
};
|
|
958
|
+
T.when || delete T.when;
|
|
959
|
+
const v = T.label ? $a([...p, T], i, t, "operation").filter(
|
|
960
|
+
(L) => L.startsWith(`operation[${p.length}]`)
|
|
961
|
+
) : [s("workshopLab.operations.needLabel")], C = (L, m) => h({
|
|
962
|
+
params: o.params.map((x, y) => y === L ? { ...x, ...m } : x)
|
|
963
|
+
}), S = (L, m) => h({
|
|
964
|
+
effects: o.effects.map((x, y) => y === L ? { ...x, ...m } : x)
|
|
965
|
+
}), N = (L, m) => {
|
|
966
|
+
if (!o.action) return;
|
|
967
|
+
const x = { ...o.action.params };
|
|
968
|
+
m ? x[L] = m : delete x[L], h({ action: { ...o.action, params: x } });
|
|
969
|
+
}, O = (L) => L ? L.from === "const" ? "const" : `${L.from}:${L.name}` : void 0;
|
|
970
|
+
return /* @__PURE__ */ e.jsx(
|
|
971
|
+
ae,
|
|
972
|
+
{
|
|
973
|
+
open: !0,
|
|
974
|
+
width: 720,
|
|
975
|
+
title: a.label ? s("workshopLab.operations.editTitle", { name: a.label }) : s("workshopLab.operations.newTitle"),
|
|
976
|
+
okText: s("workshopLab.computed.save"),
|
|
977
|
+
okButtonProps: { disabled: v.length > 0 },
|
|
978
|
+
onOk: () => c(T),
|
|
979
|
+
onCancel: k,
|
|
980
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
981
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.operations.hint") }),
|
|
982
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
983
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.operations.label") }),
|
|
984
|
+
/* @__PURE__ */ e.jsx(
|
|
985
|
+
I,
|
|
986
|
+
{
|
|
987
|
+
size: "small",
|
|
988
|
+
className: n.fieldSelect,
|
|
989
|
+
maxLength: 30,
|
|
990
|
+
placeholder: s("workshopLab.operations.labelHint"),
|
|
991
|
+
value: o.label,
|
|
992
|
+
onChange: (L) => h({ label: L.target.value })
|
|
993
|
+
}
|
|
994
|
+
)
|
|
995
|
+
] }),
|
|
996
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.operations.when") }),
|
|
997
|
+
/* @__PURE__ */ e.jsx(
|
|
998
|
+
K,
|
|
999
|
+
{
|
|
1000
|
+
value: o.when,
|
|
1001
|
+
onChange: (L) => h({ when: L }),
|
|
1002
|
+
fields: r,
|
|
1003
|
+
source: i
|
|
1004
|
+
}
|
|
1005
|
+
),
|
|
1006
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.operations.params") }),
|
|
1007
|
+
o.params.map((L, m) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1008
|
+
/* @__PURE__ */ e.jsx(
|
|
1009
|
+
I,
|
|
1010
|
+
{
|
|
1011
|
+
size: "small",
|
|
1012
|
+
className: n.fieldSelect,
|
|
1013
|
+
placeholder: s("workshopLab.operations.paramLabel"),
|
|
1014
|
+
value: L.label,
|
|
1015
|
+
onChange: (x) => C(m, { label: x.target.value })
|
|
1016
|
+
}
|
|
1017
|
+
),
|
|
1018
|
+
/* @__PURE__ */ e.jsx(
|
|
1019
|
+
F,
|
|
1020
|
+
{
|
|
1021
|
+
size: "small",
|
|
1022
|
+
value: L.type,
|
|
1023
|
+
options: Oa.map((x) => ({
|
|
1024
|
+
value: x,
|
|
1025
|
+
label: s(`workshopLab.operations.types.${x}`)
|
|
1026
|
+
})),
|
|
1027
|
+
onChange: (x) => C(m, { type: x })
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
L.type === "number" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
1031
|
+
/* @__PURE__ */ e.jsx(
|
|
1032
|
+
G,
|
|
1033
|
+
{
|
|
1034
|
+
size: "small",
|
|
1035
|
+
placeholder: s("workshopLab.operations.min"),
|
|
1036
|
+
value: L.min ?? null,
|
|
1037
|
+
onChange: (x) => C(m, { min: x ?? void 0 })
|
|
1038
|
+
}
|
|
1039
|
+
),
|
|
1040
|
+
/* @__PURE__ */ e.jsx(
|
|
1041
|
+
G,
|
|
1042
|
+
{
|
|
1043
|
+
size: "small",
|
|
1044
|
+
placeholder: s("workshopLab.operations.max"),
|
|
1045
|
+
value: L.max ?? null,
|
|
1046
|
+
onChange: (x) => C(m, { max: x ?? void 0 })
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
/* @__PURE__ */ e.jsx(
|
|
1050
|
+
G,
|
|
1051
|
+
{
|
|
1052
|
+
size: "small",
|
|
1053
|
+
placeholder: s("workshopLab.operations.default"),
|
|
1054
|
+
value: typeof L.default == "number" ? L.default : null,
|
|
1055
|
+
onChange: (x) => C(m, { default: x ?? void 0 })
|
|
1056
|
+
}
|
|
1057
|
+
)
|
|
1058
|
+
] }),
|
|
1059
|
+
/* @__PURE__ */ e.jsx(
|
|
1060
|
+
$,
|
|
1061
|
+
{
|
|
1062
|
+
size: "small",
|
|
1063
|
+
type: "text",
|
|
1064
|
+
danger: !0,
|
|
1065
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
1066
|
+
"aria-label": s("workshopLab.config.removeItem"),
|
|
1067
|
+
disabled: o.params.length <= 1,
|
|
1068
|
+
onClick: () => h({
|
|
1069
|
+
params: o.params.filter((x, y) => y !== m),
|
|
1070
|
+
effects: o.effects.filter((x) => x.param !== L.name)
|
|
1071
|
+
})
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] }, L.name)),
|
|
1075
|
+
/* @__PURE__ */ e.jsx(
|
|
1076
|
+
$,
|
|
1077
|
+
{
|
|
1078
|
+
size: "small",
|
|
1079
|
+
disabled: o.params.length >= Be,
|
|
1080
|
+
onClick: () => h({
|
|
1081
|
+
params: [
|
|
1082
|
+
...o.params,
|
|
1083
|
+
{
|
|
1084
|
+
name: Ge(
|
|
1085
|
+
o.params.map((L) => L.name),
|
|
1086
|
+
"p"
|
|
1087
|
+
),
|
|
1088
|
+
label: "",
|
|
1089
|
+
type: "number"
|
|
1090
|
+
}
|
|
1091
|
+
]
|
|
1092
|
+
}),
|
|
1093
|
+
children: s("workshopLab.operations.addParam")
|
|
1094
|
+
}
|
|
1095
|
+
),
|
|
1096
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.operations.effects") }),
|
|
1097
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.operations.effectsHint") }),
|
|
1098
|
+
o.effects.map((L, m) => {
|
|
1099
|
+
const x = u(L.field) ?? "text", y = Fe[x] ?? ["set"], R = ls(L.kind, x);
|
|
1100
|
+
return /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1101
|
+
/* @__PURE__ */ e.jsx(
|
|
1102
|
+
F,
|
|
1103
|
+
{
|
|
1104
|
+
size: "small",
|
|
1105
|
+
className: n.fieldSelect,
|
|
1106
|
+
value: L.field || void 0,
|
|
1107
|
+
placeholder: s("workshopLab.operations.field"),
|
|
1108
|
+
options: b.map((M) => ({
|
|
1109
|
+
value: M.name,
|
|
1110
|
+
label: M.label
|
|
1111
|
+
})),
|
|
1112
|
+
onChange: (M) => {
|
|
1113
|
+
const B = (Fe[u(M) ?? "text"] ?? ["set"])[0];
|
|
1114
|
+
S(m, { field: M, kind: B });
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
),
|
|
1118
|
+
/* @__PURE__ */ e.jsx(
|
|
1119
|
+
F,
|
|
1120
|
+
{
|
|
1121
|
+
size: "small",
|
|
1122
|
+
value: L.kind,
|
|
1123
|
+
options: y.map((M) => ({
|
|
1124
|
+
value: M,
|
|
1125
|
+
label: s(`workshopLab.operations.kinds.${M}`)
|
|
1126
|
+
})),
|
|
1127
|
+
onChange: (M) => S(m, { kind: M })
|
|
1128
|
+
}
|
|
1129
|
+
),
|
|
1130
|
+
/* @__PURE__ */ e.jsx(
|
|
1131
|
+
F,
|
|
1132
|
+
{
|
|
1133
|
+
size: "small",
|
|
1134
|
+
className: n.fieldSelect,
|
|
1135
|
+
value: L.param || void 0,
|
|
1136
|
+
placeholder: s("workshopLab.operations.param"),
|
|
1137
|
+
options: o.params.filter((M) => R.includes(M.type)).map((M) => ({ value: M.name, label: M.label || M.name })),
|
|
1138
|
+
onChange: (M) => S(m, { param: M })
|
|
1139
|
+
}
|
|
1140
|
+
),
|
|
1141
|
+
/* @__PURE__ */ e.jsx(
|
|
1142
|
+
$,
|
|
1143
|
+
{
|
|
1144
|
+
size: "small",
|
|
1145
|
+
type: "text",
|
|
1146
|
+
danger: !0,
|
|
1147
|
+
icon: /* @__PURE__ */ e.jsx(Y, {}),
|
|
1148
|
+
"aria-label": s("workshopLab.config.removeItem"),
|
|
1149
|
+
onClick: () => h({ effects: o.effects.filter((M, B) => B !== m) })
|
|
1150
|
+
}
|
|
1151
|
+
)
|
|
1152
|
+
] }, m);
|
|
1153
|
+
}),
|
|
1154
|
+
/* @__PURE__ */ e.jsx(
|
|
1155
|
+
$,
|
|
1156
|
+
{
|
|
1157
|
+
size: "small",
|
|
1158
|
+
disabled: o.effects.length >= Fa,
|
|
1159
|
+
onClick: () => h({
|
|
1160
|
+
effects: [...o.effects, { field: "", kind: "set", param: "" }]
|
|
1161
|
+
}),
|
|
1162
|
+
children: s("workshopLab.operations.addEffect")
|
|
1163
|
+
}
|
|
1164
|
+
),
|
|
1165
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.operations.action") }),
|
|
1166
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.operations.actionHint") }),
|
|
1167
|
+
/* @__PURE__ */ e.jsx(
|
|
1168
|
+
F,
|
|
1169
|
+
{
|
|
1170
|
+
size: "small",
|
|
1171
|
+
allowClear: !0,
|
|
1172
|
+
placeholder: s("workshopLab.operations.noAction"),
|
|
1173
|
+
value: o.action?.id,
|
|
1174
|
+
options: l.map((L) => ({ value: L.id, label: L.name })),
|
|
1175
|
+
onChange: (L) => {
|
|
1176
|
+
const m = { ...o };
|
|
1177
|
+
L ? m.action = { id: L, params: {} } : delete m.action, d(m);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
),
|
|
1181
|
+
j?.inputs.map((L) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1182
|
+
/* @__PURE__ */ e.jsx("span", { children: L.name }),
|
|
1183
|
+
/* @__PURE__ */ e.jsx(
|
|
1184
|
+
F,
|
|
1185
|
+
{
|
|
1186
|
+
size: "small",
|
|
1187
|
+
className: n.fieldSelect,
|
|
1188
|
+
allowClear: !0,
|
|
1189
|
+
placeholder: s("workshopLab.operations.sameName"),
|
|
1190
|
+
value: O(o.action?.params[L.name]),
|
|
1191
|
+
options: [
|
|
1192
|
+
...o.params.map((m) => ({
|
|
1193
|
+
value: `param:${m.name}`,
|
|
1194
|
+
label: s("workshopLab.operations.fromParam", { name: m.label || m.name })
|
|
1195
|
+
})),
|
|
1196
|
+
...w.map((m) => ({
|
|
1197
|
+
value: `field:${m.name}`,
|
|
1198
|
+
label: s("workshopLab.operations.fromField", { name: m.label })
|
|
1199
|
+
})),
|
|
1200
|
+
{ value: "const", label: s("workshopLab.operations.fromConst") }
|
|
1201
|
+
],
|
|
1202
|
+
onChange: (m) => {
|
|
1203
|
+
if (!m) return N(L.name, void 0);
|
|
1204
|
+
if (m === "const") return N(L.name, { from: "const", value: "" });
|
|
1205
|
+
const [x, y] = m.split(/:(.*)/s);
|
|
1206
|
+
N(L.name, { from: x, name: y });
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
),
|
|
1210
|
+
o.action?.params[L.name]?.from === "const" && /* @__PURE__ */ e.jsx(
|
|
1211
|
+
I,
|
|
1212
|
+
{
|
|
1213
|
+
size: "small",
|
|
1214
|
+
className: n.fieldSelect,
|
|
1215
|
+
value: String(
|
|
1216
|
+
o.action.params[L.name].value ?? ""
|
|
1217
|
+
),
|
|
1218
|
+
onChange: (m) => N(L.name, { from: "const", value: m.target.value })
|
|
1219
|
+
}
|
|
1220
|
+
)
|
|
1221
|
+
] }, L.name)),
|
|
1222
|
+
v.length > 0 && T.label && /* @__PURE__ */ e.jsx(
|
|
1223
|
+
re,
|
|
1224
|
+
{
|
|
1225
|
+
type: "warning",
|
|
1226
|
+
showIcon: !0,
|
|
1227
|
+
message: v.slice(0, 3).map((L) => L.replace(/^operation\[\d+\]\.?/, "")).join(";")
|
|
1228
|
+
}
|
|
1229
|
+
)
|
|
1230
|
+
] })
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
const Pe = (a, i) => {
|
|
1235
|
+
for (let t = 1; ; t++) if (!a.includes(`${i}${t}`)) return `${i}${t}`;
|
|
1236
|
+
};
|
|
1237
|
+
function rs({ source: a, network: i, sources: t, states: w, run: p, save: k, onClose: c }) {
|
|
1238
|
+
const { t: s } = _(), o = a.follows ?? [], d = a.relatedTo ?? [], [h, r] = A.useState(null), [u, l] = A.useState(null), j = Pa(t), g = (N, O) => i.objectTypes[N]?.properties.find((L) => L.name === O)?.label ?? O, b = (N) => t.find((O) => O.id === N), T = (N, O) => {
|
|
1239
|
+
const L = b(N);
|
|
1240
|
+
return L ? _e(i, L.objectType, O) : O.join(" → ");
|
|
1241
|
+
}, v = (N) => k({ ...a, follows: N.length > 0 ? N : void 0 }), C = (N) => k({ ...a, relatedTo: N.length > 0 ? N : void 0 }), S = o.length + d.length === 0;
|
|
1242
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedItem, children: [
|
|
1243
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedHead, children: [
|
|
1244
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.links.title") }),
|
|
1245
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
1246
|
+
S && c && /* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: c, children: s("workshopLab.blocks.cancel") }),
|
|
1247
|
+
/* @__PURE__ */ e.jsx(
|
|
1248
|
+
$,
|
|
1249
|
+
{
|
|
1250
|
+
size: "small",
|
|
1251
|
+
disabled: o.length >= Ea,
|
|
1252
|
+
onClick: () => r({
|
|
1253
|
+
index: o.length,
|
|
1254
|
+
rule: {
|
|
1255
|
+
id: Pe(
|
|
1256
|
+
o.map((N) => N.id),
|
|
1257
|
+
"follow"
|
|
1258
|
+
),
|
|
1259
|
+
field: "",
|
|
1260
|
+
from: "",
|
|
1261
|
+
path: [],
|
|
1262
|
+
fromField: "",
|
|
1263
|
+
gapDays: 0
|
|
1264
|
+
}
|
|
1265
|
+
}),
|
|
1266
|
+
children: s("workshopLab.links.addRule")
|
|
1267
|
+
}
|
|
1268
|
+
),
|
|
1269
|
+
/* @__PURE__ */ e.jsx(
|
|
1270
|
+
$,
|
|
1271
|
+
{
|
|
1272
|
+
size: "small",
|
|
1273
|
+
disabled: d.length >= Ma,
|
|
1274
|
+
onClick: () => l({
|
|
1275
|
+
index: d.length,
|
|
1276
|
+
link: {
|
|
1277
|
+
id: Pe(
|
|
1278
|
+
d.map((N) => N.id),
|
|
1279
|
+
"related"
|
|
1280
|
+
),
|
|
1281
|
+
from: "",
|
|
1282
|
+
path: []
|
|
1283
|
+
}
|
|
1284
|
+
}),
|
|
1285
|
+
children: s("workshopLab.links.addRelated")
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
] }),
|
|
1289
|
+
o.map((N, O) => {
|
|
1290
|
+
const L = b(N.from);
|
|
1291
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.operationItem, children: [
|
|
1292
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
1293
|
+
s(
|
|
1294
|
+
N.gapMinutes ? "workshopLab.links.ruleTextMinutes" : "workshopLab.links.ruleText",
|
|
1295
|
+
{
|
|
1296
|
+
field: g(a.objectType, N.field),
|
|
1297
|
+
from: L?.label ?? N.from,
|
|
1298
|
+
fromField: L ? g(L.objectType, N.fromField) : N.fromField,
|
|
1299
|
+
gap: N.gapDays,
|
|
1300
|
+
minutes: N.gapMinutes
|
|
1301
|
+
}
|
|
1302
|
+
),
|
|
1303
|
+
N.keepDuration && s("workshopLab.links.keepText", {
|
|
1304
|
+
field: g(a.objectType, N.keepDuration)
|
|
1305
|
+
})
|
|
1306
|
+
] }),
|
|
1307
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.links.via", { path: T(N.from, N.path) }) }),
|
|
1308
|
+
/* @__PURE__ */ e.jsx(
|
|
1309
|
+
ps,
|
|
1310
|
+
{
|
|
1311
|
+
rule: N,
|
|
1312
|
+
source: a,
|
|
1313
|
+
network: i,
|
|
1314
|
+
sources: t,
|
|
1315
|
+
states: w,
|
|
1316
|
+
run: p
|
|
1317
|
+
},
|
|
1318
|
+
JSON.stringify(N)
|
|
1319
|
+
),
|
|
1320
|
+
/* @__PURE__ */ e.jsxs(P, { size: 4, children: [
|
|
1321
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: () => r({ index: O, rule: N }), children: s("workshopLab.computed.edit") }),
|
|
1322
|
+
/* @__PURE__ */ e.jsx(
|
|
1323
|
+
ee,
|
|
1324
|
+
{
|
|
1325
|
+
title: s("workshopLab.links.removeConfirm"),
|
|
1326
|
+
onConfirm: () => v(o.filter((m, x) => x !== O)),
|
|
1327
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: s("workshopLab.computed.remove") })
|
|
1328
|
+
}
|
|
1329
|
+
)
|
|
1330
|
+
] })
|
|
1331
|
+
] }, N.id);
|
|
1332
|
+
}),
|
|
1333
|
+
d.map((N, O) => /* @__PURE__ */ e.jsxs("div", { className: n.operationItem, children: [
|
|
1334
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.links.relatedText", {
|
|
1335
|
+
from: b(N.from)?.label ?? N.from
|
|
1336
|
+
}) }),
|
|
1337
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.links.via", { path: T(N.from, N.path) }) }),
|
|
1338
|
+
/* @__PURE__ */ e.jsxs(P, { size: 4, children: [
|
|
1339
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: () => l({ index: O, link: N }), children: s("workshopLab.computed.edit") }),
|
|
1340
|
+
/* @__PURE__ */ e.jsx(
|
|
1341
|
+
ee,
|
|
1342
|
+
{
|
|
1343
|
+
title: s("workshopLab.links.removeConfirm"),
|
|
1344
|
+
onConfirm: () => C(d.filter((L, m) => m !== O)),
|
|
1345
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: s("workshopLab.computed.remove") })
|
|
1346
|
+
}
|
|
1347
|
+
)
|
|
1348
|
+
] })
|
|
1349
|
+
] }, N.id)),
|
|
1350
|
+
h && /* @__PURE__ */ e.jsx(
|
|
1351
|
+
is,
|
|
1352
|
+
{
|
|
1353
|
+
initial: h.rule,
|
|
1354
|
+
source: a,
|
|
1355
|
+
network: i,
|
|
1356
|
+
starts: j,
|
|
1357
|
+
sources: t,
|
|
1358
|
+
others: o.filter((N, O) => O !== h.index),
|
|
1359
|
+
onCancel: () => r(null),
|
|
1360
|
+
onSave: (N) => {
|
|
1361
|
+
const O = [...o];
|
|
1362
|
+
O[h.index] = N, v(O) && r(null);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
),
|
|
1366
|
+
u && /* @__PURE__ */ e.jsx(
|
|
1367
|
+
cs,
|
|
1368
|
+
{
|
|
1369
|
+
initial: u.link,
|
|
1370
|
+
source: a,
|
|
1371
|
+
network: i,
|
|
1372
|
+
starts: j,
|
|
1373
|
+
sources: t,
|
|
1374
|
+
others: d.filter((N, O) => O !== u.index),
|
|
1375
|
+
onCancel: () => l(null),
|
|
1376
|
+
onSave: (N) => {
|
|
1377
|
+
const O = [...d];
|
|
1378
|
+
O[u.index] = N, C(O) && l(null);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
)
|
|
1382
|
+
] });
|
|
1383
|
+
}
|
|
1384
|
+
function Xe({
|
|
1385
|
+
from: a,
|
|
1386
|
+
path: i,
|
|
1387
|
+
source: t,
|
|
1388
|
+
network: w,
|
|
1389
|
+
starts: p,
|
|
1390
|
+
onChange: k
|
|
1391
|
+
}) {
|
|
1392
|
+
const { t: c } = _(), s = p.find((h) => h.id === a), o = s ? ye(w, s.objectType, t.objectType, Ce).filter(
|
|
1393
|
+
(h) => h.length > 0
|
|
1394
|
+
) : [], d = (h) => `${_e(w, s?.objectType ?? "", h)}(${(me(w, s?.objectType ?? "", h) ?? []).map(
|
|
1395
|
+
(r, u) => oa(h[u]).reversed ? c("workshopLab.config.pathReversed", { name: r.relation.name }) : r.relation.name
|
|
1396
|
+
).join("、")})`;
|
|
1397
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
1398
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1399
|
+
/* @__PURE__ */ e.jsx("span", { children: c("workshopLab.links.from") }),
|
|
1400
|
+
/* @__PURE__ */ e.jsx(
|
|
1401
|
+
F,
|
|
1402
|
+
{
|
|
1403
|
+
size: "small",
|
|
1404
|
+
className: n.fieldSelect,
|
|
1405
|
+
"aria-label": c("workshopLab.links.from"),
|
|
1406
|
+
value: a || void 0,
|
|
1407
|
+
placeholder: c("workshopLab.links.fromHint"),
|
|
1408
|
+
options: p.map((h) => ({ value: h.id, label: h.label })),
|
|
1409
|
+
onChange: (h) => {
|
|
1410
|
+
const r = p.find((l) => l.id === h), u = r ? ye(w, r.objectType, t.objectType, Ce).find(
|
|
1411
|
+
(l) => l.length > 0
|
|
1412
|
+
) : void 0;
|
|
1413
|
+
k({ from: h, path: u ?? [] });
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
)
|
|
1417
|
+
] }),
|
|
1418
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1419
|
+
/* @__PURE__ */ e.jsx("span", { children: c("workshopLab.links.path") }),
|
|
1420
|
+
/* @__PURE__ */ e.jsx(
|
|
1421
|
+
F,
|
|
1422
|
+
{
|
|
1423
|
+
size: "small",
|
|
1424
|
+
className: n.pathSelect,
|
|
1425
|
+
"aria-label": c("workshopLab.links.path"),
|
|
1426
|
+
value: i.length > 0 ? i.join(">") : void 0,
|
|
1427
|
+
placeholder: s && o.length === 0 ? c("workshopLab.links.noPath") : c("workshopLab.links.path"),
|
|
1428
|
+
disabled: !s || o.length === 0,
|
|
1429
|
+
options: o.map((h) => ({ value: h.join(">"), label: d(h) })),
|
|
1430
|
+
onChange: (h) => k({ path: h.split(">") })
|
|
1431
|
+
}
|
|
1432
|
+
)
|
|
1433
|
+
] })
|
|
1434
|
+
] });
|
|
1435
|
+
}
|
|
1436
|
+
const We = (a) => a.slice(0, 3).map((i) => i.replace(/^item\[\d+\]\.?/, "")).join(";");
|
|
1437
|
+
function is({
|
|
1438
|
+
initial: a,
|
|
1439
|
+
source: i,
|
|
1440
|
+
network: t,
|
|
1441
|
+
starts: w,
|
|
1442
|
+
sources: p,
|
|
1443
|
+
others: k,
|
|
1444
|
+
onCancel: c,
|
|
1445
|
+
onSave: s
|
|
1446
|
+
}) {
|
|
1447
|
+
const { t: o } = _(), [d, h] = A.useState(a), r = (b) => h({ ...d, ...b }), u = t.objectTypes[i.objectType]?.primaryKeys ?? [], l = (b) => (t.objectTypes[b]?.properties ?? []).filter((T) => T.type === "date"), j = w.find((b) => b.id === d.from), g = Aa([...k, d], i, p, t, "item").filter(
|
|
1448
|
+
(b) => b.startsWith(`item[${k.length}]`)
|
|
1449
|
+
);
|
|
1450
|
+
return /* @__PURE__ */ e.jsx(
|
|
1451
|
+
ae,
|
|
1452
|
+
{
|
|
1453
|
+
open: !0,
|
|
1454
|
+
width: 640,
|
|
1455
|
+
title: o("workshopLab.links.ruleTitle"),
|
|
1456
|
+
okText: o("workshopLab.computed.save"),
|
|
1457
|
+
okButtonProps: { disabled: g.length > 0 },
|
|
1458
|
+
onOk: () => s(d),
|
|
1459
|
+
onCancel: c,
|
|
1460
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
1461
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: o("workshopLab.links.ruleHint") }),
|
|
1462
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1463
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.field") }),
|
|
1464
|
+
/* @__PURE__ */ e.jsx(
|
|
1465
|
+
F,
|
|
1466
|
+
{
|
|
1467
|
+
size: "small",
|
|
1468
|
+
className: n.fieldSelect,
|
|
1469
|
+
"aria-label": o("workshopLab.links.fieldLabel"),
|
|
1470
|
+
value: d.field || void 0,
|
|
1471
|
+
options: l(i.objectType).filter((b) => b.name !== i.key && !u.includes(b.name)).map((b) => ({ value: b.name, label: b.label })),
|
|
1472
|
+
onChange: (b) => r(b === d.keepDuration ? { field: b, keepDuration: void 0 } : { field: b })
|
|
1473
|
+
}
|
|
1474
|
+
),
|
|
1475
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.notBefore") })
|
|
1476
|
+
] }),
|
|
1477
|
+
/* @__PURE__ */ e.jsx(
|
|
1478
|
+
Xe,
|
|
1479
|
+
{
|
|
1480
|
+
from: d.from,
|
|
1481
|
+
path: d.path,
|
|
1482
|
+
source: i,
|
|
1483
|
+
network: t,
|
|
1484
|
+
starts: w,
|
|
1485
|
+
onChange: (b) => r(
|
|
1486
|
+
b.from !== void 0 && b.from !== d.from ? { ...b, fromField: "" } : b
|
|
1487
|
+
)
|
|
1488
|
+
}
|
|
1489
|
+
),
|
|
1490
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1491
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.fromField") }),
|
|
1492
|
+
/* @__PURE__ */ e.jsx(
|
|
1493
|
+
F,
|
|
1494
|
+
{
|
|
1495
|
+
size: "small",
|
|
1496
|
+
className: n.fieldSelect,
|
|
1497
|
+
"aria-label": o("workshopLab.links.fromFieldLabel"),
|
|
1498
|
+
value: d.fromField || void 0,
|
|
1499
|
+
disabled: !j,
|
|
1500
|
+
options: (j ? l(j.objectType) : []).map((b) => ({
|
|
1501
|
+
value: b.name,
|
|
1502
|
+
label: b.label
|
|
1503
|
+
})),
|
|
1504
|
+
onChange: (b) => r({ fromField: b })
|
|
1505
|
+
}
|
|
1506
|
+
),
|
|
1507
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.plus") }),
|
|
1508
|
+
/* @__PURE__ */ e.jsx(
|
|
1509
|
+
G,
|
|
1510
|
+
{
|
|
1511
|
+
size: "small",
|
|
1512
|
+
"aria-label": o("workshopLab.links.gapLabel"),
|
|
1513
|
+
min: -Ne,
|
|
1514
|
+
max: Ne,
|
|
1515
|
+
precision: 0,
|
|
1516
|
+
value: d.gapDays,
|
|
1517
|
+
onChange: (b) => r({ gapDays: b ?? 0 })
|
|
1518
|
+
}
|
|
1519
|
+
),
|
|
1520
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.days") }),
|
|
1521
|
+
/* @__PURE__ */ e.jsx(
|
|
1522
|
+
G,
|
|
1523
|
+
{
|
|
1524
|
+
size: "small",
|
|
1525
|
+
"aria-label": o("workshopLab.links.gapMinutesLabel"),
|
|
1526
|
+
min: -Se,
|
|
1527
|
+
max: Se,
|
|
1528
|
+
precision: 0,
|
|
1529
|
+
value: d.gapMinutes ?? 0,
|
|
1530
|
+
onChange: (b) => r({ gapMinutes: b || void 0 })
|
|
1531
|
+
}
|
|
1532
|
+
),
|
|
1533
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.minutes") })
|
|
1534
|
+
] }),
|
|
1535
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
1536
|
+
/* @__PURE__ */ e.jsx("span", { children: o("workshopLab.links.keepDuration") }),
|
|
1537
|
+
/* @__PURE__ */ e.jsx(
|
|
1538
|
+
F,
|
|
1539
|
+
{
|
|
1540
|
+
size: "small",
|
|
1541
|
+
allowClear: !0,
|
|
1542
|
+
className: n.fieldSelect,
|
|
1543
|
+
"aria-label": o("workshopLab.links.keepDurationLabel"),
|
|
1544
|
+
placeholder: o("workshopLab.links.keepNone"),
|
|
1545
|
+
value: d.keepDuration,
|
|
1546
|
+
disabled: !d.field,
|
|
1547
|
+
options: l(i.objectType).filter((b) => b.name !== d.field && !u.includes(b.name)).map((b) => ({ value: b.name, label: b.label })),
|
|
1548
|
+
onChange: (b) => r({ keepDuration: b })
|
|
1549
|
+
}
|
|
1550
|
+
)
|
|
1551
|
+
] }),
|
|
1552
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: o("workshopLab.links.minutesHint") }),
|
|
1553
|
+
g.length > 0 && d.field && d.from && d.fromField && /* @__PURE__ */ e.jsx(re, { type: "warning", showIcon: !0, message: We(g) })
|
|
1554
|
+
] })
|
|
1555
|
+
}
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
function cs({
|
|
1559
|
+
initial: a,
|
|
1560
|
+
source: i,
|
|
1561
|
+
network: t,
|
|
1562
|
+
starts: w,
|
|
1563
|
+
sources: p,
|
|
1564
|
+
others: k,
|
|
1565
|
+
onCancel: c,
|
|
1566
|
+
onSave: s
|
|
1567
|
+
}) {
|
|
1568
|
+
const { t: o } = _(), [d, h] = A.useState(a), r = _a([...k, d], i, p, t, "item").filter(
|
|
1569
|
+
(u) => u.startsWith(`item[${k.length}]`)
|
|
1570
|
+
);
|
|
1571
|
+
return /* @__PURE__ */ e.jsx(
|
|
1572
|
+
ae,
|
|
1573
|
+
{
|
|
1574
|
+
open: !0,
|
|
1575
|
+
width: 640,
|
|
1576
|
+
title: o("workshopLab.links.relatedTitle"),
|
|
1577
|
+
okText: o("workshopLab.computed.save"),
|
|
1578
|
+
okButtonProps: { disabled: r.length > 0 },
|
|
1579
|
+
onOk: () => s(d),
|
|
1580
|
+
onCancel: c,
|
|
1581
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
1582
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: o("workshopLab.links.relatedHint") }),
|
|
1583
|
+
/* @__PURE__ */ e.jsx(
|
|
1584
|
+
Xe,
|
|
1585
|
+
{
|
|
1586
|
+
from: d.from,
|
|
1587
|
+
path: d.path,
|
|
1588
|
+
source: i,
|
|
1589
|
+
network: t,
|
|
1590
|
+
starts: w,
|
|
1591
|
+
onChange: (u) => h({ ...d, ...u })
|
|
1592
|
+
}
|
|
1593
|
+
),
|
|
1594
|
+
r.length > 0 && d.from && /* @__PURE__ */ e.jsx(re, { type: "warning", showIcon: !0, message: We(r) })
|
|
1595
|
+
] })
|
|
1596
|
+
}
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
function ps({
|
|
1600
|
+
rule: a,
|
|
1601
|
+
source: i,
|
|
1602
|
+
network: t,
|
|
1603
|
+
sources: w,
|
|
1604
|
+
states: p,
|
|
1605
|
+
run: k
|
|
1606
|
+
}) {
|
|
1607
|
+
const { t: c } = _(), [s, o] = A.useState(null), d = w.find((j) => j.id === a.from), h = d ? p[d.id] : void 0, r = p[i.id], u = h?.status === "ready" && r?.status === "ready", l = async () => {
|
|
1608
|
+
if (!(!d || h?.status !== "ready" || r?.status !== "ready")) {
|
|
1609
|
+
o({ status: "running" });
|
|
1610
|
+
try {
|
|
1611
|
+
const j = me(t, d.objectType, a.path) ?? [], g = await Ia(
|
|
1612
|
+
k,
|
|
1613
|
+
t,
|
|
1614
|
+
d,
|
|
1615
|
+
i,
|
|
1616
|
+
j,
|
|
1617
|
+
h.rows.map((b) => b.$key)
|
|
1618
|
+
);
|
|
1619
|
+
o({ status: "done", ...wa(a, r.rows, h.rows, g) });
|
|
1620
|
+
} catch {
|
|
1621
|
+
o({ status: "error" });
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
return /* @__PURE__ */ e.jsxs("span", { className: n.muted, children: [
|
|
1626
|
+
/* @__PURE__ */ e.jsx(
|
|
1627
|
+
$,
|
|
1628
|
+
{
|
|
1629
|
+
size: "small",
|
|
1630
|
+
type: "link",
|
|
1631
|
+
disabled: !u,
|
|
1632
|
+
loading: s?.status === "running",
|
|
1633
|
+
onClick: () => {
|
|
1634
|
+
l();
|
|
1635
|
+
},
|
|
1636
|
+
children: c("workshopLab.links.check")
|
|
1637
|
+
}
|
|
1638
|
+
),
|
|
1639
|
+
s?.status === "error" && c("workshopLab.links.checkFailed"),
|
|
1640
|
+
s?.status === "done" && (s.covered === 0 ? c("workshopLab.links.checkNone") : c("workshopLab.links.checkResult", {
|
|
1641
|
+
covered: s.covered,
|
|
1642
|
+
holds: s.holds,
|
|
1643
|
+
diffs: s.diffs.map(([j, g]) => c("workshopLab.links.checkDiff", { days: j, count: g })).join("、")
|
|
1644
|
+
}))
|
|
1645
|
+
] });
|
|
1646
|
+
}
|
|
1647
|
+
const Ke = /^[A-Za-z][A-Za-z0-9_]*$/, ds = 4;
|
|
1648
|
+
function Je(a, i) {
|
|
1649
|
+
const w = (a.match(/[A-Za-z][A-Za-z0-9]*|[0-9]+/g) ?? []).map(
|
|
1650
|
+
(k, c) => c === 0 ? k.charAt(0).toLowerCase() + k.slice(1) : k.charAt(0).toUpperCase() + k.slice(1)
|
|
1651
|
+
).join(""), p = Ke.test(w) ? w.slice(0, 40) : "column";
|
|
1652
|
+
if (!i.includes(p) && p !== "column") return p;
|
|
1653
|
+
for (let k = p === "column" ? 1 : 2; ; k += 1)
|
|
1654
|
+
if (!i.includes(`${p}${k}`)) return `${p}${k}`;
|
|
1655
|
+
}
|
|
1656
|
+
const ms = 3, us = 6;
|
|
1657
|
+
function hs() {
|
|
1658
|
+
const { message: a } = na();
|
|
1659
|
+
return (i) => (i.length > 0 && a.error(i.slice(0, 3).join(";")), i.length === 0);
|
|
1660
|
+
}
|
|
1661
|
+
function bs(a, i, t) {
|
|
1662
|
+
const w = hs(), p = A.useMemo(() => Ve(i, a.sources), [i, a.sources]), k = A.useMemo(() => {
|
|
1663
|
+
const s = a.variables.find((d) => d.kind === "asOf"), o = s ? He(a.variables, {})[s.name] : void 0;
|
|
1664
|
+
return typeof o == "string" ? o : la();
|
|
1665
|
+
}, [a.variables]);
|
|
1666
|
+
return { network: p, asOf: k, save: (s, o) => {
|
|
1667
|
+
const d = {
|
|
1668
|
+
...a,
|
|
1669
|
+
sources: a.sources.map((h) => h.id === s.id ? s : h)
|
|
1670
|
+
};
|
|
1671
|
+
return w(
|
|
1672
|
+
t(o ? Ha(d, s.id, o.field, o.renames) : d)
|
|
1673
|
+
);
|
|
1674
|
+
} };
|
|
1675
|
+
}
|
|
1676
|
+
function ks({ app: a, kn: i, sources: t, run: w, chatModel: p = () => null, apply: k }) {
|
|
1677
|
+
const { t: c } = _(), { network: s, asOf: o, save: d } = bs(a, i, k), h = A.useMemo(() => He(a.variables, {}), [a.variables]), r = ga(a.sources, i, w, h, t), u = A.useMemo(() => os(a, i, c), [a, i, c]);
|
|
1678
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.library, children: [
|
|
1679
|
+
/* @__PURE__ */ e.jsx("header", { className: n.listHeader, children: /* @__PURE__ */ e.jsxs("div", { children: [
|
|
1680
|
+
/* @__PURE__ */ e.jsx("h3", { className: n.sectionTitle, children: c("workshopLab.computed.title") }),
|
|
1681
|
+
/* @__PURE__ */ e.jsx("p", { className: n.muted, children: c("workshopLab.computed.hint", { date: o }) })
|
|
1682
|
+
] }) }),
|
|
1683
|
+
a.sources.filter((l) => !l.from).map((l) => /* @__PURE__ */ e.jsx(
|
|
1684
|
+
xs,
|
|
1685
|
+
{
|
|
1686
|
+
source: l,
|
|
1687
|
+
properties: s.objectTypes[l.objectType]?.properties ?? [],
|
|
1688
|
+
state: r[l.id],
|
|
1689
|
+
states: r,
|
|
1690
|
+
sources: a.sources,
|
|
1691
|
+
asOf: o,
|
|
1692
|
+
usage: Ra(a, l.id),
|
|
1693
|
+
tools: { network: s, run: w, chatModel: p },
|
|
1694
|
+
generatedSource: u.sources.get(l.id),
|
|
1695
|
+
generatedColumns: u.columns.get(l.id),
|
|
1696
|
+
scenarioParams: a.scenarioParams ?? gs,
|
|
1697
|
+
save: d
|
|
1698
|
+
},
|
|
1699
|
+
l.id
|
|
1700
|
+
))
|
|
1701
|
+
] });
|
|
1702
|
+
}
|
|
1703
|
+
const js = ["operations", "links", "models"], ws = ["operations"], gs = [];
|
|
1704
|
+
function xs({
|
|
1705
|
+
source: a,
|
|
1706
|
+
properties: i,
|
|
1707
|
+
state: t,
|
|
1708
|
+
states: w,
|
|
1709
|
+
sources: p,
|
|
1710
|
+
asOf: k,
|
|
1711
|
+
usage: c,
|
|
1712
|
+
tools: s,
|
|
1713
|
+
scenarioParams: o,
|
|
1714
|
+
generatedSource: d,
|
|
1715
|
+
generatedColumns: h,
|
|
1716
|
+
save: r
|
|
1717
|
+
}) {
|
|
1718
|
+
const { t: u } = _(), l = a.computed ?? [], [j, g] = A.useState(null), [b, T] = A.useState(!1), [v, C] = A.useState([]), S = t?.status === "ready" ? t.rows : null, N = A.useMemo(
|
|
1719
|
+
() => S ? ue(S, a, k) : null,
|
|
1720
|
+
[S, a, k]
|
|
1721
|
+
), O = (z) => [
|
|
1722
|
+
...i,
|
|
1723
|
+
...fe(a.progress),
|
|
1724
|
+
...l.filter((f, E) => E !== z).map(te)
|
|
1725
|
+
], L = (z, f, E) => {
|
|
1726
|
+
const D = [...l];
|
|
1727
|
+
return f === null ? D.splice(z, 1) : D[z] = f, r({ ...a, computed: D.length > 0 ? D : void 0 }, E);
|
|
1728
|
+
}, m = !a.cypher && !a.events, x = {
|
|
1729
|
+
formats: Object.keys(a.formats ?? {}).length > 0,
|
|
1730
|
+
operations: (a.operations ?? []).length > 0,
|
|
1731
|
+
links: (a.follows ?? []).length + (a.relatedTo ?? []).length > 0,
|
|
1732
|
+
models: (a.models ?? []).length > 0
|
|
1733
|
+
}, y = (z) => x[z] || v.includes(z), R = (z) => C((f) => f.filter((E) => E !== z)), M = (z) => (f) => {
|
|
1734
|
+
const E = r(f);
|
|
1735
|
+
return E && R(z), E;
|
|
1736
|
+
}, B = (z) => ({
|
|
1737
|
+
key: z,
|
|
1738
|
+
label: /* @__PURE__ */ e.jsxs("span", { className: n.addItem, children: [
|
|
1739
|
+
/* @__PURE__ */ e.jsx("span", { children: u(`workshopLab.blocks.items.${z}.label`) }),
|
|
1740
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: u(`workshopLab.blocks.items.${z}.description`) })
|
|
1741
|
+
] })
|
|
1742
|
+
}), X = !!a.model, ie = X ? ws : js, ce = [
|
|
1743
|
+
...a.progress || X ? [] : [B("progress")],
|
|
1744
|
+
...X ? [] : [B("computed")],
|
|
1745
|
+
...y("formats") ? [] : [B("formats")]
|
|
1746
|
+
], se = m ? ie.filter((z) => !y(z)).map(B) : [], pe = [
|
|
1747
|
+
{
|
|
1748
|
+
type: "group",
|
|
1749
|
+
key: "columns",
|
|
1750
|
+
label: u("workshopLab.blocks.groups.columns"),
|
|
1751
|
+
children: ce
|
|
1752
|
+
},
|
|
1753
|
+
...se.length > 0 ? [
|
|
1754
|
+
{
|
|
1755
|
+
type: "group",
|
|
1756
|
+
key: "scenario",
|
|
1757
|
+
label: u("workshopLab.blocks.groups.scenario"),
|
|
1758
|
+
children: se
|
|
1759
|
+
}
|
|
1760
|
+
] : []
|
|
1761
|
+
], W = (z) => {
|
|
1762
|
+
z === "progress" ? T(!0) : z === "computed" ? g({
|
|
1763
|
+
index: l.length,
|
|
1764
|
+
field: { name: "", label: "", kind: "classify", cases: [], otherwise: { value: "" } }
|
|
1765
|
+
}) : C((f) => [...f, z]);
|
|
1766
|
+
}, Z = !!a.progress || l.length > 0 || y("formats"), oe = m && ie.some(y);
|
|
1767
|
+
return /* @__PURE__ */ e.jsxs("section", { className: n.entry, "aria-label": a.label, children: [
|
|
1768
|
+
/* @__PURE__ */ e.jsxs("header", { className: n.entryHeader, children: [
|
|
1769
|
+
/* @__PURE__ */ e.jsx("b", { children: a.label }),
|
|
1770
|
+
d !== void 0 && /* @__PURE__ */ e.jsx($e, {}),
|
|
1771
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
1772
|
+
/* @__PURE__ */ e.jsx(Da, { trigger: ["click"], menu: { items: pe, onClick: ({ key: z }) => W(z) }, children: /* @__PURE__ */ e.jsxs($, { size: "small", type: "primary", icon: /* @__PURE__ */ e.jsx(ne, {}), children: [
|
|
1773
|
+
u("workshopLab.blocks.add"),
|
|
1774
|
+
" ",
|
|
1775
|
+
/* @__PURE__ */ e.jsx(ta, {})
|
|
1776
|
+
] }) })
|
|
1777
|
+
] }),
|
|
1778
|
+
d && /* @__PURE__ */ e.jsx("span", { className: n.muted, children: d }),
|
|
1779
|
+
!Z && !oe && /* @__PURE__ */ e.jsx("span", { className: n.muted, children: u("workshopLab.blocks.empty") }),
|
|
1780
|
+
Z && /* @__PURE__ */ e.jsx("span", { className: n.blockGroup, children: u("workshopLab.blocks.groups.columns") }),
|
|
1781
|
+
/* @__PURE__ */ e.jsx(
|
|
1782
|
+
Ps,
|
|
1783
|
+
{
|
|
1784
|
+
source: a,
|
|
1785
|
+
properties: i,
|
|
1786
|
+
rows: N,
|
|
1787
|
+
usage: c,
|
|
1788
|
+
onEdit: () => T(!0),
|
|
1789
|
+
onRemove: () => r({ ...a, progress: void 0 })
|
|
1790
|
+
}
|
|
1791
|
+
),
|
|
1792
|
+
l.length > 0 && /* @__PURE__ */ e.jsx("ul", { className: n.computedList, children: l.map((z, f) => {
|
|
1793
|
+
const E = c.get(z.name) ?? [];
|
|
1794
|
+
return /* @__PURE__ */ e.jsxs("li", { className: n.computedItem, children: [
|
|
1795
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedHead, children: [
|
|
1796
|
+
/* @__PURE__ */ e.jsx("b", { children: z.label }),
|
|
1797
|
+
/* @__PURE__ */ e.jsx(J, { children: u(`workshopLab.computed.kinds.${z.kind}`) }),
|
|
1798
|
+
h?.has(z.name) && /* @__PURE__ */ e.jsx($e, {}),
|
|
1799
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
1800
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: () => g({ index: f, field: z }), children: u("workshopLab.computed.edit") }),
|
|
1801
|
+
E.length > 0 ? /* @__PURE__ */ e.jsx(
|
|
1802
|
+
xe,
|
|
1803
|
+
{
|
|
1804
|
+
title: u("workshopLab.computed.removeBlocked", {
|
|
1805
|
+
names: E.map((D) => D.label).join("、")
|
|
1806
|
+
}),
|
|
1807
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, disabled: !0, children: u("workshopLab.computed.remove") })
|
|
1808
|
+
}
|
|
1809
|
+
) : /* @__PURE__ */ e.jsx(
|
|
1810
|
+
ee,
|
|
1811
|
+
{
|
|
1812
|
+
title: u("workshopLab.computed.removeConfirm", { name: z.label }),
|
|
1813
|
+
onConfirm: () => L(f, null),
|
|
1814
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: u("workshopLab.computed.remove") })
|
|
1815
|
+
}
|
|
1816
|
+
)
|
|
1817
|
+
] }),
|
|
1818
|
+
h?.has(z.name) && /* @__PURE__ */ e.jsx("span", { className: n.muted, children: h.get(z.name) }),
|
|
1819
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: Ls(z, O(f), u, s.network, a.objectType, p) }),
|
|
1820
|
+
/* @__PURE__ */ e.jsx(qe, { field: z, rows: N }),
|
|
1821
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: E.length > 0 ? u("workshopLab.computed.usedBy", {
|
|
1822
|
+
names: E.map((D) => D.label).join("、")
|
|
1823
|
+
}) : u("workshopLab.computed.unused") })
|
|
1824
|
+
] }, z.name);
|
|
1825
|
+
}) }),
|
|
1826
|
+
y("formats") && /* @__PURE__ */ e.jsx(
|
|
1827
|
+
es,
|
|
1828
|
+
{
|
|
1829
|
+
source: a,
|
|
1830
|
+
fields: O(l.length),
|
|
1831
|
+
save: M("formats"),
|
|
1832
|
+
onClose: () => R("formats")
|
|
1833
|
+
}
|
|
1834
|
+
),
|
|
1835
|
+
oe && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
1836
|
+
/* @__PURE__ */ e.jsx("span", { className: n.blockGroup, children: u("workshopLab.blocks.groups.scenario") }),
|
|
1837
|
+
y("operations") && /* @__PURE__ */ e.jsx(
|
|
1838
|
+
ts,
|
|
1839
|
+
{
|
|
1840
|
+
source: a,
|
|
1841
|
+
network: s.network,
|
|
1842
|
+
save: M("operations"),
|
|
1843
|
+
adding: v.includes("operations"),
|
|
1844
|
+
onClose: () => R("operations")
|
|
1845
|
+
}
|
|
1846
|
+
),
|
|
1847
|
+
y("links") && /* @__PURE__ */ e.jsx(
|
|
1848
|
+
rs,
|
|
1849
|
+
{
|
|
1850
|
+
source: a,
|
|
1851
|
+
network: s.network,
|
|
1852
|
+
sources: p,
|
|
1853
|
+
states: w,
|
|
1854
|
+
run: s.run,
|
|
1855
|
+
save: M("links"),
|
|
1856
|
+
onClose: () => R("links")
|
|
1857
|
+
}
|
|
1858
|
+
),
|
|
1859
|
+
y("models") && /* @__PURE__ */ e.jsx(
|
|
1860
|
+
as,
|
|
1861
|
+
{
|
|
1862
|
+
source: a,
|
|
1863
|
+
network: s.network,
|
|
1864
|
+
scenarioParams: o,
|
|
1865
|
+
save: M("models"),
|
|
1866
|
+
adding: v.includes("models"),
|
|
1867
|
+
onClose: () => R("models")
|
|
1868
|
+
}
|
|
1869
|
+
)
|
|
1870
|
+
] }),
|
|
1871
|
+
j && /* @__PURE__ */ e.jsx(
|
|
1872
|
+
Qe,
|
|
1873
|
+
{
|
|
1874
|
+
field: j.field,
|
|
1875
|
+
isNew: j.index === l.length,
|
|
1876
|
+
fields: O(j.index),
|
|
1877
|
+
source: a,
|
|
1878
|
+
rows: S,
|
|
1879
|
+
asOf: k,
|
|
1880
|
+
tools: s,
|
|
1881
|
+
others: { sources: p, states: w },
|
|
1882
|
+
taken: O(j.index).map((z) => z.name),
|
|
1883
|
+
onCancel: () => g(null),
|
|
1884
|
+
onSave: (z) => {
|
|
1885
|
+
const f = Ba(j.field, z), E = f.size > 0 ? { field: z.name, renames: f } : void 0;
|
|
1886
|
+
L(j.index, z, E) && g(null);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
),
|
|
1890
|
+
b && /* @__PURE__ */ e.jsx(
|
|
1891
|
+
Ms,
|
|
1892
|
+
{
|
|
1893
|
+
initial: a.progress,
|
|
1894
|
+
source: a,
|
|
1895
|
+
asOf: k,
|
|
1896
|
+
properties: i,
|
|
1897
|
+
rows: S,
|
|
1898
|
+
onCancel: () => T(!1),
|
|
1899
|
+
onSave: (z) => {
|
|
1900
|
+
r({ ...a, progress: z }) && T(!1);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
)
|
|
1904
|
+
] });
|
|
1905
|
+
}
|
|
1906
|
+
function fs({
|
|
1907
|
+
source: a,
|
|
1908
|
+
spec: i,
|
|
1909
|
+
onCancel: t,
|
|
1910
|
+
onSave: w
|
|
1911
|
+
}) {
|
|
1912
|
+
return /* @__PURE__ */ e.jsx(Ze, { source: a, spec: i, onCancel: t, onSave: w });
|
|
1913
|
+
}
|
|
1914
|
+
function vs({
|
|
1915
|
+
source: a,
|
|
1916
|
+
spec: i,
|
|
1917
|
+
name: t,
|
|
1918
|
+
onCancel: w,
|
|
1919
|
+
onSave: p
|
|
1920
|
+
}) {
|
|
1921
|
+
const k = a.computed?.find((c) => c.name === t);
|
|
1922
|
+
return k ? /* @__PURE__ */ e.jsx(Ze, { source: a, spec: i, field: k, onCancel: w, onSave: p }) : null;
|
|
1923
|
+
}
|
|
1924
|
+
function Ze({
|
|
1925
|
+
source: a,
|
|
1926
|
+
spec: i,
|
|
1927
|
+
field: t,
|
|
1928
|
+
onCancel: w,
|
|
1929
|
+
onSave: p
|
|
1930
|
+
}) {
|
|
1931
|
+
const { kn: k, sources: c, run: s, values: o } = Ka(), d = va(), h = A.useMemo(() => Ve(k, i.sources), [k, i.sources]), r = c[a.id], u = [
|
|
1932
|
+
...h.objectTypes[a.objectType]?.properties ?? [],
|
|
1933
|
+
...fe(a.progress),
|
|
1934
|
+
...(a.computed ?? []).filter((l) => l.name !== t?.name).map(te)
|
|
1935
|
+
];
|
|
1936
|
+
return /* @__PURE__ */ e.jsx(
|
|
1937
|
+
Qe,
|
|
1938
|
+
{
|
|
1939
|
+
field: t ?? { name: "", label: "", kind: "classify", cases: [], otherwise: { value: "" } },
|
|
1940
|
+
isNew: !t,
|
|
1941
|
+
fields: u,
|
|
1942
|
+
source: a,
|
|
1943
|
+
rows: r?.status === "ready" ? r.rows : null,
|
|
1944
|
+
asOf: Ja(i, o),
|
|
1945
|
+
tools: { network: h, run: s, chatModel: d?.chatModel ?? (() => null) },
|
|
1946
|
+
others: { sources: i.sources, states: c },
|
|
1947
|
+
taken: u.map((l) => l.name),
|
|
1948
|
+
onCancel: w,
|
|
1949
|
+
onSave: p
|
|
1950
|
+
}
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
function Ls(a, i, t, w, p, k = []) {
|
|
1954
|
+
const c = (s) => s === Q ? t("workshopLab.computed.asOf") : i.find((o) => o.name === s)?.label ?? s;
|
|
1955
|
+
switch (a.kind) {
|
|
1956
|
+
case "classify":
|
|
1957
|
+
return [
|
|
1958
|
+
...a.cases.map(
|
|
1959
|
+
(s) => t("workshopLab.computed.caseLine", {
|
|
1960
|
+
value: s.value,
|
|
1961
|
+
when: s.when.length ? s.when.map(
|
|
1962
|
+
(o) => [
|
|
1963
|
+
c(o.field),
|
|
1964
|
+
t(`workshopLab.computed.ops.${o.op}`),
|
|
1965
|
+
o.ref !== void 0 ? c(o.ref) : o.values?.join("、") ?? String(o.value ?? "")
|
|
1966
|
+
].filter(Boolean).join(" ")
|
|
1967
|
+
).join(t("workshopLab.computed.and")) : t("workshopLab.computed.always")
|
|
1968
|
+
})
|
|
1969
|
+
),
|
|
1970
|
+
t("workshopLab.computed.otherwiseLine", { value: a.otherwise.value })
|
|
1971
|
+
].join(";");
|
|
1972
|
+
case "days":
|
|
1973
|
+
return t("workshopLab.computed.daysLine", { from: c(a.from), to: c(a.to) });
|
|
1974
|
+
case "formula":
|
|
1975
|
+
return t("workshopLab.computed.formulaLine", {
|
|
1976
|
+
expr: a.expr.replace(/[A-Za-z_][A-Za-z0-9_]*/g, (s) => c(s))
|
|
1977
|
+
});
|
|
1978
|
+
case "related": {
|
|
1979
|
+
const s = me(w, p, a.path) ?? [], o = s.length > 0 ? w.objectTypes[s[s.length - 1].to] : void 0, d = (h) => o?.properties.find((r) => r.name === h)?.label ?? h ?? "";
|
|
1980
|
+
return t("workshopLab.computed.relatedLine", {
|
|
1981
|
+
path: s.map((h) => h.relation.name).join(" → ") || "—",
|
|
1982
|
+
target: o?.name ?? "—",
|
|
1983
|
+
what: t(`workshopLab.computed.aggregates.${a.aggregate}`, {
|
|
1984
|
+
field: d(a.field)
|
|
1985
|
+
}),
|
|
1986
|
+
where: a.where?.length ? t("workshopLab.computed.relatedWhere", {
|
|
1987
|
+
when: a.where.map(
|
|
1988
|
+
(h) => [
|
|
1989
|
+
d(h.field),
|
|
1990
|
+
t(`workshopLab.computed.ops.${h.op}`),
|
|
1991
|
+
h.values?.join("、") ?? String(h.value ?? "")
|
|
1992
|
+
].filter(Boolean).join(" ")
|
|
1993
|
+
).join(t("workshopLab.computed.and"))
|
|
1994
|
+
}) : ""
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
case "region":
|
|
1998
|
+
return t("workshopLab.computed.regionLine", {
|
|
1999
|
+
from: c(a.from),
|
|
2000
|
+
scope: t(`workshopLab.basemaps.${a.scope ?? "china"}`)
|
|
2001
|
+
});
|
|
2002
|
+
case "matched": {
|
|
2003
|
+
const s = k.find((h) => h.id === a.source), o = s ? [
|
|
2004
|
+
...w.objectTypes[s.objectType]?.properties ?? [],
|
|
2005
|
+
...(s.computed ?? []).map(te)
|
|
2006
|
+
] : [], d = (h) => o.find((r) => r.name === h)?.label ?? h;
|
|
2007
|
+
return t(
|
|
2008
|
+
a.field ? "workshopLab.computed.matchedValueLine" : "workshopLab.computed.matchedCountLine",
|
|
2009
|
+
{
|
|
2010
|
+
source: s?.label ?? t("workshopLab.computed.matchedMissing"),
|
|
2011
|
+
pairs: a.pairs.map(
|
|
2012
|
+
(h) => t("workshopLab.computed.matchedPair", {
|
|
2013
|
+
own: c(h.field),
|
|
2014
|
+
other: d(h.other)
|
|
2015
|
+
})
|
|
2016
|
+
).join("、"),
|
|
2017
|
+
field: a.field ? d(a.field) : "",
|
|
2018
|
+
where: a.where?.length ? t("workshopLab.computed.relatedWhere", {
|
|
2019
|
+
when: a.where.map(
|
|
2020
|
+
(h) => [
|
|
2021
|
+
d(h.field),
|
|
2022
|
+
t(`workshopLab.computed.ops.${h.op}`),
|
|
2023
|
+
h.ref !== void 0 ? d(h.ref) : h.values?.join("、") ?? String(h.value ?? "")
|
|
2024
|
+
].filter(Boolean).join(" ")
|
|
2025
|
+
).join(t("workshopLab.computed.and"))
|
|
2026
|
+
}) : ""
|
|
2027
|
+
}
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
case "text":
|
|
2031
|
+
return t("workshopLab.computed.textLine", {
|
|
2032
|
+
template: a.template.replace(
|
|
2033
|
+
/\{([^{}]+)\}/g,
|
|
2034
|
+
(s, o) => `{${c(o.trim())}}`
|
|
2035
|
+
)
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function qe({ field: a, rows: i }) {
|
|
2040
|
+
const { t } = _();
|
|
2041
|
+
if (!i) return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: t("workshopLab.computed.notLoaded") });
|
|
2042
|
+
const w = i.map((o) => o[a.name]);
|
|
2043
|
+
if (a.kind === "classify") {
|
|
2044
|
+
const o = /* @__PURE__ */ new Map();
|
|
2045
|
+
for (const d of w) o.set(String(d), (o.get(String(d)) ?? 0) + 1);
|
|
2046
|
+
return /* @__PURE__ */ e.jsx("span", { className: n.computedPreview, children: [...a.cases, a.otherwise].map((d, h) => /* @__PURE__ */ e.jsxs(J, { color: ve(d.tone), children: [
|
|
2047
|
+
d.value,
|
|
2048
|
+
" ",
|
|
2049
|
+
o.get(d.value) ?? 0
|
|
2050
|
+
] }, h)) });
|
|
2051
|
+
}
|
|
2052
|
+
const p = w.filter((o) => o != null && o !== ""), k = a.kind === "matched" && a.field !== void 0 && a.type !== "number" || a.kind === "related" && (a.aggregate === "list" || a.aggregate === "one" && a.type !== "number");
|
|
2053
|
+
if (a.kind === "text" || k) {
|
|
2054
|
+
const o = [...new Set(p.map(String))].slice(0, 3).join("、");
|
|
2055
|
+
return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: t("workshopLab.computed.textPreview", {
|
|
2056
|
+
count: p.length,
|
|
2057
|
+
total: i.length,
|
|
2058
|
+
samples: o || "—"
|
|
2059
|
+
}) });
|
|
2060
|
+
}
|
|
2061
|
+
if (a.kind !== "region") {
|
|
2062
|
+
const o = p.map(Number), d = (h) => h.toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
2063
|
+
return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: o.length === 0 ? t("workshopLab.computed.daysNone", { total: i.length }) : t("workshopLab.computed.numberPreview", {
|
|
2064
|
+
count: o.length,
|
|
2065
|
+
total: i.length,
|
|
2066
|
+
min: d(Math.min(...o)),
|
|
2067
|
+
max: d(Math.max(...o)),
|
|
2068
|
+
unit: a.kind === "days" ? t("workshopLab.computed.dayUnit") : ""
|
|
2069
|
+
}) });
|
|
2070
|
+
}
|
|
2071
|
+
const c = /* @__PURE__ */ new Map();
|
|
2072
|
+
for (const o of p) c.set(String(o), (c.get(String(o)) ?? 0) + 1);
|
|
2073
|
+
const s = [...c].sort((o, d) => d[1] - o[1]).slice(0, ms).map(([o, d]) => `${o} ${d}`).join("、");
|
|
2074
|
+
return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: t("workshopLab.computed.regionPreview", {
|
|
2075
|
+
count: p.length,
|
|
2076
|
+
missing: i.length - p.length,
|
|
2077
|
+
top: s || "—"
|
|
2078
|
+
}) });
|
|
2079
|
+
}
|
|
2080
|
+
function ys({
|
|
2081
|
+
field: a,
|
|
2082
|
+
rows: i,
|
|
2083
|
+
fields: t
|
|
2084
|
+
}) {
|
|
2085
|
+
const { t: w } = _(), [p, k] = A.useState(null);
|
|
2086
|
+
if (!i) return null;
|
|
2087
|
+
const c = (r) => r == null || r === "", s = a.kind === "classify" ? [...a.cases, a.otherwise].map((r) => ({
|
|
2088
|
+
key: r.value,
|
|
2089
|
+
label: r.value,
|
|
2090
|
+
test: (u) => u[a.name] === r.value
|
|
2091
|
+
})) : [
|
|
2092
|
+
{
|
|
2093
|
+
key: "set",
|
|
2094
|
+
label: w("workshopLab.computed.withValue"),
|
|
2095
|
+
test: (r) => !c(r[a.name])
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
key: "empty",
|
|
2099
|
+
label: w("workshopLab.computed.withoutValue"),
|
|
2100
|
+
test: (r) => c(r[a.name])
|
|
2101
|
+
}
|
|
2102
|
+
], o = s.find((r) => r.key === p), d = [...new Set(ma(a))], h = (r) => t.find((u) => u.name === r)?.label ?? r;
|
|
2103
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedSamples, children: [
|
|
2104
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: w("workshopLab.computed.samplesHint") }),
|
|
2105
|
+
/* @__PURE__ */ e.jsx(P, { size: 4, wrap: !0, children: s.map((r) => /* @__PURE__ */ e.jsx(
|
|
2106
|
+
J.CheckableTag,
|
|
2107
|
+
{
|
|
2108
|
+
checked: p === r.key,
|
|
2109
|
+
onChange: (u) => k(u ? r.key : null),
|
|
2110
|
+
children: r.label
|
|
2111
|
+
},
|
|
2112
|
+
r.key
|
|
2113
|
+
)) }),
|
|
2114
|
+
o && /* @__PURE__ */ e.jsx(
|
|
2115
|
+
De,
|
|
2116
|
+
{
|
|
2117
|
+
size: "small",
|
|
2118
|
+
rowKey: "$key",
|
|
2119
|
+
pagination: !1,
|
|
2120
|
+
scroll: { x: "max-content" },
|
|
2121
|
+
dataSource: i.filter(o.test).slice(0, us),
|
|
2122
|
+
columns: [
|
|
2123
|
+
{ key: "$key", title: w("workshopLab.computed.object"), dataIndex: "$key" },
|
|
2124
|
+
...d.map((r) => ({
|
|
2125
|
+
key: r,
|
|
2126
|
+
title: h(r),
|
|
2127
|
+
dataIndex: r,
|
|
2128
|
+
render: (u) => c(u) ? "—" : String(u).slice(0, 24)
|
|
2129
|
+
})),
|
|
2130
|
+
{
|
|
2131
|
+
key: a.name,
|
|
2132
|
+
title: a.label || a.name,
|
|
2133
|
+
dataIndex: a.name,
|
|
2134
|
+
render: (r) => c(r) ? "—" : String(r)
|
|
2135
|
+
}
|
|
2136
|
+
]
|
|
2137
|
+
}
|
|
2138
|
+
)
|
|
2139
|
+
] });
|
|
2140
|
+
}
|
|
2141
|
+
function ve(a) {
|
|
2142
|
+
return a === "danger" ? "error" : a === "success" ? "success" : a === "warning" ? "warning" : a === "info" ? "processing" : "default";
|
|
2143
|
+
}
|
|
2144
|
+
function Qe({
|
|
2145
|
+
field: a,
|
|
2146
|
+
isNew: i,
|
|
2147
|
+
fields: t,
|
|
2148
|
+
source: w,
|
|
2149
|
+
rows: p,
|
|
2150
|
+
asOf: k,
|
|
2151
|
+
tools: c,
|
|
2152
|
+
others: s,
|
|
2153
|
+
taken: o,
|
|
2154
|
+
onCancel: d,
|
|
2155
|
+
onSave: h
|
|
2156
|
+
}) {
|
|
2157
|
+
const { t: r } = _(), { network: u } = c, [l, j] = A.useState(a), [g, b] = A.useState(!i || !!a.name), [T, v] = A.useState(!1), C = (f) => j(
|
|
2158
|
+
g || f.label === l.label ? f : { ...f, name: f.label.trim() ? Je(f.label, o) : "" }
|
|
2159
|
+
), S = t.filter((f) => f.type === "date"), N = t.filter((f) => f.type === "text"), O = [
|
|
2160
|
+
{ value: Q, label: r("workshopLab.computed.asOf") },
|
|
2161
|
+
...S.map((f) => ({ value: f.name, label: f.label }))
|
|
2162
|
+
], L = {
|
|
2163
|
+
kn: u,
|
|
2164
|
+
objectType: w.objectType,
|
|
2165
|
+
cypher: w.cypher !== void 0,
|
|
2166
|
+
progress: !!w.progress,
|
|
2167
|
+
sources: s.sources.map(
|
|
2168
|
+
(f) => f.id === w.id ? {
|
|
2169
|
+
...f,
|
|
2170
|
+
computed: [
|
|
2171
|
+
...(f.computed ?? []).filter(
|
|
2172
|
+
(E) => E.name !== a.name && E.name !== l.name
|
|
2173
|
+
),
|
|
2174
|
+
l
|
|
2175
|
+
]
|
|
2176
|
+
} : f
|
|
2177
|
+
),
|
|
2178
|
+
source: w.id
|
|
2179
|
+
}, m = l.name ? Me([l], t, "field", L) : [], x = l.kind === "related" && m.length === 0 ? l : null, y = x ? `${Va(u, w, x)}|${p?.length}` : null, R = xa(
|
|
2180
|
+
y,
|
|
2181
|
+
(f) => Wa(
|
|
2182
|
+
c.run,
|
|
2183
|
+
u,
|
|
2184
|
+
w,
|
|
2185
|
+
x,
|
|
2186
|
+
f,
|
|
2187
|
+
p?.map((E) => E.$key)
|
|
2188
|
+
)
|
|
2189
|
+
), M = A.useMemo(() => {
|
|
2190
|
+
if (!p || !l.name) return null;
|
|
2191
|
+
let f = p;
|
|
2192
|
+
if (l.kind === "matched") {
|
|
2193
|
+
const D = Cs(l, s, k);
|
|
2194
|
+
if (!D || !l.pairs.length || l.pairs.some((V) => !V.field || !V.other))
|
|
2195
|
+
return null;
|
|
2196
|
+
const H = Ua(p, D, l, k);
|
|
2197
|
+
f = p.map((V) => ({
|
|
2198
|
+
...V,
|
|
2199
|
+
[l.name]: Ga(l, H.get(V.$key))
|
|
2200
|
+
}));
|
|
2201
|
+
}
|
|
2202
|
+
if (l.kind === "related") {
|
|
2203
|
+
if (R.status !== "ready") return null;
|
|
2204
|
+
const { values: D, fallback: H } = R.value;
|
|
2205
|
+
f = p.map((V) => ({ ...V, [l.name]: D.get(V.$key) ?? H }));
|
|
2206
|
+
}
|
|
2207
|
+
const E = (w.computed ?? []).filter(
|
|
2208
|
+
(D) => D.name !== l.name && D.name !== a.name
|
|
2209
|
+
);
|
|
2210
|
+
return ue(f, { ...w, computed: [...E, l] }, k);
|
|
2211
|
+
}, [p, l, a.name, w, k, R, s]), B = l.name && (!Ke.test(l.name) || i && o.includes(l.name)) ? r("workshopLab.computed.nameError") : null, [X, ie] = A.useState(""), [ce, se] = A.useState(!1), [pe, W] = A.useState(null), Z = A.useRef(null), oe = async () => {
|
|
2212
|
+
const f = c.chatModel();
|
|
2213
|
+
if (!f) return W(r("workshopLab.computed.noModel"));
|
|
2214
|
+
const E = new AbortController();
|
|
2215
|
+
Z.current = E, se(!0), W(r("workshopLab.computed.generating"));
|
|
2216
|
+
const D = performance.now();
|
|
2217
|
+
try {
|
|
2218
|
+
const H = await Qa({
|
|
2219
|
+
model: f,
|
|
2220
|
+
scope: {
|
|
2221
|
+
sourceLabel: w.label,
|
|
2222
|
+
fields: t,
|
|
2223
|
+
samples: p ? Ya(p, t) : {},
|
|
2224
|
+
context: L
|
|
2225
|
+
},
|
|
2226
|
+
instruction: X,
|
|
2227
|
+
current: i && !l.label ? void 0 : l,
|
|
2228
|
+
taken: o,
|
|
2229
|
+
signal: E.signal,
|
|
2230
|
+
onStep: (V) => W(
|
|
2231
|
+
V.kind === "generating" ? r("workshopLab.computed.attempt", { attempt: V.attempt }) : r("workshopLab.computed.retry", { error: V.error })
|
|
2232
|
+
)
|
|
2233
|
+
});
|
|
2234
|
+
H.ok ? (C({
|
|
2235
|
+
...H.field,
|
|
2236
|
+
name: l.name || H.field.name,
|
|
2237
|
+
label: l.label || H.field.label
|
|
2238
|
+
}), W(
|
|
2239
|
+
r("workshopLab.computed.generated", {
|
|
2240
|
+
seconds: ((performance.now() - D) / 1e3).toFixed(1),
|
|
2241
|
+
explanation: H.explanation
|
|
2242
|
+
})
|
|
2243
|
+
)) : W(
|
|
2244
|
+
r("workshopLab.computed.gaveUp", { attempts: H.attempts, error: H.error })
|
|
2245
|
+
);
|
|
2246
|
+
} catch (H) {
|
|
2247
|
+
W(E.signal.aborted ? null : Re(H));
|
|
2248
|
+
} finally {
|
|
2249
|
+
se(!1);
|
|
2250
|
+
}
|
|
2251
|
+
}, z = (f) => {
|
|
2252
|
+
const E = { name: l.name, label: l.label };
|
|
2253
|
+
f === "classify" && C({ ...E, kind: f, cases: [], otherwise: { value: "" } }), f === "days" && C({ ...E, kind: f, from: S[0]?.name ?? Q, to: Q }), f === "formula" && C({ ...E, kind: f, expr: "" }), f === "related" && C({ ...E, kind: f, path: [], aggregate: "count" }), f === "region" && C({ ...E, kind: f, from: N[0]?.name ?? "" }), f === "text" && C({ ...E, kind: f, template: "" }), f === "matched" && C({ ...E, kind: f, source: "", pairs: [] });
|
|
2254
|
+
};
|
|
2255
|
+
return /* @__PURE__ */ e.jsx(
|
|
2256
|
+
ae,
|
|
2257
|
+
{
|
|
2258
|
+
open: !0,
|
|
2259
|
+
width: 800,
|
|
2260
|
+
title: r(i ? "workshopLab.computed.newTitle" : "workshopLab.computed.editTitle"),
|
|
2261
|
+
okText: r("workshopLab.computed.save"),
|
|
2262
|
+
okButtonProps: { disabled: !l.name || !l.label || !!B },
|
|
2263
|
+
onOk: () => h(l),
|
|
2264
|
+
onCancel: () => {
|
|
2265
|
+
Z.current?.abort(), d();
|
|
2266
|
+
},
|
|
2267
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
2268
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedAsk, children: [
|
|
2269
|
+
/* @__PURE__ */ e.jsx(
|
|
2270
|
+
I,
|
|
2271
|
+
{
|
|
2272
|
+
variant: "borderless",
|
|
2273
|
+
placeholder: r("workshopLab.computed.askPlaceholder"),
|
|
2274
|
+
value: X,
|
|
2275
|
+
onChange: (f) => ie(f.target.value),
|
|
2276
|
+
onPressEnter: (f) => !f.nativeEvent.isComposing && X.trim() && !ce && void oe()
|
|
2277
|
+
}
|
|
2278
|
+
),
|
|
2279
|
+
ce ? /* @__PURE__ */ e.jsx($, { size: "small", onClick: () => Z.current?.abort(), children: r("workshopLab.computed.stop") }) : /* @__PURE__ */ e.jsx(
|
|
2280
|
+
$,
|
|
2281
|
+
{
|
|
2282
|
+
size: "small",
|
|
2283
|
+
type: "primary",
|
|
2284
|
+
disabled: !X.trim(),
|
|
2285
|
+
onClick: () => {
|
|
2286
|
+
oe();
|
|
2287
|
+
},
|
|
2288
|
+
children: r(
|
|
2289
|
+
i && !l.label ? "workshopLab.computed.aiWrite" : "workshopLab.computed.aiRevise"
|
|
2290
|
+
)
|
|
2291
|
+
}
|
|
2292
|
+
)
|
|
2293
|
+
] }),
|
|
2294
|
+
pe && /* @__PURE__ */ e.jsx("span", { className: n.muted, children: pe }),
|
|
2295
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, align: "end", children: [
|
|
2296
|
+
/* @__PURE__ */ e.jsxs("label", { className: n.field, children: [
|
|
2297
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: r("workshopLab.computed.label") }),
|
|
2298
|
+
/* @__PURE__ */ e.jsx(
|
|
2299
|
+
I,
|
|
2300
|
+
{
|
|
2301
|
+
value: l.label,
|
|
2302
|
+
onChange: (f) => C({ ...l, label: f.target.value })
|
|
2303
|
+
}
|
|
2304
|
+
)
|
|
2305
|
+
] }),
|
|
2306
|
+
/* @__PURE__ */ e.jsx(
|
|
2307
|
+
$,
|
|
2308
|
+
{
|
|
2309
|
+
size: "small",
|
|
2310
|
+
type: "link",
|
|
2311
|
+
"aria-expanded": T,
|
|
2312
|
+
onClick: () => v(!T),
|
|
2313
|
+
children: r(T ? "workshopLab.computed.hideAdvanced" : "workshopLab.computed.advanced")
|
|
2314
|
+
}
|
|
2315
|
+
)
|
|
2316
|
+
] }),
|
|
2317
|
+
T && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2318
|
+
/* @__PURE__ */ e.jsxs("label", { className: n.field, children: [
|
|
2319
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: r("workshopLab.computed.name") }),
|
|
2320
|
+
/* @__PURE__ */ e.jsx(
|
|
2321
|
+
I,
|
|
2322
|
+
{
|
|
2323
|
+
disabled: !i,
|
|
2324
|
+
status: B ? "error" : void 0,
|
|
2325
|
+
value: l.name,
|
|
2326
|
+
onChange: (f) => {
|
|
2327
|
+
b(!0), j({ ...l, name: f.target.value.trim() });
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
)
|
|
2331
|
+
] }),
|
|
2332
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: r(i ? "workshopLab.computed.nameHint" : "workshopLab.computed.nameKept") })
|
|
2333
|
+
] }),
|
|
2334
|
+
B && /* @__PURE__ */ e.jsx("span", { className: n.error, children: B }),
|
|
2335
|
+
/* @__PURE__ */ e.jsx(
|
|
2336
|
+
he.Group,
|
|
2337
|
+
{
|
|
2338
|
+
optionType: "button",
|
|
2339
|
+
size: "small",
|
|
2340
|
+
value: l.kind,
|
|
2341
|
+
onChange: (f) => z(f.target.value),
|
|
2342
|
+
options: ra.map((f) => ({
|
|
2343
|
+
value: f,
|
|
2344
|
+
label: r(`workshopLab.computed.kinds.${f}`)
|
|
2345
|
+
}))
|
|
2346
|
+
}
|
|
2347
|
+
),
|
|
2348
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: r(`workshopLab.computed.kindHints.${l.kind}`) }),
|
|
2349
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: r(`workshopLab.computed.kindExamples.${l.kind}`) }),
|
|
2350
|
+
l.kind === "classify" && /* @__PURE__ */ e.jsx(Fs, { field: l, fields: t, source: w, onChange: C }),
|
|
2351
|
+
l.kind === "days" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2352
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2353
|
+
/* @__PURE__ */ e.jsx("span", { children: r("workshopLab.computed.from") }),
|
|
2354
|
+
/* @__PURE__ */ e.jsx(
|
|
2355
|
+
F,
|
|
2356
|
+
{
|
|
2357
|
+
size: "small",
|
|
2358
|
+
className: n.fieldSelect,
|
|
2359
|
+
value: l.from,
|
|
2360
|
+
options: O,
|
|
2361
|
+
onChange: (f) => C({ ...l, from: f })
|
|
2362
|
+
}
|
|
2363
|
+
),
|
|
2364
|
+
/* @__PURE__ */ e.jsx("span", { children: r("workshopLab.computed.to") }),
|
|
2365
|
+
/* @__PURE__ */ e.jsx(
|
|
2366
|
+
F,
|
|
2367
|
+
{
|
|
2368
|
+
size: "small",
|
|
2369
|
+
className: n.fieldSelect,
|
|
2370
|
+
value: l.to,
|
|
2371
|
+
options: O,
|
|
2372
|
+
onChange: (f) => C({ ...l, to: f })
|
|
2373
|
+
}
|
|
2374
|
+
)
|
|
2375
|
+
] }),
|
|
2376
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: r("workshopLab.computed.onlyWhen") }),
|
|
2377
|
+
/* @__PURE__ */ e.jsx(
|
|
2378
|
+
K,
|
|
2379
|
+
{
|
|
2380
|
+
value: l.when,
|
|
2381
|
+
fields: t,
|
|
2382
|
+
source: w,
|
|
2383
|
+
onChange: (f) => C({ ...l, when: f.length > 0 ? f : void 0 })
|
|
2384
|
+
}
|
|
2385
|
+
)
|
|
2386
|
+
] }),
|
|
2387
|
+
l.kind === "formula" && /* @__PURE__ */ e.jsx($s, { field: l, fields: t, onChange: C }),
|
|
2388
|
+
l.kind === "text" && /* @__PURE__ */ e.jsx(zs, { field: l, fields: t, onChange: C }),
|
|
2389
|
+
l.kind === "matched" && /* @__PURE__ */ e.jsx(
|
|
2390
|
+
Ts,
|
|
2391
|
+
{
|
|
2392
|
+
field: l,
|
|
2393
|
+
fields: t,
|
|
2394
|
+
source: w,
|
|
2395
|
+
others: s,
|
|
2396
|
+
kn: u,
|
|
2397
|
+
onChange: C
|
|
2398
|
+
}
|
|
2399
|
+
),
|
|
2400
|
+
l.kind === "related" && /* @__PURE__ */ e.jsx(Os, { field: l, source: w, kn: u, onChange: C }),
|
|
2401
|
+
l.kind === "region" && /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2402
|
+
/* @__PURE__ */ e.jsx("span", { children: r("workshopLab.computed.regionFrom") }),
|
|
2403
|
+
/* @__PURE__ */ e.jsx(
|
|
2404
|
+
F,
|
|
2405
|
+
{
|
|
2406
|
+
size: "small",
|
|
2407
|
+
className: n.fieldSelect,
|
|
2408
|
+
value: l.from || void 0,
|
|
2409
|
+
options: N.map((f) => ({ value: f.name, label: f.label })),
|
|
2410
|
+
onChange: (f) => C({ ...l, from: f })
|
|
2411
|
+
}
|
|
2412
|
+
),
|
|
2413
|
+
/* @__PURE__ */ e.jsx("span", { children: r("workshopLab.computed.regionScope") }),
|
|
2414
|
+
/* @__PURE__ */ e.jsx(
|
|
2415
|
+
F,
|
|
2416
|
+
{
|
|
2417
|
+
size: "small",
|
|
2418
|
+
value: l.scope ?? "china",
|
|
2419
|
+
options: ia.map((f) => ({
|
|
2420
|
+
value: f,
|
|
2421
|
+
label: r(`workshopLab.basemaps.${f}`)
|
|
2422
|
+
})),
|
|
2423
|
+
onChange: (f) => C(
|
|
2424
|
+
f === "china" ? { name: l.name, label: l.label, kind: "region", from: l.from } : { ...l, scope: f }
|
|
2425
|
+
)
|
|
2426
|
+
}
|
|
2427
|
+
)
|
|
2428
|
+
] }),
|
|
2429
|
+
m.length > 0 && /* @__PURE__ */ e.jsx("ul", { className: n.computedProblems, children: m.slice(0, 4).map((f) => /* @__PURE__ */ e.jsx("li", { children: f.replace(/^field\[0\]\.?/, "") }, f)) }),
|
|
2430
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedPreviewBox, children: [
|
|
2431
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: r("workshopLab.computed.previewTitle", { date: k }) }),
|
|
2432
|
+
l.name ? l.kind === "matched" && m.length > 0 ? /* @__PURE__ */ e.jsx("span", { className: n.muted, children: r("workshopLab.computed.fixFirst") }) : l.kind === "matched" && !M ? /* @__PURE__ */ e.jsx("span", { className: n.muted, children: r("workshopLab.computed.matchedNotLoaded") }) : l.kind === "related" && R.status === "error" ? /* @__PURE__ */ e.jsx("span", { className: n.error, children: r("workshopLab.computed.relatedFailed") }) : l.kind === "related" && m.length > 0 ? /* @__PURE__ */ e.jsx("span", { className: n.muted, children: r("workshopLab.computed.fixFirst") }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2433
|
+
/* @__PURE__ */ e.jsx(qe, { field: l, rows: M }),
|
|
2434
|
+
/* @__PURE__ */ e.jsx(ys, { field: l, rows: M, fields: t })
|
|
2435
|
+
] }) : /* @__PURE__ */ e.jsx("span", { className: n.muted, children: r("workshopLab.computed.needName") })
|
|
2436
|
+
] })
|
|
2437
|
+
] })
|
|
2438
|
+
}
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
function Ns(a, i) {
|
|
2442
|
+
return a.sources.filter(
|
|
2443
|
+
(t) => t.id !== i.id && !t.from && !t.cypher && !t.events && !t.model
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
function Ss(a, i) {
|
|
2447
|
+
return a ? [
|
|
2448
|
+
...i.objectTypes[a.objectType]?.properties ?? [],
|
|
2449
|
+
...(a.computed ?? []).map(te)
|
|
2450
|
+
] : [];
|
|
2451
|
+
}
|
|
2452
|
+
function Cs(a, i, t) {
|
|
2453
|
+
const w = i.sources.find((k) => k.id === a.source), p = i.states[a.source];
|
|
2454
|
+
return !w || p?.status !== "ready" || p.truncated ? null : ue(p.rows, w, t);
|
|
2455
|
+
}
|
|
2456
|
+
function Ts({
|
|
2457
|
+
field: a,
|
|
2458
|
+
fields: i,
|
|
2459
|
+
source: t,
|
|
2460
|
+
others: w,
|
|
2461
|
+
kn: p,
|
|
2462
|
+
onChange: k
|
|
2463
|
+
}) {
|
|
2464
|
+
const { t: c } = _(), s = Ns(w, t), o = s.find((l) => l.id === a.source), d = Ss(o, p), h = i.filter((l) => l.type !== "date" || l.name !== Q), r = (l, j) => {
|
|
2465
|
+
const g = [...a.pairs];
|
|
2466
|
+
j === null ? g.splice(l, 1) : g[l] = j, k({ ...a, pairs: g });
|
|
2467
|
+
}, u = (l) => {
|
|
2468
|
+
const j = { ...a };
|
|
2469
|
+
delete j.field, delete j.type;
|
|
2470
|
+
const g = d.find((b) => b.name === l)?.type;
|
|
2471
|
+
k(l ? { ...j, field: l, ...g ? { type: g } : {} } : j);
|
|
2472
|
+
};
|
|
2473
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.matchedForm, children: [
|
|
2474
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: c("workshopLab.computed.matchedFrom") }),
|
|
2475
|
+
/* @__PURE__ */ e.jsx(
|
|
2476
|
+
F,
|
|
2477
|
+
{
|
|
2478
|
+
size: "small",
|
|
2479
|
+
className: n.fieldSelect,
|
|
2480
|
+
"aria-label": c("workshopLab.computed.matchedFrom"),
|
|
2481
|
+
value: a.source || void 0,
|
|
2482
|
+
placeholder: c("workshopLab.computed.matchedSource"),
|
|
2483
|
+
options: s.map((l) => ({ value: l.id, label: l.label })),
|
|
2484
|
+
onChange: (l) => (
|
|
2485
|
+
// Another source has other fields: the pairs, conditions and value start again.
|
|
2486
|
+
k({
|
|
2487
|
+
name: a.name,
|
|
2488
|
+
label: a.label,
|
|
2489
|
+
kind: "matched",
|
|
2490
|
+
source: l,
|
|
2491
|
+
pairs: [{ field: "", other: "" }]
|
|
2492
|
+
})
|
|
2493
|
+
)
|
|
2494
|
+
}
|
|
2495
|
+
),
|
|
2496
|
+
o && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2497
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: c("workshopLab.computed.matchedPairs") }),
|
|
2498
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.matchedPairs, children: [
|
|
2499
|
+
a.pairs.map((l, j) => /* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2500
|
+
/* @__PURE__ */ e.jsx(
|
|
2501
|
+
F,
|
|
2502
|
+
{
|
|
2503
|
+
size: "small",
|
|
2504
|
+
showSearch: !0,
|
|
2505
|
+
optionFilterProp: "label",
|
|
2506
|
+
className: n.fieldSelect,
|
|
2507
|
+
"aria-label": c("workshopLab.computed.matchedOwn", { n: j + 1 }),
|
|
2508
|
+
placeholder: c("workshopLab.computed.matchedOwnField", { source: t.label }),
|
|
2509
|
+
value: l.field || void 0,
|
|
2510
|
+
options: h.map((g) => ({ value: g.name, label: g.label })),
|
|
2511
|
+
onChange: (g) => r(j, { ...l, field: g })
|
|
2512
|
+
}
|
|
2513
|
+
),
|
|
2514
|
+
/* @__PURE__ */ e.jsx("span", { children: "=" }),
|
|
2515
|
+
/* @__PURE__ */ e.jsx(
|
|
2516
|
+
F,
|
|
2517
|
+
{
|
|
2518
|
+
size: "small",
|
|
2519
|
+
showSearch: !0,
|
|
2520
|
+
optionFilterProp: "label",
|
|
2521
|
+
className: n.fieldSelect,
|
|
2522
|
+
"aria-label": c("workshopLab.computed.matchedOther", { n: j + 1 }),
|
|
2523
|
+
placeholder: c("workshopLab.computed.matchedOwnField", { source: o.label }),
|
|
2524
|
+
value: l.other || void 0,
|
|
2525
|
+
options: d.map((g) => ({ value: g.name, label: g.label })),
|
|
2526
|
+
onChange: (g) => r(j, { ...l, other: g })
|
|
2527
|
+
}
|
|
2528
|
+
),
|
|
2529
|
+
a.pairs.length > 1 && /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, onClick: () => r(j, null), children: c("workshopLab.computed.removeCondition") })
|
|
2530
|
+
] }, j)),
|
|
2531
|
+
a.pairs.length < ds && /* @__PURE__ */ e.jsx(
|
|
2532
|
+
$,
|
|
2533
|
+
{
|
|
2534
|
+
size: "small",
|
|
2535
|
+
type: "dashed",
|
|
2536
|
+
icon: /* @__PURE__ */ e.jsx(ne, {}),
|
|
2537
|
+
onClick: () => k({ ...a, pairs: [...a.pairs, { field: "", other: "" }] }),
|
|
2538
|
+
children: c("workshopLab.computed.matchedAddPair")
|
|
2539
|
+
}
|
|
2540
|
+
)
|
|
2541
|
+
] }),
|
|
2542
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.computed.matchedPairsHint") }),
|
|
2543
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: c("workshopLab.computed.matchedOnly", { source: o.label }) }),
|
|
2544
|
+
/* @__PURE__ */ e.jsx(
|
|
2545
|
+
K,
|
|
2546
|
+
{
|
|
2547
|
+
value: a.where,
|
|
2548
|
+
fields: d,
|
|
2549
|
+
source: o,
|
|
2550
|
+
onChange: (l) => k({ ...a, where: l.length > 0 ? l : void 0 })
|
|
2551
|
+
}
|
|
2552
|
+
),
|
|
2553
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: c("workshopLab.computed.matchedTake") }),
|
|
2554
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2555
|
+
/* @__PURE__ */ e.jsx(
|
|
2556
|
+
he.Group,
|
|
2557
|
+
{
|
|
2558
|
+
size: "small",
|
|
2559
|
+
optionType: "button",
|
|
2560
|
+
value: a.field === void 0 ? "count" : "first",
|
|
2561
|
+
onChange: (l) => u(l.target.value === "count" ? void 0 : d[0]?.name ?? void 0),
|
|
2562
|
+
options: [
|
|
2563
|
+
{ value: "count", label: c("workshopLab.computed.matchedCount") },
|
|
2564
|
+
{ value: "first", label: c("workshopLab.computed.matchedFirst") }
|
|
2565
|
+
]
|
|
2566
|
+
}
|
|
2567
|
+
),
|
|
2568
|
+
a.field !== void 0 && /* @__PURE__ */ e.jsx(
|
|
2569
|
+
F,
|
|
2570
|
+
{
|
|
2571
|
+
size: "small",
|
|
2572
|
+
showSearch: !0,
|
|
2573
|
+
optionFilterProp: "label",
|
|
2574
|
+
className: n.fieldSelect,
|
|
2575
|
+
"aria-label": c("workshopLab.computed.matchedFirst"),
|
|
2576
|
+
value: a.field,
|
|
2577
|
+
options: d.map((l) => ({ value: l.name, label: l.label })),
|
|
2578
|
+
onChange: (l) => u(l)
|
|
2579
|
+
}
|
|
2580
|
+
)
|
|
2581
|
+
] }),
|
|
2582
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.computed.matchedNote") })
|
|
2583
|
+
] })
|
|
2584
|
+
] });
|
|
2585
|
+
}
|
|
2586
|
+
function zs({
|
|
2587
|
+
field: a,
|
|
2588
|
+
fields: i,
|
|
2589
|
+
onChange: t
|
|
2590
|
+
}) {
|
|
2591
|
+
const { t: w } = _();
|
|
2592
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2593
|
+
/* @__PURE__ */ e.jsx(
|
|
2594
|
+
I,
|
|
2595
|
+
{
|
|
2596
|
+
size: "small",
|
|
2597
|
+
spellCheck: !1,
|
|
2598
|
+
placeholder: "{given_name} {family_name}",
|
|
2599
|
+
value: a.template,
|
|
2600
|
+
onChange: (p) => t({ ...a, template: p.target.value })
|
|
2601
|
+
}
|
|
2602
|
+
),
|
|
2603
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2604
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: w("workshopLab.computed.insertField") }),
|
|
2605
|
+
/* @__PURE__ */ e.jsx(
|
|
2606
|
+
F,
|
|
2607
|
+
{
|
|
2608
|
+
size: "small",
|
|
2609
|
+
showSearch: !0,
|
|
2610
|
+
optionFilterProp: "label",
|
|
2611
|
+
className: n.fieldSelect,
|
|
2612
|
+
value: null,
|
|
2613
|
+
placeholder: w("workshopLab.computed.anyFields"),
|
|
2614
|
+
options: i.map((p) => ({ value: p.name, label: p.label })),
|
|
2615
|
+
onChange: (p) => t({
|
|
2616
|
+
...a,
|
|
2617
|
+
template: `${a.template}${a.template && !a.template.endsWith(" ") ? " " : ""}{${p}}`
|
|
2618
|
+
})
|
|
2619
|
+
}
|
|
2620
|
+
)
|
|
2621
|
+
] })
|
|
2622
|
+
] });
|
|
2623
|
+
}
|
|
2624
|
+
function $s({
|
|
2625
|
+
field: a,
|
|
2626
|
+
fields: i,
|
|
2627
|
+
onChange: t
|
|
2628
|
+
}) {
|
|
2629
|
+
const { t: w } = _(), p = i.filter((s) => s.type === "number"), k = a.expr.trim() ? ca(a.expr) : null, c = k?.ok === !0 ? pa(k.node).filter((s) => !p.some((o) => o.name === s)) : [];
|
|
2630
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2631
|
+
/* @__PURE__ */ e.jsx(
|
|
2632
|
+
I.TextArea,
|
|
2633
|
+
{
|
|
2634
|
+
className: n.cypherText,
|
|
2635
|
+
autoSize: { minRows: 2, maxRows: 4 },
|
|
2636
|
+
spellCheck: !1,
|
|
2637
|
+
placeholder: "signing_quantity - shipping_quantity",
|
|
2638
|
+
value: a.expr,
|
|
2639
|
+
onChange: (s) => t({ ...a, expr: s.target.value })
|
|
2640
|
+
}
|
|
2641
|
+
),
|
|
2642
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2643
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: w("workshopLab.computed.insertField") }),
|
|
2644
|
+
/* @__PURE__ */ e.jsx(
|
|
2645
|
+
F,
|
|
2646
|
+
{
|
|
2647
|
+
size: "small",
|
|
2648
|
+
showSearch: !0,
|
|
2649
|
+
optionFilterProp: "label",
|
|
2650
|
+
className: n.fieldSelect,
|
|
2651
|
+
value: null,
|
|
2652
|
+
placeholder: w("workshopLab.computed.numberFields"),
|
|
2653
|
+
options: p.map((s) => ({ value: s.name, label: s.label })),
|
|
2654
|
+
onChange: (s) => t({ ...a, expr: `${a.expr}${a.expr.trim() ? " " : ""}${s}` })
|
|
2655
|
+
}
|
|
2656
|
+
)
|
|
2657
|
+
] }),
|
|
2658
|
+
k && !k.ok && /* @__PURE__ */ e.jsx("span", { className: n.error, children: k.error }),
|
|
2659
|
+
c.length > 0 && /* @__PURE__ */ e.jsx("span", { className: n.error, children: w("workshopLab.computed.formulaUnknown", { names: c.join("、") }) })
|
|
2660
|
+
] });
|
|
2661
|
+
}
|
|
2662
|
+
function Os({
|
|
2663
|
+
field: a,
|
|
2664
|
+
source: i,
|
|
2665
|
+
kn: t,
|
|
2666
|
+
onChange: w
|
|
2667
|
+
}) {
|
|
2668
|
+
const { t: p } = _(), k = me(t, i.objectType, a.path), c = k && k.length > 0 ? k[k.length - 1].to : i.objectType, s = t.objectTypes[c], o = s?.properties ?? [], d = t.relations.filter(
|
|
2669
|
+
(r) => r.source === c || r.target === c
|
|
2670
|
+
), h = (r) => t.objectTypes[r]?.name ?? r;
|
|
2671
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2672
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2673
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.computed.relatedPath") }),
|
|
2674
|
+
/* @__PURE__ */ e.jsx("span", { className: n.mono, children: h(i.objectType) }),
|
|
2675
|
+
(k ?? []).map((r, u) => /* @__PURE__ */ e.jsxs(
|
|
2676
|
+
J,
|
|
2677
|
+
{
|
|
2678
|
+
closable: u === (k?.length ?? 0) - 1,
|
|
2679
|
+
onClose: () => w({ ...a, path: a.path.slice(0, -1), where: void 0 }),
|
|
2680
|
+
children: [
|
|
2681
|
+
r.relation.name,
|
|
2682
|
+
" → ",
|
|
2683
|
+
h(r.to)
|
|
2684
|
+
]
|
|
2685
|
+
},
|
|
2686
|
+
u
|
|
2687
|
+
)),
|
|
2688
|
+
/* @__PURE__ */ e.jsx(
|
|
2689
|
+
F,
|
|
2690
|
+
{
|
|
2691
|
+
size: "small",
|
|
2692
|
+
showSearch: !0,
|
|
2693
|
+
optionFilterProp: "label",
|
|
2694
|
+
className: n.fieldSelect,
|
|
2695
|
+
value: null,
|
|
2696
|
+
placeholder: p("workshopLab.computed.relatedNext"),
|
|
2697
|
+
options: d.map((r) => ({
|
|
2698
|
+
value: r.id,
|
|
2699
|
+
label: `${r.name}(→ ${h(r.source === c ? r.target : r.source)})`
|
|
2700
|
+
})),
|
|
2701
|
+
onChange: (r) => w({ ...a, path: [...a.path, r], field: void 0, where: void 0 })
|
|
2702
|
+
}
|
|
2703
|
+
)
|
|
2704
|
+
] }),
|
|
2705
|
+
a.path.length > 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
2706
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2707
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.computed.relatedHow") }),
|
|
2708
|
+
/* @__PURE__ */ e.jsx(
|
|
2709
|
+
he.Group,
|
|
2710
|
+
{
|
|
2711
|
+
size: "small",
|
|
2712
|
+
optionType: "button",
|
|
2713
|
+
value: a.aggregate,
|
|
2714
|
+
onChange: (r) => {
|
|
2715
|
+
const u = r.target.value, l = o.find((g) => g.name === a.field)?.type, j = { ...a, aggregate: u };
|
|
2716
|
+
delete j.type, w({ ...j, ...u === "one" && l ? { type: l } : {} });
|
|
2717
|
+
},
|
|
2718
|
+
options: da.map((r) => ({
|
|
2719
|
+
value: r,
|
|
2720
|
+
label: p(`workshopLab.computed.aggregateNames.${r}`)
|
|
2721
|
+
}))
|
|
2722
|
+
}
|
|
2723
|
+
),
|
|
2724
|
+
a.aggregate !== "count" && /* @__PURE__ */ e.jsx(
|
|
2725
|
+
F,
|
|
2726
|
+
{
|
|
2727
|
+
size: "small",
|
|
2728
|
+
className: n.fieldSelect,
|
|
2729
|
+
value: a.field,
|
|
2730
|
+
placeholder: p(
|
|
2731
|
+
a.aggregate === "one" || a.aggregate === "list" ? "workshopLab.computed.anyFields" : "workshopLab.computed.numberFields"
|
|
2732
|
+
),
|
|
2733
|
+
options: o.filter(
|
|
2734
|
+
(r) => a.aggregate === "one" || a.aggregate === "list" || r.type === "number"
|
|
2735
|
+
).map((r) => ({ value: r.name, label: r.label })),
|
|
2736
|
+
onChange: (r) => {
|
|
2737
|
+
const u = o.find((l) => l.name === r)?.type;
|
|
2738
|
+
w({
|
|
2739
|
+
...a,
|
|
2740
|
+
field: r,
|
|
2741
|
+
...a.aggregate === "one" && u ? { type: u } : {}
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
)
|
|
2746
|
+
] }),
|
|
2747
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: p("workshopLab.computed.relatedOnly", { target: s?.name ?? "" }) }),
|
|
2748
|
+
/* @__PURE__ */ e.jsx(
|
|
2749
|
+
K,
|
|
2750
|
+
{
|
|
2751
|
+
literalOnly: !0,
|
|
2752
|
+
value: a.where,
|
|
2753
|
+
fields: o,
|
|
2754
|
+
onChange: (r) => w({ ...a, where: r.length > 0 ? r : void 0 })
|
|
2755
|
+
}
|
|
2756
|
+
),
|
|
2757
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: p("workshopLab.computed.relatedNote") })
|
|
2758
|
+
] })
|
|
2759
|
+
] });
|
|
2760
|
+
}
|
|
2761
|
+
function Fs({
|
|
2762
|
+
field: a,
|
|
2763
|
+
fields: i,
|
|
2764
|
+
source: t,
|
|
2765
|
+
onChange: w
|
|
2766
|
+
}) {
|
|
2767
|
+
const { t: p } = _(), k = (c, s) => {
|
|
2768
|
+
const o = [...a.cases];
|
|
2769
|
+
s === null ? o.splice(c, 1) : o[c] = s, w({ ...a, cases: o });
|
|
2770
|
+
};
|
|
2771
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedCases, children: [
|
|
2772
|
+
a.cases.map((c, s) => /* @__PURE__ */ e.jsxs("div", { className: n.computedCase, children: [
|
|
2773
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedCaseHead, children: [
|
|
2774
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.computed.caseValue", { n: s + 1 }) }),
|
|
2775
|
+
/* @__PURE__ */ e.jsx(
|
|
2776
|
+
Ee,
|
|
2777
|
+
{
|
|
2778
|
+
outcome: c,
|
|
2779
|
+
onChange: (o) => k(s, { ...c, ...o })
|
|
2780
|
+
}
|
|
2781
|
+
),
|
|
2782
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
2783
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, onClick: () => k(s, null), children: p("workshopLab.computed.removeCase") })
|
|
2784
|
+
] }),
|
|
2785
|
+
/* @__PURE__ */ e.jsx("span", { className: n.fieldLabel, children: p("workshopLab.computed.when") }),
|
|
2786
|
+
/* @__PURE__ */ e.jsx(
|
|
2787
|
+
K,
|
|
2788
|
+
{
|
|
2789
|
+
value: c.when,
|
|
2790
|
+
fields: i,
|
|
2791
|
+
source: t,
|
|
2792
|
+
onChange: (o) => k(s, { ...c, when: o })
|
|
2793
|
+
}
|
|
2794
|
+
)
|
|
2795
|
+
] }, s)),
|
|
2796
|
+
/* @__PURE__ */ e.jsx(
|
|
2797
|
+
$,
|
|
2798
|
+
{
|
|
2799
|
+
size: "small",
|
|
2800
|
+
type: "dashed",
|
|
2801
|
+
onClick: () => w({ ...a, cases: [...a.cases, { value: "", when: [] }] }),
|
|
2802
|
+
children: p("workshopLab.computed.addCase")
|
|
2803
|
+
}
|
|
2804
|
+
),
|
|
2805
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedCaseHead, children: [
|
|
2806
|
+
/* @__PURE__ */ e.jsx("span", { children: p("workshopLab.computed.otherwise") }),
|
|
2807
|
+
/* @__PURE__ */ e.jsx(
|
|
2808
|
+
Ee,
|
|
2809
|
+
{
|
|
2810
|
+
outcome: a.otherwise,
|
|
2811
|
+
onChange: (c) => w({ ...a, otherwise: c })
|
|
2812
|
+
}
|
|
2813
|
+
)
|
|
2814
|
+
] })
|
|
2815
|
+
] });
|
|
2816
|
+
}
|
|
2817
|
+
function Ee({
|
|
2818
|
+
outcome: a,
|
|
2819
|
+
onChange: i
|
|
2820
|
+
}) {
|
|
2821
|
+
const { t } = _();
|
|
2822
|
+
return /* @__PURE__ */ e.jsxs(P.Compact, { children: [
|
|
2823
|
+
/* @__PURE__ */ e.jsx(
|
|
2824
|
+
I,
|
|
2825
|
+
{
|
|
2826
|
+
size: "small",
|
|
2827
|
+
placeholder: t("workshopLab.computed.valuePlaceholder"),
|
|
2828
|
+
value: a.value,
|
|
2829
|
+
onChange: (w) => i({ ...a, value: w.target.value })
|
|
2830
|
+
}
|
|
2831
|
+
),
|
|
2832
|
+
/* @__PURE__ */ e.jsx(
|
|
2833
|
+
F,
|
|
2834
|
+
{
|
|
2835
|
+
size: "small",
|
|
2836
|
+
className: n.toneSelect,
|
|
2837
|
+
value: a.tone ?? "neutral",
|
|
2838
|
+
options: Ae.map((w) => ({
|
|
2839
|
+
value: w,
|
|
2840
|
+
label: t(`workshopLab.computed.tones.${w}`)
|
|
2841
|
+
})),
|
|
2842
|
+
onChange: (w) => i({ ...a, tone: w })
|
|
2843
|
+
}
|
|
2844
|
+
)
|
|
2845
|
+
] });
|
|
2846
|
+
}
|
|
2847
|
+
function Ps({
|
|
2848
|
+
source: a,
|
|
2849
|
+
properties: i,
|
|
2850
|
+
rows: t,
|
|
2851
|
+
usage: w,
|
|
2852
|
+
onEdit: p,
|
|
2853
|
+
onRemove: k
|
|
2854
|
+
}) {
|
|
2855
|
+
const { t: c } = _(), s = a.progress;
|
|
2856
|
+
if (!s) return null;
|
|
2857
|
+
const o = (u) => i.find((l) => l.name === u)?.label ?? u, d = fe(s), h = [
|
|
2858
|
+
...new Map(
|
|
2859
|
+
d.flatMap((u) => w.get(u.name) ?? []).map((u) => [u.id, u])
|
|
2860
|
+
).values()
|
|
2861
|
+
], r = /* @__PURE__ */ new Map();
|
|
2862
|
+
for (const u of t ?? []) {
|
|
2863
|
+
const l = String(u[q.status] ?? "");
|
|
2864
|
+
r.set(l, (r.get(l) ?? 0) + 1);
|
|
2865
|
+
}
|
|
2866
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedItem, children: [
|
|
2867
|
+
/* @__PURE__ */ e.jsxs("div", { className: n.computedHead, children: [
|
|
2868
|
+
/* @__PURE__ */ e.jsx("b", { children: c("workshopLab.progress.title") }),
|
|
2869
|
+
/* @__PURE__ */ e.jsx("span", { className: n.spacer }),
|
|
2870
|
+
/* @__PURE__ */ e.jsx($, { size: "small", type: "link", onClick: p, children: c("workshopLab.computed.edit") }),
|
|
2871
|
+
h.length > 0 ? /* @__PURE__ */ e.jsx(
|
|
2872
|
+
xe,
|
|
2873
|
+
{
|
|
2874
|
+
title: c("workshopLab.computed.removeBlocked", {
|
|
2875
|
+
names: h.map((u) => u.label).join("、")
|
|
2876
|
+
}),
|
|
2877
|
+
children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, disabled: !0, children: c("workshopLab.computed.remove") })
|
|
2878
|
+
}
|
|
2879
|
+
) : /* @__PURE__ */ e.jsx(ee, { title: c("workshopLab.progress.removeConfirm"), onConfirm: k, children: /* @__PURE__ */ e.jsx($, { size: "small", type: "link", danger: !0, children: c("workshopLab.computed.remove") }) })
|
|
2880
|
+
] }),
|
|
2881
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
2882
|
+
s.steps.map(
|
|
2883
|
+
(u) => u.done ? c("workshopLab.progress.stepByRule", { label: u.label }) : c("workshopLab.progress.stepByDate", {
|
|
2884
|
+
label: u.label,
|
|
2885
|
+
field: u.field ? o(u.field) : ""
|
|
2886
|
+
})
|
|
2887
|
+
).join(" → "),
|
|
2888
|
+
s.due && c("workshopLab.progress.dueLine", {
|
|
2889
|
+
label: s.due.label || o(s.due.field)
|
|
2890
|
+
})
|
|
2891
|
+
] }),
|
|
2892
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.progress.exists", { label: s.steps[0]?.label ?? "" }) }),
|
|
2893
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.progress.columns", {
|
|
2894
|
+
names: d.map((u) => `${u.label}(${u.name})`).join("、")
|
|
2895
|
+
}) }),
|
|
2896
|
+
t ? /* @__PURE__ */ e.jsx("span", { className: n.computedPreview, children: Ie.map((u) => /* @__PURE__ */ e.jsxs(J, { color: ve(u.tone), children: [
|
|
2897
|
+
je(u.value),
|
|
2898
|
+
" ",
|
|
2899
|
+
r.get(u.value) ?? 0
|
|
2900
|
+
] }, u.value)) }) : /* @__PURE__ */ e.jsx("span", { className: n.muted, children: c("workshopLab.computed.notLoaded") }),
|
|
2901
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: h.length > 0 ? c("workshopLab.computed.usedBy", { names: h.map((u) => u.label).join("、") }) : c("workshopLab.computed.unused") })
|
|
2902
|
+
] });
|
|
2903
|
+
}
|
|
2904
|
+
function Es(a) {
|
|
2905
|
+
return a ? {
|
|
2906
|
+
steps: a.steps.map((i) => {
|
|
2907
|
+
const t = i.done?.[0];
|
|
2908
|
+
return t && t.op === "eq" ? {
|
|
2909
|
+
label: i.label,
|
|
2910
|
+
field: i.field,
|
|
2911
|
+
by: "field",
|
|
2912
|
+
doneField: t.field,
|
|
2913
|
+
doneValue: String(t.value ?? "")
|
|
2914
|
+
} : { label: i.label, field: i.field, by: "date" };
|
|
2915
|
+
}),
|
|
2916
|
+
due: a.due?.field,
|
|
2917
|
+
dueLabel: a.due?.label ?? ""
|
|
2918
|
+
} : {
|
|
2919
|
+
steps: [
|
|
2920
|
+
{ label: "", by: "date" },
|
|
2921
|
+
{ label: "", by: "date" }
|
|
2922
|
+
],
|
|
2923
|
+
dueLabel: ""
|
|
2924
|
+
};
|
|
2925
|
+
}
|
|
2926
|
+
function Ms({
|
|
2927
|
+
initial: a,
|
|
2928
|
+
source: i,
|
|
2929
|
+
asOf: t,
|
|
2930
|
+
properties: w,
|
|
2931
|
+
rows: p,
|
|
2932
|
+
onCancel: k,
|
|
2933
|
+
onSave: c
|
|
2934
|
+
}) {
|
|
2935
|
+
const { t: s } = _(), o = w.filter((v) => v.type === "date"), [d, h] = A.useState(() => Es(a)), r = (v, C) => h({
|
|
2936
|
+
...d,
|
|
2937
|
+
steps: d.steps.map((S, N) => N === v ? { ...S, ...C } : S)
|
|
2938
|
+
}), u = (v) => {
|
|
2939
|
+
if (!p || !v) return [];
|
|
2940
|
+
const C = /* @__PURE__ */ new Map();
|
|
2941
|
+
for (const S of p) {
|
|
2942
|
+
const N = S[v];
|
|
2943
|
+
N != null && N !== "" && C.set(String(N), (C.get(String(N)) ?? 0) + 1);
|
|
2944
|
+
}
|
|
2945
|
+
return [...C].sort((S, N) => N[1] - S[1]);
|
|
2946
|
+
}, l = d.steps.every(
|
|
2947
|
+
(v) => v.label.trim() !== "" && (v.by === "date" ? !!v.field : !!(v.doneField && v.doneValue))
|
|
2948
|
+
), j = () => ({
|
|
2949
|
+
steps: d.steps.map((v) => ({
|
|
2950
|
+
label: v.label.trim(),
|
|
2951
|
+
...v.field ? { field: v.field } : {},
|
|
2952
|
+
...v.by === "field" && v.doneField ? {
|
|
2953
|
+
done: [
|
|
2954
|
+
{ field: v.doneField, op: "eq", value: v.doneValue ?? "" }
|
|
2955
|
+
]
|
|
2956
|
+
} : {}
|
|
2957
|
+
})),
|
|
2958
|
+
...d.due ? {
|
|
2959
|
+
due: {
|
|
2960
|
+
field: d.due,
|
|
2961
|
+
...d.dueLabel.trim() ? { label: d.dueLabel.trim() } : {}
|
|
2962
|
+
}
|
|
2963
|
+
} : {}
|
|
2964
|
+
}), g = o.map((v) => ({ value: v.name, label: v.label })), b = l && d.steps.length > 0 ? j() : void 0, T = A.useMemo(
|
|
2965
|
+
() => p && b ? ue(p, { ...i, progress: b }, t) : null,
|
|
2966
|
+
// The draft is rebuilt each render; its JSON says when it really changed.
|
|
2967
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2968
|
+
[p, i, t, JSON.stringify(b)]
|
|
2969
|
+
);
|
|
2970
|
+
return /* @__PURE__ */ e.jsx(
|
|
2971
|
+
ae,
|
|
2972
|
+
{
|
|
2973
|
+
open: !0,
|
|
2974
|
+
width: 680,
|
|
2975
|
+
title: s("workshopLab.progress.dialogTitle"),
|
|
2976
|
+
okText: s("workshopLab.computed.save"),
|
|
2977
|
+
okButtonProps: { disabled: !l || d.steps.length === 0 },
|
|
2978
|
+
onOk: () => c(j()),
|
|
2979
|
+
onCancel: k,
|
|
2980
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: n.computedForm, children: [
|
|
2981
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.progress.dialogHint") }),
|
|
2982
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.progress.stepsTitle") }),
|
|
2983
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.progress.stepDateHint") }),
|
|
2984
|
+
d.steps.map((v, C) => /* @__PURE__ */ e.jsxs("div", { className: n.computedCase, children: [
|
|
2985
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
2986
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.progress.stepN", { n: C + 1 }) }),
|
|
2987
|
+
/* @__PURE__ */ e.jsx(
|
|
2988
|
+
I,
|
|
2989
|
+
{
|
|
2990
|
+
size: "small",
|
|
2991
|
+
className: n.fieldSelect,
|
|
2992
|
+
placeholder: s("workshopLab.progress.stepLabel"),
|
|
2993
|
+
value: v.label,
|
|
2994
|
+
onChange: (S) => r(C, { label: S.target.value })
|
|
2995
|
+
}
|
|
2996
|
+
),
|
|
2997
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.progress.stepDate") }),
|
|
2998
|
+
/* @__PURE__ */ e.jsx(
|
|
2999
|
+
F,
|
|
3000
|
+
{
|
|
3001
|
+
size: "small",
|
|
3002
|
+
className: n.fieldSelect,
|
|
3003
|
+
allowClear: v.by === "field",
|
|
3004
|
+
value: v.field,
|
|
3005
|
+
options: g,
|
|
3006
|
+
onChange: (S) => r(C, { field: S })
|
|
3007
|
+
}
|
|
3008
|
+
),
|
|
3009
|
+
/* @__PURE__ */ e.jsx(
|
|
3010
|
+
$,
|
|
3011
|
+
{
|
|
3012
|
+
size: "small",
|
|
3013
|
+
type: "link",
|
|
3014
|
+
danger: !0,
|
|
3015
|
+
disabled: d.steps.length <= 1,
|
|
3016
|
+
onClick: () => h({ ...d, steps: d.steps.filter((S, N) => N !== C) }),
|
|
3017
|
+
children: s("workshopLab.computed.removeCase")
|
|
3018
|
+
}
|
|
3019
|
+
)
|
|
3020
|
+
] }),
|
|
3021
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
3022
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.progress.doneBy") }),
|
|
3023
|
+
/* @__PURE__ */ e.jsx(
|
|
3024
|
+
he.Group,
|
|
3025
|
+
{
|
|
3026
|
+
size: "small",
|
|
3027
|
+
value: v.by,
|
|
3028
|
+
onChange: (S) => r(C, { by: S.target.value }),
|
|
3029
|
+
options: [
|
|
3030
|
+
{ value: "date", label: s("workshopLab.progress.doneByDate") },
|
|
3031
|
+
{ value: "field", label: s("workshopLab.progress.doneByField") }
|
|
3032
|
+
]
|
|
3033
|
+
}
|
|
3034
|
+
),
|
|
3035
|
+
v.by === "field" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
3036
|
+
/* @__PURE__ */ e.jsx(
|
|
3037
|
+
F,
|
|
3038
|
+
{
|
|
3039
|
+
size: "small",
|
|
3040
|
+
className: n.fieldSelect,
|
|
3041
|
+
value: v.doneField,
|
|
3042
|
+
options: w.filter((S) => S.type !== "date").map((S) => ({ value: S.name, label: S.label })),
|
|
3043
|
+
onChange: (S) => r(C, { doneField: S, doneValue: void 0 })
|
|
3044
|
+
}
|
|
3045
|
+
),
|
|
3046
|
+
/* @__PURE__ */ e.jsx("span", { children: s("workshopLab.computed.ops.eq") }),
|
|
3047
|
+
/* @__PURE__ */ e.jsx(
|
|
3048
|
+
fa,
|
|
3049
|
+
{
|
|
3050
|
+
size: "small",
|
|
3051
|
+
className: n.fieldSelect,
|
|
3052
|
+
value: v.doneValue,
|
|
3053
|
+
options: u(v.doneField).map(([S, N]) => ({
|
|
3054
|
+
value: S,
|
|
3055
|
+
label: `${S}(${N})`
|
|
3056
|
+
})),
|
|
3057
|
+
filterOption: (S, N) => String(N?.value ?? "").includes(S),
|
|
3058
|
+
onChange: (S) => r(C, { doneValue: S })
|
|
3059
|
+
}
|
|
3060
|
+
)
|
|
3061
|
+
] })
|
|
3062
|
+
] })
|
|
3063
|
+
] }, C)),
|
|
3064
|
+
/* @__PURE__ */ e.jsx(
|
|
3065
|
+
$,
|
|
3066
|
+
{
|
|
3067
|
+
size: "small",
|
|
3068
|
+
disabled: d.steps.length >= Xa,
|
|
3069
|
+
onClick: () => h({ ...d, steps: [...d.steps, { label: "", by: "date" }] }),
|
|
3070
|
+
children: s("workshopLab.progress.addStep")
|
|
3071
|
+
}
|
|
3072
|
+
),
|
|
3073
|
+
/* @__PURE__ */ e.jsx("b", { children: s("workshopLab.progress.dueTitle") }),
|
|
3074
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.progress.dueHint") }),
|
|
3075
|
+
/* @__PURE__ */ e.jsxs(P, { wrap: !0, children: [
|
|
3076
|
+
/* @__PURE__ */ e.jsx(
|
|
3077
|
+
F,
|
|
3078
|
+
{
|
|
3079
|
+
size: "small",
|
|
3080
|
+
allowClear: !0,
|
|
3081
|
+
className: n.fieldSelect,
|
|
3082
|
+
placeholder: s("workshopLab.progress.noDue"),
|
|
3083
|
+
value: d.due,
|
|
3084
|
+
options: g,
|
|
3085
|
+
onChange: (v) => h({ ...d, due: v })
|
|
3086
|
+
}
|
|
3087
|
+
),
|
|
3088
|
+
/* @__PURE__ */ e.jsx(
|
|
3089
|
+
I,
|
|
3090
|
+
{
|
|
3091
|
+
size: "small",
|
|
3092
|
+
className: n.fieldSelect,
|
|
3093
|
+
placeholder: s("workshopLab.progress.dueLabel"),
|
|
3094
|
+
value: d.dueLabel,
|
|
3095
|
+
onChange: (v) => h({ ...d, dueLabel: v.target.value })
|
|
3096
|
+
}
|
|
3097
|
+
)
|
|
3098
|
+
] }),
|
|
3099
|
+
d.due && d.steps.some((v) => v.by === "date" && v.field === d.due) && /* @__PURE__ */ e.jsx(re, { type: "warning", showIcon: !0, message: s("workshopLab.progress.sameAsDue") }),
|
|
3100
|
+
/* @__PURE__ */ e.jsx("span", { className: n.muted, children: s("workshopLab.progress.makes") }),
|
|
3101
|
+
/* @__PURE__ */ e.jsx(
|
|
3102
|
+
Ye,
|
|
3103
|
+
{
|
|
3104
|
+
rows: T,
|
|
3105
|
+
loaded: p !== null,
|
|
3106
|
+
progress: b,
|
|
3107
|
+
properties: w,
|
|
3108
|
+
asOf: t
|
|
3109
|
+
}
|
|
3110
|
+
)
|
|
3111
|
+
] })
|
|
3112
|
+
}
|
|
3113
|
+
);
|
|
3114
|
+
}
|
|
3115
|
+
const As = [
|
|
3116
|
+
de.overdue.value,
|
|
3117
|
+
de.active.value,
|
|
3118
|
+
de.done.value
|
|
3119
|
+
], _s = 6;
|
|
3120
|
+
function Ye({
|
|
3121
|
+
rows: a,
|
|
3122
|
+
loaded: i,
|
|
3123
|
+
progress: t,
|
|
3124
|
+
properties: w,
|
|
3125
|
+
asOf: p
|
|
3126
|
+
}) {
|
|
3127
|
+
const { t: k } = _(), [c, s] = A.useState(), o = (h) => w.find((r) => r.name === h)?.label ?? h, d = (() => {
|
|
3128
|
+
if (!i) return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: k("workshopLab.computed.notLoaded") });
|
|
3129
|
+
if (!t || !a)
|
|
3130
|
+
return /* @__PURE__ */ e.jsx("span", { className: n.muted, children: k("workshopLab.progress.previewIncomplete") });
|
|
3131
|
+
const h = /* @__PURE__ */ new Map();
|
|
3132
|
+
for (const j of a) {
|
|
3133
|
+
const g = String(j[le] ?? "");
|
|
3134
|
+
h.set(g, (h.get(g) ?? 0) + 1);
|
|
3135
|
+
}
|
|
3136
|
+
const r = c ? a.filter((j) => j[le] === c).slice(0, _s) : As.flatMap(
|
|
3137
|
+
(j) => a.filter((g) => g[le] === j).slice(0, 2)
|
|
3138
|
+
), u = [
|
|
3139
|
+
.../* @__PURE__ */ new Set([
|
|
3140
|
+
...t.steps.flatMap((j) => j.field ? [j.field] : []),
|
|
3141
|
+
...t.due ? [t.due.field] : []
|
|
3142
|
+
])
|
|
3143
|
+
], l = (j) => j == null || j === "";
|
|
3144
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
3145
|
+
/* @__PURE__ */ e.jsx("span", { className: n.computedPreview, children: Ie.map((j) => /* @__PURE__ */ e.jsxs(
|
|
3146
|
+
J,
|
|
3147
|
+
{
|
|
3148
|
+
color: ve(j.tone),
|
|
3149
|
+
className: n.previewTag,
|
|
3150
|
+
"data-dim": c !== void 0 && c !== j.value || void 0,
|
|
3151
|
+
onClick: () => s(c === j.value ? void 0 : j.value),
|
|
3152
|
+
children: [
|
|
3153
|
+
je(j.value),
|
|
3154
|
+
" ",
|
|
3155
|
+
h.get(j.value) ?? 0
|
|
3156
|
+
]
|
|
3157
|
+
},
|
|
3158
|
+
j.value
|
|
3159
|
+
)) }),
|
|
3160
|
+
t.due && (h.get(de.overdue.value) ?? 0) === 0 && /* @__PURE__ */ e.jsx("span", { className: n.muted, children: k("workshopLab.progress.previewNoOverdue") }),
|
|
3161
|
+
/* @__PURE__ */ e.jsx(
|
|
3162
|
+
De,
|
|
3163
|
+
{
|
|
3164
|
+
size: "small",
|
|
3165
|
+
rowKey: "$key",
|
|
3166
|
+
pagination: !1,
|
|
3167
|
+
scroll: { x: "max-content" },
|
|
3168
|
+
dataSource: r,
|
|
3169
|
+
columns: [
|
|
3170
|
+
{ key: "$key", title: k("workshopLab.computed.object"), dataIndex: "$key" },
|
|
3171
|
+
...u.map((j) => ({
|
|
3172
|
+
key: j,
|
|
3173
|
+
title: j === t.due?.field ? k("workshopLab.progress.previewDue", { label: o(j) }) : o(j),
|
|
3174
|
+
dataIndex: j,
|
|
3175
|
+
render: (g) => l(g) ? "—" : String(g).slice(0, 10)
|
|
3176
|
+
})),
|
|
3177
|
+
{
|
|
3178
|
+
key: q.stage,
|
|
3179
|
+
title: k("workshopLab.progress.previewStage"),
|
|
3180
|
+
dataIndex: q.stage,
|
|
3181
|
+
render: (j) => l(j) ? "—" : String(j)
|
|
3182
|
+
},
|
|
3183
|
+
{
|
|
3184
|
+
key: le,
|
|
3185
|
+
title: k("workshopLab.progress.title"),
|
|
3186
|
+
dataIndex: le,
|
|
3187
|
+
render: (j) => je(String(j ?? ""))
|
|
3188
|
+
},
|
|
3189
|
+
...t.due ? [
|
|
3190
|
+
{
|
|
3191
|
+
key: q.overdueDays,
|
|
3192
|
+
title: k("workshopLab.progress.previewOverdue"),
|
|
3193
|
+
dataIndex: q.overdueDays,
|
|
3194
|
+
render: (j) => l(j) || j === 0 ? "—" : String(j)
|
|
3195
|
+
}
|
|
3196
|
+
] : []
|
|
3197
|
+
]
|
|
3198
|
+
}
|
|
3199
|
+
)
|
|
3200
|
+
] });
|
|
3201
|
+
})();
|
|
3202
|
+
return /* @__PURE__ */ e.jsxs("div", { className: n.computedPreviewBox, "aria-label": k("workshopLab.progress.previewTitle"), children: [
|
|
3203
|
+
/* @__PURE__ */ e.jsx("b", { children: k("workshopLab.progress.previewTitle", { date: p }) }),
|
|
3204
|
+
d
|
|
3205
|
+
] });
|
|
3206
|
+
}
|
|
3207
|
+
const le = q.status, Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3208
|
+
__proto__: null,
|
|
3209
|
+
ComputedView: ks,
|
|
3210
|
+
EditColumnDialog: vs,
|
|
3211
|
+
NewColumnDialog: fs,
|
|
3212
|
+
ProgressPreview: Ye,
|
|
3213
|
+
columnName: Je
|
|
3214
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3215
|
+
export {
|
|
3216
|
+
ks as C,
|
|
3217
|
+
$e as G,
|
|
3218
|
+
Hs as a,
|
|
3219
|
+
Ue as c,
|
|
3220
|
+
os as s
|
|
3221
|
+
};
|