@eintrek/erp-shell 0.1.71 → 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,12 @@ 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
+
179
185
  ### 0.1.71
180
186
 
181
187
  - Escape on the finish card closes it where the person is. Only the button
@@ -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");
@@ -3789,8 +3812,9 @@ function GuideRuntimeInner({ config, organizationId, code, routing, progress: pr
3789
3812
  missionNo,
3790
3813
  missionTitle: mission.title,
3791
3814
  replay: screen.replay,
3792
- index: screen.index,
3793
- 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,
3794
3818
  title: bridge ? "กดปุ่มเมนู" : resolveText(step.title, stepCtx),
3795
3819
  why: bridge ? `เมนูทั้งหมดของ ${suite.appName} อยู่ในนี้` : resolveText(step.why, stepCtx),
3796
3820
  error: screen.error,
@@ -3847,4 +3871,4 @@ function useFactsKey(facts) {
3847
3871
  }
3848
3872
 
3849
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 };
3850
- //# sourceMappingURL=guide-runtime-BTatpm-V.esm.js.map
3874
+ //# sourceMappingURL=guide-runtime-B-3myqxe.esm.js.map