Skip to content

SHOULD NOT MERGE : EEC-149: Add custom behaviour for problem selections routing. - #101

Draft
anjurajanHO wants to merge 6 commits into
eec-phase-4-releasefrom
EEC-149-evisa-problems-route
Draft

SHOULD NOT MERGE : EEC-149: Add custom behaviour for problem selections routing.#101
anjurajanHO wants to merge 6 commits into
eec-phase-4-releasefrom
EEC-149-evisa-problems-route

Conversation

@anjurajanHO

Copy link
Copy Markdown
Contributor

What?

Why?

How?

Testing?

Screenshots (optional)

Anything Else? (optional)

Check list

  • I have reviewed my own pull request
  • I have written tests (if relevant)

@anjurajanHO
anjurajanHO requested review from Copilot and dk4g July 15, 2026 18:31
@anjurajanHO anjurajanHO changed the title Eec 149 evisa problems route EEC-149: Add custom behaviour for problem selections routing. Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 /problem fork 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 thread utils/problem-utils.js
Comment on lines +22 to +28
const getProblemOrder = key => {
if (!key) {
return 0;
}

return PROBLEM_ORDER_BY_KEY[key];
};
Comment thread utils/problem-utils.js
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));
Comment thread utils/index.js
return new Intl.DateTimeFormat(config.dateLocales, config.dateFormat).format(dateObj);
};

const joinNonEmpty = (values, separator = ' ') => values.filter(Boolean).join(separator);
Comment thread utils/build-problem-forks.js Outdated
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 thread utils/problem-utils.js
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 anjurajanHO changed the title EEC-149: Add custom behaviour for problem selections routing. NOT IN USE: EEC-149: Add custom behaviour for problem selections routing. Jul 27, 2026
@anjurajanHO anjurajanHO changed the title NOT IN USE: EEC-149: Add custom behaviour for problem selections routing. SHOULD NOT MERGE : EEC-149: Add custom behaviour for problem selections routing. Jul 27, 2026
@anjurajanHO
anjurajanHO force-pushed the EEC-149-evisa-problems-route branch from 9a625f0 to 45c4d55 Compare July 29, 2026 17:28
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