Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/485768 page conditions #669

Merged
merged 10 commits into from
Jan 21, 2025
Merged

Conversation

davidjamesstone
Copy link
Contributor

No description provided.

Copy link
Contributor

@alexluckett alexluckett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. If this gets more complicated, we should look at splitting out our v1/v2 engine logic into separate encapsulated functions and using something like the strategy pattern to switch between the logic for engine v1/v2 depending on the form definition's engine version.

e.g.

engineStrategies.js

class EngineStrategyV1 {
    getNextPath(defaultPath) { }
    // anything else we need
}

class EngineStrategyV2 {
    getNextPath(defaultPath) { }
    // anything else we need
}

QuestionPageController.ts

getNextPath(context: FormContext) {
    const { model, next, path } = this
    const { evaluationState } = context
    const summaryPath = this.getSummaryPath()
    const statusPath = this.getStatusPath()

    // Walk from summary page (no next links) to status page
    let defaultPath = path === summaryPath ? statusPath : undefined

    return engineStrategy.getNextPath() // engineStrategy would be passed in ideally as a dependency in the constructor
}

questionPageController = new QuestionPageController(engineStrategy) // engineStrategy is either EngineStrategyV1 or EngineStrategyV2 based on model.engine

@davidjamesstone davidjamesstone marked this pull request as ready for review January 21, 2025 13:22
@@ -24,7 +24,7 @@
{% include "partials/heading.html" %}

{% block form %}
{% if page.next | length %}
{% if page.allowContinue %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👌

@davidjamesstone davidjamesstone merged commit 83ba365 into main Jan 21, 2025
12 checks passed
@davidjamesstone davidjamesstone deleted the feature/485768-page-conditions branch January 21, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants