@skillre/dsh-plugin-work-dashboard 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -250,7 +250,7 @@ window.__ModuleLoader__.load({
250
250
  // Milestone 3: export form
251
251
  exportNav: "\u5BFC\u51FA\u8868\u5355",
252
252
  exportTitle: "\u5BFC\u51FA\u7ED9\u7EC4\u5458\u586B\u5199\u7684\u8868\u5355",
253
- exportSubtitle: "\u52FE\u9009\u9879\u76EE\uFF0C\u751F\u6210\u4E00\u4E2A\u81EA\u5305\u542B HTML \u6587\u4EF6\uFF1A\u53CC\u51FB\u5373\u53EF\u586B\u5199\uFF0C\u81EA\u52A8\u4FDD\u5B58\uFF0C\u5B9E\u65F6\u6821\u9A8C\uFF0C\u586B\u5B8C\u4E0B\u8F7D YAML\u3002",
253
+ exportSubtitle: "\u52FE\u9009\u9879\u76EE\uFF0C\u751F\u6210\u4E00\u4E2A\u81EA\u5305\u542B HTML \u6587\u4EF6\uFF1A\u53CC\u51FB\u5373\u53EF\u586B\u5199\uFF0C\u81EA\u52A8\u4FDD\u5B58\uFF0C\u5B9E\u65F6\u6821\u9A8C\u3002\u7EC4\u5458\u586B\u5B8C\u70B9\u3010\u751F\u6210\u56DE\u4F20\u6587\u4EF6\u3011\uFF0C\u901A\u8FC7\u4F01\u4E1A\u5FAE\u4FE1\u53D1\u56DE\u5373\u53EF\u3002",
254
254
  exportSelectAll: "\u5168\u9009",
255
255
  exportSelectNone: "\u6E05\u7A7A",
256
256
  exportSelected: "\u5DF2\u9009 {count} \u4E2A\u9879\u76EE",
@@ -261,15 +261,13 @@ window.__ModuleLoader__.load({
261
261
  exportIntentLabel: "\u8FD9\u6B21\u8981\u505A\u4EC0\u4E48",
262
262
  exportIntentNew: "\u65B0\u5EFA\u9879\u76EE",
263
263
  exportIntentNewHint: "\u7ACB\u9879\u767B\u8BB0\uFF1A\u8EAB\u4EFD + G0 \u4E94\u5FC5\u586B",
264
- exportIntentSupplement: "\u8865\u5145\u4FE1\u606F",
265
- exportIntentSupplementHint: "\u53EA\u586B\u5F53\u524D\u9636\u6BB5\u8BE5\u586B\u7684\uFF0C\u5176\u4F59\u53EA\u8BFB",
266
264
  exportIntentProgress: "\u8BB0\u5F55\u8FDB\u5C55",
267
- exportIntentProgressHint: "\u53EA\u586B\u8FD9\u4E00\u8F6E\uFF0C\u4E00\u5C4F\u5B8C\u6210",
268
- exportNewHint: "\u65B0\u5EFA\u9879\u76EE\u8868\u5355\u53EA\u95EE\u4E24\u4EF6\u4E8B\uFF1A\u9879\u76EE\u8EAB\u4EFD\uFF0C\u548C G0 \u7684\u4E94\u4E2A\u5FC5\u586B\u9879\u3002\u8BA1\u5212\uFF08\u6307\u6807\u3001\u573A\u666F\uFF09\u7559\u5230 G1 \u518D\u586B\u2014\u2014\u53F0\u8D26\u4E5F\u662F G0 \u901A\u8FC7\u4E4B\u540E\u624D\u8981\u6C42\u8BA1\u5212\u3002",
265
+ exportIntentProgressHint: "\u5BF9\u7167\u4E0A\u8F6E\u8BA1\u5212\uFF0C\u586B\u5199\u672C\u8F6E\u8FDB\u5C55\u4E0E\u4E0B\u8F6E\u5B89\u6392",
266
+ exportNewHint: "\u53EA\u9700\u7ACB\u9879\u57FA\u672C\u4FE1\u606F\u548C G0 \u4E94\u9879\u4E8B\u5B9E\u3002\u5DF2\u6709\u8FDB\u5C55\u6216\u4E0B\u4E00\u6B65\u8BA1\u5212\uFF0C\u53EF\u4EE5\u9009\u586B\u3002",
269
267
  exportStageFilterLabel: "\u6309\u9636\u6BB5\u7B5B\u9009",
270
268
  exportStageAll: "\u5168\u90E8\u9636\u6BB5",
271
269
  exportStageEmpty: "\u8FD9\u4E2A\u9636\u6BB5\u4E0B\u6CA1\u6709\u9879\u76EE\u3002",
272
- exportHint: "\u8868\u5355\u5B8C\u5168\u79BB\u7EBF\u53EF\u7528\uFF1A\u6CA1\u6709 CDN\u3001\u6CA1\u6709\u5916\u90E8\u5B57\u4F53\u3001\u6CA1\u6709\u670D\u52A1\u5668\u3002\u586B\u5B8C\u4E0B\u8F7D\u7684\u53D8\u66F4\u96C6\uFF08.json\uFF09\u53D1\u7ED9\u9879\u76EE\u8D1F\u8D23\u4EBA\uFF0C\u7531\u4ED6\u5408\u5E76\u8FDB\u53F0\u8D26\u3002",
270
+ exportHint: "\u8868\u5355\u5B8C\u5168\u79BB\u7EBF\u53EF\u7528\uFF1A\u6CA1\u6709 CDN\u3001\u6CA1\u6709\u5916\u90E8\u5B57\u4F53\u3001\u6CA1\u6709\u670D\u52A1\u5668\u3002\u7EC4\u5458\u586B\u5B8C\u751F\u6210\u56DE\u4F20 HTML\uFF0C\u901A\u8FC7\u4F01\u4E1A\u5FAE\u4FE1\u53D1\u56DE\u3002DSH \u6821\u9A8C\u540E\u51C6\u5907\u5F85\u5BA1\u53D8\u66F4\uFF0C\u4E0D\u76F4\u63A5\u5199\u53F0\u8D26\u3002",
273
271
  exportGenerate: "\u751F\u6210\u5E76\u4E0B\u8F7D",
274
272
  exportGenerating: "\u6B63\u5728\u751F\u6210\u2026",
275
273
  exportDone: "\u5DF2\u4E0B\u8F7D {name}",
@@ -837,7 +835,7 @@ window.__ModuleLoader__.load({
837
835
  // Milestone 3: export form
838
836
  exportNav: "Export form",
839
837
  exportTitle: "Export a form for a colleague",
840
- exportSubtitle: "Pick projects and generate one self-contained HTML file: open it, fill it in, auto-saved, live-validated, then download the YAML.",
838
+ exportSubtitle: "Pick projects and generate one self-contained HTML file: open it, fill it in, auto-saved, live-validated. The colleague then clicks Generate return file and sends it back.",
841
839
  exportSelectAll: "Select all",
842
840
  exportSelectNone: "Clear",
843
841
  exportSelected: "{count} project(s) selected",
@@ -846,15 +844,13 @@ window.__ModuleLoader__.load({
846
844
  exportIntentLabel: "What is this for",
847
845
  exportIntentNew: "New project",
848
846
  exportIntentNewHint: "Registration: identity + the five G0 requirements",
849
- exportIntentSupplement: "Fill in a stage",
850
- exportIntentSupplementHint: "Only the current stage is editable",
851
847
  exportIntentProgress: "Record progress",
852
- exportIntentProgressHint: "One round, one screen",
853
- exportNewHint: "A new-project form asks only two things: the project identity, and the five Gate 0 requirements. The plan (criteria, scenarios) waits for G1 \u2014 the ledger only demands a plan after G0 passes.",
848
+ exportIntentProgressHint: "Review the last plan and set the next one",
849
+ exportNewHint: "Add the project basics and five Gate 0 facts. The first progress round or action plan is optional.",
854
850
  exportStageFilterLabel: "Filter by stage",
855
851
  exportStageAll: "All stages",
856
852
  exportStageEmpty: "No projects at this stage.",
857
- exportHint: "The form works fully offline: no CDN, no external fonts, no server. The change set (.json) it produces goes to the project owner, who merges it into the ledger.",
853
+ exportHint: "The form works fully offline: no CDN, no external fonts, no server. The colleague downloads an HTML return file to send back. DSH validates it and prepares a change for review.",
858
854
  exportGenerate: "Generate and download",
859
855
  exportGenerating: "Generating\u2026",
860
856
  exportDone: "Downloaded {name}",
@@ -1417,6 +1413,27 @@ window.__ModuleLoader__.load({
1417
1413
  return project.stage ?? "unknown";
1418
1414
  }
1419
1415
 
1416
+ // src/progress.ts
1417
+ var clean = (value) => typeof value === "string" ? value.trim() : "";
1418
+ function canReportProgress(stage, status) {
1419
+ return clean(stage).toLowerCase() !== "closed" && !["\u5DF2\u5173\u95ED", "\u5DF2\u53D6\u6D88"].includes(clean(status));
1420
+ }
1421
+ function scenarioRoundViews(view, scenarioId) {
1422
+ if (!view.lines) return view.scenarioIds.includes(scenarioId) ? [view] : [];
1423
+ return view.lines.filter((line) => line.scenario_ids?.includes(scenarioId)).map((line) => ({
1424
+ ...view,
1425
+ goal: clean(line.title),
1426
+ actual: clean(line.actual),
1427
+ completion: clean(line.completion),
1428
+ scenarioIds: line.scenario_ids ?? [],
1429
+ criteriaIds: line.criteria_ids ?? [],
1430
+ evidence: (line.evidence ?? []).map((item) => ({ title: clean(item.title), link: clean(item.link), type: clean(item.type) })),
1431
+ customer: { syncedWith: clean(line.customer?.synced_with), feedback: clean(line.customer?.feedback), recognition: clean(line.review?.recognition) },
1432
+ gate3_1: clean(line.review?.gate3_1),
1433
+ gate3_2: clean(line.review?.gate3_2)
1434
+ }));
1435
+ }
1436
+
1420
1437
  // src/client/detail.tsx
1421
1438
  var import_react2 = require("react");
1422
1439
 
@@ -4236,7 +4253,29 @@ window.__ModuleLoader__.load({
4236
4253
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "prog-meter-value", children: entry.completion })
4237
4254
  ] })
4238
4255
  ] }),
4239
- entry.actual === "" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "prog-actual-line", "data-empty": "true", children: t("emptyField") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "prog-actual-line", children: entry.actual }),
4256
+ entry.lines === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "prog-actual-line", "data-empty": entry.actual === "", children: entry.actual || t("emptyField") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
4257
+ entry.lines.map((line, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dt-round-line", children: [
4258
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: line.title }),
4259
+ " \xB7 ",
4260
+ line.status,
4261
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "prose", children: line.actual }),
4262
+ line.customer?.feedback ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "prose", children: [
4263
+ t("dtScenarioCustomer"),
4264
+ "\uFF1A",
4265
+ line.customer.feedback
4266
+ ] }) : null,
4267
+ line.evidence?.length ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "prose", children: [
4268
+ t("dtScenarioEvidence"),
4269
+ "\uFF1A",
4270
+ line.evidence.map((e) => e.title).filter(Boolean).join(" \xB7 ")
4271
+ ] }) : null
4272
+ ] }, line.plan_id ?? itemIndex)),
4273
+ entry.stageNotes?.map((note) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "dt-round-line prose", children: [
4274
+ note.stage,
4275
+ " \xB7 ",
4276
+ note.text
4277
+ ] }, note.stage))
4278
+ ] }),
4240
4279
  entry.scenarioIds.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "chip-row prog-scope-row", children: entry.scenarioIds.map((id, itemIndex) => {
4241
4280
  const linked = scenarioNameOf(detail, id);
4242
4281
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "chip", children: linked === "" ? id : linked }, `${id}:${itemIndex}`);
@@ -4300,7 +4339,7 @@ window.__ModuleLoader__.load({
4300
4339
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Section, { title: t("dtScenarioTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, { text: t("dtScenarioNotFound") }) });
4301
4340
  }
4302
4341
  const tone = scenarioTone(scenario.status);
4303
- const entries = detail.progress.filter((entry) => entry.scenarioIds.includes(scenarioId)).slice().sort((left, right) => right.date === left.date ? (right.seq ?? 0) - (left.seq ?? 0) : right.date.localeCompare(left.date));
4342
+ const entries = detail.progress.flatMap((entry) => scenarioRoundViews(entry, scenarioId)).sort((left, right) => right.date === left.date ? (right.seq ?? 0) - (left.seq ?? 0) : right.date.localeCompare(left.date));
4304
4343
  const evidence = entries.flatMap((entry) => entry.evidence.map((item) => ({ ...item, date: entry.date })));
4305
4344
  const latestWithCustomer = entries.find((entry) => entry.customer.syncedWith !== "" || entry.customer.feedback !== "" || entry.customer.recognition !== "");
4306
4345
  const latest = entries[0];
@@ -4326,7 +4365,7 @@ window.__ModuleLoader__.load({
4326
4365
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-evidence-type", children: item.type === "" ? t("dtUnset") : item.type }),
4327
4366
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-evidence-title", children: item.title === "" ? t("emptyField") : item.title }),
4328
4367
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-evidence-date", children: item.date }),
4329
- item.link === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "sd-evidence-link", href: item.link, target: "_blank", rel: "noreferrer noopener", children: t("dtPlanScenarioDetail") })
4368
+ !/^(https?):\/\//i.test(item.link) ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "sd-evidence-link", href: item.link, target: "_blank", rel: "noreferrer noopener", children: t("dtPlanScenarioDetail") })
4330
4369
  ] }, `${item.title}:${index}`)) })
4331
4370
  ] }),
4332
4371
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "plan-block", children: [
@@ -4366,7 +4405,7 @@ window.__ModuleLoader__.load({
4366
4405
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "plan-block-title", children: t("dtScenarioLinked") }),
4367
4406
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "plan-block-note", children: format(t("dtProgressCountLabel"), { count: entries.length }) })
4368
4407
  ] }),
4369
- entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, { text: t("dtScenarioLinkedNone") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "sd-linked", children: entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "sd-linked-row", children: [
4408
+ entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, { text: t("dtScenarioLinkedNone") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "sd-linked", children: entries.map((entry, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "sd-linked-row", children: [
4370
4409
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-linked-date", children: entry.date }),
4371
4410
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "sd-linked-seq", children: [
4372
4411
  "#",
@@ -4374,7 +4413,7 @@ window.__ModuleLoader__.load({
4374
4413
  ] }),
4375
4414
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-linked-change", children: entry.change === "" ? t("dtUnset") : entry.change }),
4376
4415
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sd-linked-actual", children: entry.actual === "" ? t("emptyField") : entry.actual })
4377
- ] }, entry.seq ?? entry.date)) })
4416
+ ] }, `${entry.seq ?? entry.date}:${itemIndex}`)) })
4378
4417
  ] })
