@eintrek/erp-shell 0.1.70 → 0.1.72

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 CHANGED
@@ -176,6 +176,18 @@ progress API: `API.md` next to it.
176
176
  shell's adapters), `guide-ui.tsx`, `guide-styles.ts`. Tests:
177
177
  `src/guide/*.test.ts`.
178
178
 
179
+ ### 0.1.72
180
+
181
+ - "ขั้นที่ x/y" counts only the steps this person will see: a step whose
182
+ `requires` they lack or whose `skipIf` holds is left out (Plannex mission 3
183
+ said 1/6 and ended at 5/6).
184
+
185
+ ### 0.1.71
186
+
187
+ - Escape on the finish card closes it where the person is. Only the button
188
+ follows `complete.action`, which may lead to another app (Platform's finish
189
+ goes to Peoplx).
190
+
179
191
  ### 0.1.70
180
192
 
181
193
  - `GuideSuite.reopenHint`: what the skip and exit confirms say about
@@ -727,11 +727,34 @@ function announceStep(d, suite, env) {
727
727
  const ctx = guideContext(env, d.state.progress.context, routeParamsFor(step, env));
728
728
  const title = s.bridge ? COPY.bridgeTitle : plainTitle(resolveText(step.title, ctx));
729
729
  const why = s.bridge ? COPY.bridgeWhy(suite.appName) : plainTitle(resolveText(step.why, ctx));
730
+ const pos = stepPosition(mission, s.index, env, d.state.progress.context);
730
731
  d.effects.push({
731
732
  type: "announce",
732
- text: `ขั้นที่ ${s.index + 1} จาก ${mission.steps.length}. ${title}${why ? `. ${why}` : ""}`,
733
+ text: `ขั้นที่ ${pos.no} จาก ${pos.total}. ${title}${why ? `. ${why}` : ""}`,
733
734
  });
734
735
  }
736
+ /**
737
+ * "ขั้นที่ no จาก total" counting only the steps this person will see: a step
738
+ * whose `requires` they lack or whose `skipIf` holds is left out (the step on
739
+ * screen always counts).
740
+ */
741
+ function stepPosition(mission, index, env, context) {
742
+ let no = 0;
743
+ let total = 0;
744
+ mission.steps.forEach((step, i) => {
745
+ if (i !== index) {
746
+ if (step.requires && !safe(() => env.can(step.requires), true))
747
+ return;
748
+ const ctx = guideContext(env, context, routeParamsFor(step, env));
749
+ if (step.skipIf && safe(() => step.skipIf(ctx), false))
750
+ return;
751
+ }
752
+ total++;
753
+ if (i <= index)
754
+ no = total;
755
+ });
756
+ return { no: Math.max(no, 1), total: Math.max(total, 1) };
757
+ }
735
758
  /** "กด [บันทึก]" → "กด บันทึก" (for screen readers). */
736
759
  function plainTitle(t) {
737
760
  return t.replace(/\[([^\]]+)\]/g, "$1");
@@ -1453,6 +1476,11 @@ function reduceGuide(state, action, suite, env) {
1453
1476
  d.effects.push({ type: "navigate", href: filled });
1454
1477
  break;
1455
1478
  }
1479
+ case "dismissComplete":
1480
+ if (s.name !== "complete")
1481
+ break;
1482
+ setScreen(d, { name: "idle" });
1483
+ break;
1456
1484
  case "openPanel":
1457
1485
  if (state.audience !== "none" && s.name === "idle") {
1458
1486
  d.state = { ...d.state, panelOpen: true };
@@ -3566,8 +3594,10 @@ function GuideRuntimeInner({ config, organizationId, code, routing, progress: pr
3566
3594
  dispatchRef.current({ type: "rest" });
3567
3595
  }
3568
3596
  else if (sc.name === "complete") {
3597
+ // Escape closes the card where the person is; only the button
3598
+ // follows complete.action, which may be another app.
3569
3599
  stop();
3570
- dispatchRef.current({ type: "finish" });
3600
+ dispatchRef.current({ type: "dismissComplete" });
3571
3601
  }
3572
3602
  else if (s.panelOpen) {
3573
3603
  stop();
@@ -3782,8 +3812,9 @@ function GuideRuntimeInner({ config, organizationId, code, routing, progress: pr
3782
3812
  missionNo,
3783
3813
  missionTitle: mission.title,
3784
3814
  replay: screen.replay,
3785
- index: screen.index,
3786
- total: mission.steps.length,
3815
+ // Steps this person skips (requires / skipIf) are not counted.
3816
+ index: stepPosition(mission, screen.index, env(), state.progress.context).no - 1,
3817
+ total: stepPosition(mission, screen.index, env(), state.progress.context).total,
3787
3818
  title: bridge ? "กดปุ่มเมนู" : resolveText(step.title, stepCtx),
3788
3819
  why: bridge ? `เมนูทั้งหมดของ ${suite.appName} อยู่ในนี้` : resolveText(step.why, stepCtx),
3789
3820
  error: screen.error,
@@ -3840,4 +3871,4 @@ function useFactsKey(facts) {
3840
3871
  }
3841
3872
 
3842
3873
  export { API_EVENT as A, GUIDE_EVENT_PREFIX as G, GUIDE_LAYER_ATTRIBUTE as a, GuideErrorBoundary as b, GuideProgressConflict as c, GuideRuntime as d, apiCallDetail as e, emitGuideEvent as f, fillRoute as g, guideAnchor as h, matchRoute as i, reportApiEvent as j, loadGuides as l, matchApiPath as m, openGuidePanel as o, reportApiCall as r, storeGuides as s, useGuideEntry as u };
3843
- //# sourceMappingURL=guide-runtime-CUCcs6q0.esm.js.map
3874
+ //# sourceMappingURL=guide-runtime-B-3myqxe.esm.js.map