Documentation
¶
Overview ¶
Package pageflow contains experimental helpers for multi-step page flows.
Index ¶
- type PageFlow
- func (f *PageFlow) AllPreviousValidated(session *SessionData) bool
- func (f *PageFlow) CurrentStep(session *SessionData) *Step
- func (f *PageFlow) FindStep(name string) int
- func (f *PageFlow) FirstStep() *Step
- func (f *PageFlow) Next(session *SessionData) bool
- func (f *PageFlow) Prev(session *SessionData) bool
- func (f *PageFlow) SetCurrentStep(session *SessionData, stepName string) bool
- type SessionData
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PageFlow ¶
type PageFlow struct {
Steps []Step
}
PageFlow contains the ordered steps for a flow.
func (*PageFlow) AllPreviousValidated ¶
func (f *PageFlow) AllPreviousValidated(session *SessionData) bool
AllPreviousValidated reports whether every step before the current one passed validation.
func (*PageFlow) CurrentStep ¶
func (f *PageFlow) CurrentStep(session *SessionData) *Step
CurrentStep returns the active step for a session.
func (*PageFlow) Next ¶
func (f *PageFlow) Next(session *SessionData) bool
Next moves a session to the next step.
func (*PageFlow) Prev ¶
func (f *PageFlow) Prev(session *SessionData) bool
Prev moves a session to the previous step.
func (*PageFlow) SetCurrentStep ¶
func (f *PageFlow) SetCurrentStep(session *SessionData, stepName string) bool
SetCurrentStep moves a session to a named step when it exists.
type SessionData ¶
type SessionData struct {
StepData map[string]map[string]any
Validated map[string]bool
Current string
}
SessionData stores per-session progress and data for a PageFlow.
SessionData is mutable session state. Do not share one SessionData value across goroutines without external synchronization.
func (*SessionData) GetAllData ¶
func (session *SessionData) GetAllData() map[string]any
GetAllData returns all step data merged into one map.
func (*SessionData) GetStepData ¶
func (session *SessionData) GetStepData(stepName string) map[string]any
GetStepData returns stored data for a step.
func (*SessionData) SetStepData ¶
func (session *SessionData) SetStepData(stepName string, data map[string]any)
SetStepData stores data for a step.
func (*SessionData) SetStepValidated ¶
func (session *SessionData) SetStepValidated(stepName string, valid bool)
SetStepValidated stores the validation state for a step.