4379
4418
  ] });
4380
4419
  }
@@ -4533,7 +4572,8 @@ window.__ModuleLoader__.load({
4533
4572
  }
4534
4573
  function NextActionsPanel({ detail, t }) {
4535
4574
  const outcome = detail.outcome;
4536
- const newestNext = detail.progress.find((entry) => entry.next.goal !== "" || entry.next.owner !== "" || entry.next.deadline !== "");
4575
+ const latest = detail.progress.at(-1);
4576
+ const plans = latest?.nextPlans ?? (latest && (latest.next.goal || latest.next.owner || latest.next.deadline) ? [latest.next] : []);
4537
4577
  const rows = [];
4538
4578
  if (outcome.milestone !== "" || outcome.businessOwner !== "" || outcome.businessDeadline !== "") {
4539
4579
  rows.push({
@@ -4544,15 +4584,7 @@ window.__ModuleLoader__.load({
4544
4584
  tone: outcome.businessStatus === "\u5DF2\u8FDB\u5165\u4E0B\u4E00\u91CC\u7A0B\u7891" ? "green" : outcome.businessStatus === "" ? "slate" : "amber"
4545
4585
  });
4546
4586
  }
4547
- if (newestNext !== void 0) {
4548
- rows.push({
4549
- goal: newestNext.next.goal,
4550
- owner: newestNext.next.owner,
4551
- deadline: newestNext.next.deadline,
4552
- status: t("dtStatusNotStarted"),
4553
- tone: "slate"
4554
- });
4555
- }
4587
+ for (const plan of plans) rows.push({ ...plan, status: t("dtStatusNotStarted"), tone: "slate" });
4556
4588
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Section, { title: t("dtNextActionsTitle"), kicker: t("dtNextActionsKicker"), children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, { text: t("dtNextActionsNone") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { className: "next-table", children: [
4557
4589
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
4558
4590
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { children: t("dtNextGoal") }),
@@ -4611,27 +4643,27 @@ window.__ModuleLoader__.load({
4611
4643
  { key: "G1", label: "G1" },
4612
4644
  { key: "G2", label: "G2" },
4613
4645
  { key: "G3", label: "G3" },
4614
- { key: "G4", label: "G4" },
4615
- { key: "closed", label: "\u5DF2\u7ED3\u675F" }
4646
+ { key: "G4", label: "G4" }
4616
4647
  ];
4617
4648
  function ExportFormDialog({ api, projects, t, onClose, onError }) {
4618
4649
  const rows = (0, import_react3.useMemo)(
4619
- () => projects.map((project) => ({
4650
+ () => projects.filter((project) => !project.closed && canReportProgress(project.stageLabel, project.status)).map((project) => ({
4620
4651
  pocId: project.pocId,
4621
4652
  name: project.name,
4622
4653
  company: project.company,
4623
4654
  stage: project.stageLabel,
4624
- stageKey: project.closed ? "closed" : project.stage ?? "unknown"
4655
+ stageKey: project.stage ?? "unknown"
4625
4656
  })),
4626
4657
  [projects]
4627
4658
  );
4628
- const [intent, setIntent] = (0, import_react3.useState)("supplement");
4659
+ const [intent, setIntent] = (0, import_react3.useState)("progress");
4629
4660
  const [stageFilter, setStageFilter] = (0, import_react3.useState)(null);
4630
4661
  const visibleRows = (0, import_react3.useMemo)(
4631
4662
  () => stageFilter === null ? rows : rows.filter((row) => row.stageKey === stageFilter),
4632
4663
  [rows, stageFilter]
4633
4664
  );
4634
- const [selected, setSelected] = (0, import_react3.useState)(() => new Set(rows.map((row) => row.pocId)));
4665
+ const [selected, setSelected] = (0, import_react3.useState)(() => new Set(rows.length === 1 ? [rows[0].pocId] : []));
4666
+ const selectedIds = visibleRows.filter((row) => selected.has(row.pocId)).map((row) => row.pocId);
4635
4667
  const [busy, setBusy] = (0, import_react3.useState)(false);
4636
4668
  const toggle = (pocId) => {
4637
4669
  setSelected((current) => {
@@ -4644,10 +4676,11 @@ window.__ModuleLoader__.load({
4644
4676
  const selectAll = () => setSelected(new Set(visibleRows.map((row) => row.pocId)));
4645
4677
  const selectNone = () => setSelected(/* @__PURE__ */ new Set());
4646
4678
  const generate = async () => {
4679
+ if (intent === "progress" && selectedIds.length === 0) return;
4647
4680
  setBusy(true);
4648
4681
  try {
4649
4682
  const mode = intent === "new" ? "blank" : "fill";
4650
- const result = await api.exportForm(mode, mode === "blank" ? [] : [...selected], intent);
4683
+ const result = await api.exportForm(mode, mode === "blank" ? [] : selectedIds, intent);
4651
4684
  const blob = new Blob([result.html], { type: "text/html;charset=utf-8" });
4652
4685
  const url = URL.createObjectURL(blob);
4653
4686
  const anchor = document.createElement("a");
@@ -4688,7 +4721,6 @@ window.__ModuleLoader__.load({
4688
4721
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "modal-lead", children: t("exportSubtitle") }),
4689
4722
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "export-intent", role: "group", "aria-label": t("exportIntentLabel"), children: [
4690
4723
  { key: "new", label: t("exportIntentNew"), hint: t("exportIntentNewHint") },
4691
- { key: "supplement", label: t("exportIntentSupplement"), hint: t("exportIntentSupplementHint") },
4692
4724
  { key: "progress", label: t("exportIntentProgress"), hint: t("exportIntentProgressHint") }
4693
4725
  ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4694
4726
  "button",
@@ -4742,7 +4774,7 @@ window.__ModuleLoader__.load({
4742
4774
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "export-toolbar", children: [
4743
4775
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "btn btn-small", onClick: selectAll, disabled: busy, children: t("exportSelectAll") }),
4744
4776
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "btn btn-small", onClick: selectNone, disabled: busy, children: t("exportSelectNone") }),
4745
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "export-count", children: format(t("exportSelected"), { count: selected.size }) })
4777
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "export-count", children: format(t("exportSelected"), { count: selectedIds.length }) })
4746
4778
  ] })
4747
4779
  ] }),
4748
4780
  intent !== "new" && (rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "modal-lead", children: t("exportNoProjects") }) : visibleRows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "modal-lead", children: t("exportStageEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "export-list", children: visibleRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "export-row", "data-selected": selected.has(row.pocId), children: [
@@ -4764,7 +4796,7 @@ window.__ModuleLoader__.load({
4764
4796
  ] })
4765
4797
  ] })
4766
4798
  ] }) }, row.pocId)) })),
