SHOULD NOT MERGE : EEC-149: Add custom behaviour for problem selections routing. - #101
Draft
anjurajanHO wants to merge 6 commits into
Draft
SHOULD NOT MERGE : EEC-149: Add custom behaviour for problem selections routing.#101anjurajanHO wants to merge 6 commits into
anjurajanHO wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a canonical “problem” ordering and uses it to drive deterministic routing (forks) and back-link behaviour across the eVisa problem sub-journey, including edit-journey handling and summary formatting tweaks.
Changes:
- Adds canonical problem ordering + utilities to map problem keys ⇄ routes and compute ordering/owned fields.
- Replaces the large hardcoded
/problemfork list with generated forks and adds edit-safe behaviours (problem selection snapshot + deterministic back link). - Updates check-answers summary formatting to better present corrected details (including combined name fields and problem selection display).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/problem-order.js | Defines canonical ordered list of eVisa problems and their target routes. |
| utils/problem-utils.js | Adds ordering/lookup utilities and “owned field” resolution for problems. |
| utils/build-problem-forks.js | Generates ordered fork conditions to route to the next eligible selected problem (incl. edit-journey logic). |
| utils/index.js | Exports new joinNonEmpty helper for consistent string assembly. |
| apps/eec/index.js | Switches problem routing to generated forks and wires in new behaviours across problem-related steps. |
| apps/eec/behaviours/capture-problem-selection.js | Snapshots/restores problem-owned values across edit submissions to prevent unintended clearing. |
| apps/eec/behaviours/problem-back-link.js | Overrides back-link resolution for problem journey routes based on selected problems and canonical order. |
| apps/eec/sections/summary-data-sections.js | Updates summary parsing/formatting for corrected details and problem selection output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+22
to
+28
| const getProblemOrder = key => { | ||
| if (!key) { | ||
| return 0; | ||
| } | ||
|
|
||
| return PROBLEM_ORDER_BY_KEY[key]; | ||
| }; |
Comment on lines
+46
to
+50
| const getFieldsForProblemKey = (req, problemKey) => { | ||
| const targetRoute = PROBLEM_KEY_TO_TARGET_ROUTE[problemKey]; | ||
| const steps = req.form && req.form.options ? req.form.options.steps : null; | ||
| const sessionSteps = toArray(req.sessionModel.get('steps')); | ||
|
|
Comment on lines
+62
to
+69
| successHandler(req, res) { | ||
| const params = req.params || {}; | ||
| const isEditJourney = Boolean(params.edit || params.action === 'edit'); | ||
|
|
||
| this.emit('complete', req, res); | ||
|
|
||
| if (isEditJourney) { | ||
| const currentSelection = toArray(req.sessionModel.get('problem')); |
Comment on lines
+83
to
+85
| if ((currentValue === undefined || currentValue === null || currentValue === '') && previousValue) { | ||
| req.sessionModel.set(fieldName, previousValue); | ||
| } |
| }); | ||
| } | ||
|
|
||
| res.redirect(this.getNextStep(req, res)); |
| return new Intl.DateTimeFormat(config.dateLocales, config.dateFormat).format(dateObj); | ||
| }; | ||
|
|
||
| const joinNonEmpty = (values, separator = ' ') => values.filter(Boolean).join(separator); |
Comment on lines
+59
to
+65
| // Find the next selected problem after the current step, preferring incomplete | ||
| // edit-step targets before newly selected later problems. | ||
| const nextSelectedProblem = (req, afterKey = null) => { | ||
| const selected = new Set(getProblemSelection(req)); | ||
| const editJourney = isProblemEditJourney(req); | ||
| const preEditSelected = new Set(getPreEditProblemSelection(req)); | ||
| const afterOrder = getProblemOrder(afterKey); |
Comment on lines
+99
to
+112
| module.exports = superclass => class extends superclass { | ||
| // Override controller back-link resolution for problem-journey routes. | ||
| getBackLink(req, res) { | ||
| const route = req.form && req.form.options ? normaliseRoute(req.form.options.route) : null; | ||
|
|
||
| if (isProblemRelatedRoute(route)) { | ||
| const backLink = getProblemBackLink(req); | ||
| if (backLink) { | ||
| res.locals.backLink = backLink; | ||
| } | ||
| } | ||
|
|
||
| return super.getBackLink(req, res); | ||
| } |
Comment on lines
+30
to
+44
| const toArray = value => { | ||
| if (!value) { | ||
| return []; | ||
| } | ||
|
|
||
| if (Array.isArray(value)) { | ||
| return value; | ||
| } | ||
|
|
||
| if (typeof value === 'string') { | ||
| return value.split(',').map(item => item.trim()).filter(Boolean); | ||
| } | ||
|
|
||
| return [value]; | ||
| }; |
anjurajanHO
force-pushed
the
EEC-149-evisa-problems-route
branch
from
July 29, 2026 17:28
9a625f0 to
45c4d55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Why?
How?
Testing?
Screenshots (optional)
Anything Else? (optional)
Check list