* Die Schritte, so gruppiert, wie der Block sie gruppiert. * * Genau die Zeilen des Dokuments, in genau seiner Reihenfolge: die * Ueberschriften als Ueberschrift, die nummerierten Zeilen als Halt des * Steppers, und die Saetze ueber leere Gruppen als das, was sie sind. Die * Zuordnung Zeile zu
(props: {
flow: FlowView;
step: number;
onStep: (index: number) => void;
})
| 679 | * dieselbe Nummerierung benutzen und nicht zwei. |
| 680 | */ |
| 681 | function StepList(props: { |
| 682 | flow: FlowView; |
| 683 | step: number; |
| 684 | onStep: (index: number) => void; |
| 685 | }): JSX.Element { |
| 686 | const stepByLine = new Map<number, number>(); |
| 687 | props.flow.steps.forEach((step, index) => stepByLine.set(step.lineIndex, index)); |
| 688 | return ( |
| 689 | <ol className="atlas-flow-step-list" data-testid="atlas-flow-step-list"> |
| 690 | {props.flow.document.lines.map((line, lineIndex) => { |
| 691 | if (line.kind === 'group') { |
| 692 | return ( |
| 693 | <li |
| 694 | className="atlas-flow-step-group" |
| 695 | data-testid="atlas-flow-group" |
| 696 | data-group={line.group} |
| 697 | key={`group-${lineIndex}`} |
| 698 | > |
| 699 | {line.text} |
| 700 | </li> |
| 701 | ); |
| 702 | } |
| 703 | if (line.kind === 'note') { |
| 704 | return ( |
| 705 | <li |
| 706 | className="atlas-flow-step-absence" |
| 707 | data-testid="atlas-flow-absence" |
| 708 | data-group={line.group} |
| 709 | key={`note-${lineIndex}`} |
| 710 | > |
| 711 | {line.text} |
| 712 | </li> |
| 713 | ); |
| 714 | } |
| 715 | const index = stepByLine.get(lineIndex) ?? -1; |
| 716 | const active = index >= 0 && index === props.step; |
| 717 | return ( |
| 718 | <li |
| 719 | className="atlas-flow-step" |
| 720 | data-testid="atlas-flow-step" |
| 721 | data-step={index} |
| 722 | data-kind={line.kind} |
| 723 | data-active={active} |
| 724 | data-alarm={line.kind === 'raise'} |
| 725 | ref={active ? scrollIntoView : undefined} |
| 726 | key={`step-${lineIndex}`} |
| 727 | > |
| 728 | <Hint name="flow-step-line" text={PSEUDOCODE_LINE_TOOLTIP}> |
| 729 | <button |
| 730 | type="button" |
| 731 | className="atlas-flow-step-line" |
| 732 | data-testid="atlas-flow-step-button" |
| 733 | onClick={() => props.onStep(index)} |
| 734 | > |
| 735 | {line.text} |
| 736 | </button> |
| 737 | </Hint> |
| 738 | </li> |