4767
- intent === "new" ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "helper-box", children: selected.size === 0 ? t("exportBlankHint") : t("exportHint") })
4799
+ intent === "new" ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "helper-box", children: selectedIds.length === 0 ? t("exportBlankHint") : t("exportHint") })
4768
4800
  ] }),
4769
4801
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "modal-footer", children: [
4770
4802
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "spacer" }),
@@ -4777,7 +4809,7 @@ window.__ModuleLoader__.load({
4777
4809
  onClick: () => {
4778
4810
  void generate();
4779
4811
  },
4780
- disabled: busy || intent !== "new" && selected.size === 0,
4812
+ disabled: busy || intent !== "new" && selectedIds.length === 0,
4781
4813
  children: busy ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
4782
4814
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "spinner" }),
4783
4815
  " ",
@@ -6659,6 +6691,10 @@ window.__ModuleLoader__.load({
6659
6691
  }
6660
6692
  .wd-shell .dt-body { display: flex; flex-direction: column; gap: 18px; }
6661
6693
 
6694
+ /* ---------- structured round items ---------- */
6695
+ .wd-shell .dt-round-line { margin: 8px 0; padding: 6px 0; border-top: 1px solid var(--wd-hairline); overflow-wrap: anywhere; }
6696
+ .wd-shell .dt-round-line .prose { margin: 4px 0 0; }
6697
+
6662
6698
  /* ---------- banner ---------- */
6663
6699
  .wd-shell .dt-header {
6664
6700
  display: grid;
package/lib/form.d.ts CHANGED
@@ -35,7 +35,7 @@
35
35
  * commits; submission stays a human-merged PR, which is the ledger's design.
36
36
  */
37
37
  import YAML from 'yaml';
38
- import type { PocRecord } from './types.js';
38
+ import type { PocRecord, ProgressRecord } from './types.js';
39
39
  /** The four G0 prerequisites that live under `gate0` (the fifth is identity). */
40
40
  export declare const G0_FIELDS: readonly ["why_customer", "why_us", "decision_chain", "post_poc_decision"];
41
41
  /** One plan criterion, as the form edits it. */
@@ -98,6 +98,35 @@ export interface FormProgress {
98
98
  deadline: string;
99
99
  };
100
100
  }
101
+ /**
102
+ * One already-recorded progress round, as the form shows it read-only.
103
+ *
104
+ * This exists because the form used to say only "已有 3 条进展" and never showed
105
+ * them. Two concrete failures came from that:
106
+ *
107
+ * - the colleague could not see what had already been reported, so the same
108
+ * round was filed twice under different wording;
109
+ * - the reviewer opening a returned form could not see the story the new round
110
+ * was supposed to continue, so "这次什么变了" was unverifiable.
111
+ *
112
+ * Read-only by construction: v3 history is append-only, and the form's job is to
113
+ * add a round, never to rewrite one.
114
+ */
115
+ export interface FormHistoryEntry {
116
+ seq: number | null;
117
+ date: string;
118
+ type: string;
119
+ change: string;
120
+ actual: string;
121
+ completion: string;
122
+ /** Evidence titles, already flattened: the form only lists them. */
123
+ evidence: string[];
124
+ syncedWith: string;
125
+ recognition: string;
126
+ nextGoal: string;
127
+ nextOwner: string;
128
+ nextDeadline: string;
129
+ }
101
130
  /**
102
131
  * The project shape the form edits.
103
132
  *
@@ -146,6 +175,14 @@ export interface FormProject {
146
175
  progress: FormProgress;
147
176
  /** How many entries the project already has (so `seq` can continue). */
148
177
  existingProgressCount: number;
178
+ /**
179
+ * The recorded rounds, newest first, for the read-only history block.
180
+ *
181
+ * Capped by {@link HISTORY_LIMIT}: a project with forty rounds does not need
182
+ * all forty in a form whose job is to add the forty-first, and an uncapped list
183
+ * would push the fields the colleague must fill below the fold.
184
+ */
185
+ history: FormHistoryEntry[];
149
186
  /**
150
187
  * The G4 conclusion block.
151
188
  *
@@ -219,6 +256,17 @@ export interface FormOptions {
219
256
  * empty one rather than `undefined`, so the generated script never has to guard.
220
257
  */
221
258
  export declare function projectForForm(record: PocRecord): FormProject;
259
+ /** How many recorded rounds the form lists read-only. */
260
+ export declare const HISTORY_LIMIT = 5;
261
+ /**
262
+ * Flatten the recorded rounds for the read-only history block.
263
+ *
264
+ * Newest first, because the round a colleague is about to continue is the newest
265
+ * one: reading it first is what makes "这次什么变了" answerable. The order is
266
+ * reversed rather than re-sorted by date because the ledger's own array order is
267
+ * the append order, and a hand-edited `date` must not reshuffle history.
268
+ */
269
+ export declare function progressHistory(progress: readonly ProgressRecord[]): FormHistoryEntry[];
222
270
  /** One empty progress entry, with `seq` continuing the existing count. */
223
271
  export declare function blankProgress(existingCount: number): FormProgress;
224
272
  /** The blank project a `blank`-mode form edits. */
@@ -317,17 +365,50 @@ export interface FormChangeSet {
317
365
  ready: string | null;
318
366
  };
319
367
  };
368
+ /**
369
+ * The G4 conclusion block.
370
+ *
371
+ * It was missing from the change set while the form could edit it, which meant a
372
+ * G4 colleague filled in "我们证明了什么 / 客户认可了什么 / 下一步业务动作",
373
+ * downloaded the file, and every one of those answers was silently dropped. The
374
+ * form showed the block; the serializer never wrote it. A G4 form could not
375
+ * record the only thing a G4 form exists to record.
376
+ */
377
+ outcome: {
378
+ achievement: string | null;
379
+ customer_recognition: string | null;
380
+ our_proof: string | null;
381
+ remaining_risks: string | null;
382
+ conclusion: {
383
+ proved: string | null;
384
+ recognized: string | null;
385
+ next_business: string | null;
386
+ };
387
+ business: {
388
+ milestone: string | null;
389
+ owner: string | null;
390
+ deadline: string | null;
391
+ status: string | null;
392
+ };
393
+ overall: string | null;
394
+ };
320
395
  /** The rounds this form ADDS; empty when the colleague recorded none. */
321
396
  progress: Array<Record<string, unknown>>;
322
397
  }
323
398
  /**
324
399
  * Build one project's change set from the form state.
325
400
  *
326
- * Every field the form can edit appears, so `poc-submit` can apply the whole
327
- * object with `setIfPresent` semantics: a blank field means "I did not change
328
- * this", which the merge step must not read as "delete it".
401
+ * Blocks outside the intent's scope are emitted as `null` (or an empty list), which
402
+ * `poc-submit` treats as "not changed" and skips. A blank field inside a block that
403
+ * IS in scope means the same thing: the colleague did not touch it.
404
+ *
405
+ * @param project the form's own view of the project
406
+ * @param intent what the colleague was asked to do; defaults to `supplement`, the
407
+ * widest scope, so an older caller keeps its previous behaviour
408
+ * @param baseline the project's values when the form was generated. When given,
409
+ * a field equal to its seed is emitted as `null` — "I did not touch this".
329
410
  */
330
- export declare function projectToChangeSet(project: FormProject): FormChangeSet;
411
+ export declare function projectToChangeSet(project: FormProject, intent?: FormIntent, baseline?: FormProject): FormChangeSet;
331
412
  /** The whole download: one change set per project, plus provenance. */
332
413
  export interface FormChangeDocument {
333
414
  schemaVersion: string;
@@ -341,6 +422,15 @@ export declare function buildChangeDocument(options: {
341
422
  projects: readonly FormProject[];
342
423
  intent: FormIntent;
343
424
  now?: Date;
425
+ /**
426
+ * The values each project had when the form was GENERATED.
427
+ *
428
+ * When supplied, only fields that differ from their seed are emitted — so a
429
+ * colleague who opened a form, changed one field and sent it back cannot revert
430
+ * the other twenty to the day the form was exported. See
431
+ * {@link projectToChangeSet}.
432
+ */
433
+ baseline?: readonly FormProject[];
344
434
  }): FormChangeDocument;
345
435
  /** The enums, mirrored from `schemas/enums.yaml`. */
346
436
  declare const ENUMS: {
@@ -391,6 +481,14 @@ export interface FormPayload {
391
481
  generatedAt: string;
392
482
  today: string;
393
483
  projects: FormProject[];
484
+ /**
485
+ * Each project's values at generation time, index-aligned with `projects`.
486
+ *
487
+ * The page compares against this before emitting a change set, so a field the
488
+ * colleague never touched is sent as "unchanged" rather than as its stale
489
+ * pre-filled value.
490
+ */
491
+ baseline: FormProject[];
394
492
  /**
395
493
  * Per-project section resolution, index-aligned with `projects`.
396
494
  *
@@ -411,6 +509,15 @@ export interface FormPayload {
411
509
  label: string;
412
510
  hint: string;
413
511
  }>;
512
+ /**
513
+ * The returned page's stylesheet.
514
+ *
515
+ * It is shipped in the payload rather than referenced from the page script
516
+ * because the page script is generated code with no module scope: it cannot see
517
+ * a Host constant, and a first attempt that assumed otherwise threw
518
+ * "RETURN_CSS is not defined" at the moment a colleague clicked the button.
519
+ */
520
+ returnCss: string;
414
521
  }
415
522
  /**
416
523
  * Generate the complete HTML form.
@@ -456,3 +563,35 @@ export interface FormCompatibility {
456
563
  * point is to inspect a document whose shape may be from an older generation.
457
564
  */
458
565
  export declare function checkFormCompatibility(payload: unknown): FormCompatibility;
566
+ /** The element id the returned page carries its change set in. */
567
+ export declare const RETURN_DATA_ID = "poc-return-data";
568
+ /** What reading a returned file produced. */
569
+ export interface ReturnReadResult {
570
+ /** The change document, or `null` when the file could not be read. */
571
+ document: FormChangeDocument | null;
572
+ /** A message safe to show the person who sent the file back. */
573
+ reason: string;
574
+ }
575
+ /**
576
+ * Read a returned form — either the `.html` this generator emits or a `.json`
577
+ * change set — back into a change document.
578
+ *
579
+ * ## Why both formats, and why HTML is the default
580
+ *
581
+ * The documented workflow is "colleague fills it in and sends the HTML back on
582
+ * WeChat". That only works if the returned HTML actually carries the answers, so
583
+ * {@link buildFormHtml}'s page writes a `RETURN_DATA_ID` script block holding the
584
+ * exact change set. The same page is also readable by a human: it renders the
585
+ * answers as formatted HTML, so the person who receives it can see what was
586
+ * submitted before handing it to DSH.
587
+ *
588
+ * The `.json` path is kept because it is stricter and smaller, and because forms
589
+ * already in circulation emit it.
590
+ *
591
+ * ## Safety
592
+ *
593
+ * The HTML is never executed and never given to a DOM parser: the block is found
594
+ * with a string search and the slice is handed to `JSON.parse`. Nothing in the
595
+ * returned file can run.
596
+ */
597
+ export declare function readReturnDocument(input: string): ReturnReadResult;