diff --git a/app/views/cases/indictment/assign/defendants.html b/app/views/cases/indictment/assign/defendants.html index 5219a84c..fe686cc9 100644 --- a/app/views/cases/indictment/assign/defendants.html +++ b/app/views/cases/indictment/assign/defendants.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Assign defendants' %} +{% set pageName = 'Select defendants for count' %} {% block beforeContent %} {{ govukBackLink({ @@ -18,10 +18,14 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

-

Select all defendants that apply to this count

+

Select all that apply

{% if returnTo %} diff --git a/app/views/cases/indictment/assign/victims.html b/app/views/cases/indictment/assign/victims.html index d989e45a..43854cc3 100644 --- a/app/views/cases/indictment/assign/victims.html +++ b/app/views/cases/indictment/assign/victims.html @@ -2,7 +2,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Assign victims' %} +{% set pageName = 'Select victims for count' %} {% block beforeContent %} {{ govukBackLink({ @@ -17,10 +17,14 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

-

Select all victims that apply to this count

+

Select all that apply

{% if returnTo %} diff --git a/app/views/cases/indictment/assign/witnesses.html b/app/views/cases/indictment/assign/witnesses.html index 8bfe9a48..a72d2b48 100644 --- a/app/views/cases/indictment/assign/witnesses.html +++ b/app/views/cases/indictment/assign/witnesses.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Assign witnesses' %} +{% set pageName = 'Select witnesses for count' %} {% block beforeContent %} {{ govukBackLink({ @@ -18,10 +18,14 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

-

Select all witnesses that apply to this count

+

Select all that apply

{% if returnTo %} diff --git a/app/views/cases/indictment/counts/added/index.html b/app/views/cases/indictment/counts/added/index.html index 3eccdac2..259d0124 100644 --- a/app/views/cases/indictment/counts/added/index.html +++ b/app/views/cases/indictment/counts/added/index.html @@ -29,7 +29,7 @@ }) }} {% endif %} - Build indictment + {{_case.reference}} - Indictments

{{ pageName }}

diff --git a/app/views/cases/indictment/counts/charges.html b/app/views/cases/indictment/counts/charges.html index 4ddda474..dccb946c 100644 --- a/app/views/cases/indictment/counts/charges.html +++ b/app/views/cases/indictment/counts/charges.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Charges' %} +{% set pageName = 'Select charges for indictment' %} {% block beforeContent %} {{ govukBackLink({ @@ -17,8 +17,13 @@
+ - Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

diff --git a/app/views/cases/indictment/counts/check.html b/app/views/cases/indictment/counts/check.html index 5e9516c4..fc00634b 100644 --- a/app/views/cases/indictment/counts/check.html +++ b/app/views/cases/indictment/counts/check.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Check and edit count' %} +{% set pageName = 'Check count details' %} {% block beforeContent %} {{ govukBackLink({ @@ -18,7 +18,11 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{# ---------------------------- @@ -170,7 +174,7 @@

{{ pageName }}

{% set _ = rows.push({ - key: { text: "Precedent charge or offence" }, + key: { text: "Precedent" }, value: precedentRowValue, actions: { items: [{ @@ -208,7 +212,7 @@

{{ pageName }}

{# Particulars #} {% set _ = rows.push({ - key: { text: "Particulars" }, + key: { text: "Particulars of offence" }, value: { text: particularsDisplay }, actions: { items: [{ diff --git a/app/views/cases/indictment/counts/date-and-charges.html b/app/views/cases/indictment/counts/date-and-charges.html index 31ff736d..25c4019c 100644 --- a/app/views/cases/indictment/counts/date-and-charges.html +++ b/app/views/cases/indictment/counts/date-and-charges.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Charge and date' %} +{% set pageName = 'Select charge for count' %} {% block beforeContent %} {{ govukBackLink({ @@ -17,7 +17,11 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

diff --git a/app/views/cases/indictment/counts/offence-and-particulars.html b/app/views/cases/indictment/counts/offence-and-particulars.html index 07bbad04..d4afd9d3 100644 --- a/app/views/cases/indictment/counts/offence-and-particulars.html +++ b/app/views/cases/indictment/counts/offence-and-particulars.html @@ -115,6 +115,15 @@ {% set dateNarrative = dayNum + suffix + " day of " + (months[monthIdx] or "[month]") + " " + yearVal %} {% endif %} + {# ✅ Unified token date: + - single => narrative ("11th day of November 2025") + - range => numeric range ("01/01/25 to 02/01/25") + #} + {% set dateForToken = dateText %} + {% if draftCount.dateType == "single" %} + {% set dateForToken = dateNarrative %} + {% endif %} + {# ------------------------------------------------------------ Location string ------------------------------------------------------------ #} @@ -145,13 +154,24 @@ {% set primaryChargeText = draftCount.chargeLabel or statementCardText %}
+ {##############################################################################################} + {############################# LEFT (2/3) — Statement of offence + particulars #################} + {##############################################################################################}
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{% if returnTo %}{% endif %} + {# ========================= + Statement of offence (editable) + - Prefill from selected charge (date-and-charges) unless user has typed their own. + ========================= #} {{ govukTextarea({ id: "statementOfOffenceText", name: "statementOfOffenceText", @@ -163,6 +183,9 @@

{{ pageName }}

rows: 8 }) }} + {# ========================= + Read-only summary card (single selected charge from date-and-charges) + ========================= #}

Statement of Offence

@@ -179,9 +202,16 @@

Statement of Offence

+ {# ========================= + Particulars of offence (editable) + ========================= #}

Particulars of offence

Edit to match case. View particulars in the sidebar.

+ {# ------------------------------------------------------------ + Build tokens (actors, date, place) for template injection + Research ordering: DEFENDANT(s), DATE, VICTIM(s) + ------------------------------------------------------------ #} {% set defendantsText = "[DEFENDANT(S)]" %} {% if defendantNames and defendantNames.length %} {% set defendantsText = (defendantNames | join(" and ")) | upper %} @@ -194,13 +224,20 @@

Particulars of offence

{% set placeForTemplate = locationText or "[place]" %} + {# ------------------------------------------------------------ + Particulars Starter (chosen at /precedent-charges-or-offence/continue) + Expectation: draftCount.particularsStarter contains something like: + "[Defendant(s)] [date] at [place], used threatening behaviour..." + ------------------------------------------------------------ #} {% set particularsStarter = draftCount.particularsStarter or "" %} {% set particularsFromStarter = particularsStarter %} + {# Token injection (simple, case-insensitive-ish by covering common variants) #} {% if particularsFromStarter %} {% set particularsFromStarter = particularsFromStarter | replace("[Defendant(s)]", defendantsText) %} {% set particularsFromStarter = particularsFromStarter | replace("[defendant(s)]", defendantsText) %} + {# Fallback: starter text often says “the defendant” instead of using tokens #} {% set particularsFromStarter = particularsFromStarter | replace("the defendant", defendantsText) %} {% set particularsFromStarter = particularsFromStarter | replace("The defendant", defendantsText) %} @@ -210,25 +247,51 @@

Particulars of offence

{% set particularsFromStarter = particularsFromStarter | replace("[Place]", placeForTemplate) %} {% set particularsFromStarter = particularsFromStarter | replace("[place]", placeForTemplate) %} - {% set particularsFromStarter = particularsFromStarter | replace("[Date]", dateNarrative) %} - {% set particularsFromStarter = particularsFromStarter | replace("[date]", dateNarrative) %} + {# ✅ use unified date token #} + {% set particularsFromStarter = particularsFromStarter | replace("[Date]", dateForToken) %} + {% set particularsFromStarter = particularsFromStarter | replace("[date]", dateForToken) %} {% endif %} - {% set fallbackDate = "[DATE]" %} - {% if dateText and dateText != "xx/xx/xx" %} - {% set fallbackDate = dateText %} + {# ------------------------------------------------------------ + Optional starter normaliser (light-touch): + If a template begins with "On ..." prepend defendants/date/victims + to match research ordering without rewriting the whole template. + ------------------------------------------------------------ #} + {% if particularsFromStarter %} + {% set lowerStarter = particularsFromStarter | lower %} + {% set lowerDate = (dateForToken or "") | lower %} + + {% if lowerDate and ( + lowerStarter.indexOf("on " + lowerDate) == 0 + or lowerStarter.indexOf("on the " + lowerDate) == 0 + ) %} + {% set particularsFromStarter = + defendantsText + ", on " + dateForToken + ", " + victimsText + ", " + particularsFromStarter + %} + {% endif %} {% endif %} + {# ------------------------------------------------------------ + Fallback suggested particulars if no library template selected + Research ordering: DEFENDANT(s), DATE, VICTIM(s) + ------------------------------------------------------------ #} {% set offenceForFallback = "[OFFENCE]" %} {% if primaryChargeText %} {% set offenceForFallback = primaryChargeText | lower %} {% endif %} {% set suggestedParticulars = - defendantsText + ", on " + fallbackDate + " at " + placeForTemplate + ", " + - offenceForFallback + " " + victimsText + " of [PROPERTY]" + defendantsText + ", on " + (dateText if (dateText and dateText != "xx/xx/xx") else "[DATE]") + ", " + + victimsText + ", at " + placeForTemplate + ", " + + offenceForFallback + " of [PROPERTY]" %} + {# ------------------------------------------------------------ + Decide what goes in the textarea: + 1) User-typed value (persisted) + 2) Template-driven starter (if selected) + 3) Fallback suggestion + ------------------------------------------------------------ #} {% set particularsValue = draftCount.particularsOfOffenceText or "" %} {% if not particularsValue %} {% if particularsFromStarter %} @@ -238,6 +301,10 @@

Particulars of offence

{% endif %} {% endif %} + {# ------------------------------------------------------------ + Patch older saved textarea values that still say “the defendant” + (only if names exist and the names aren’t already in the text) + ------------------------------------------------------------ #} {% if defendantNames and defendantNames.length %} {% set firstDefName = defendantNames[0] %} {% set lowerParticulars = (particularsValue or "") | lower %} @@ -251,16 +318,39 @@

Particulars of offence

{# ------------------------------------------------------------ ✅ FINAL DATE TOKEN PATCH (applies to saved values too) ------------------------------------------------------------ #} - {% set dateForToken = dateText %} - {% if draftCount.dateType == "single" %} - {% set dateForToken = dateNarrative %} - {% endif %} - {% if particularsValue %} {% set particularsValue = particularsValue | replace("[Date]", dateForToken) %} {% set particularsValue = particularsValue | replace("[date]", dateForToken) %} {% endif %} + {# ------------------------------------------------------------ + ✅ Enforce research ordering in textarea: + DEFENDANT(s), DATE, VICTIM(s) + If text begins "On ...", move defendants to the front. + ------------------------------------------------------------ #} + + {% set lowerParticulars = (particularsValue or "") | lower %} + {% set lowerDef = (defendantsText or "") | lower %} + + {# Only do this if it starts with "on " AND does not already start with the defendant(s) #} + {% if lowerParticulars.indexOf("on ") == 0 and (lowerDef and lowerParticulars.indexOf(lowerDef) != 0) %} + + {# Remove leading "On " / "on " #} + {% set remainder = particularsValue | replace("On ", "") %} + {% set remainder = remainder | replace("on ", "") %} + + {# Remove first “defendant chunk” where it appears later (common patterns) #} + {% set remainder = remainder | replace(defendantsText + " ", "") %} + {% set remainder = remainder | replace(defendantsText + ", ", "") %} + {% set remainder = remainder | replace(" " + defendantsText + " ", " ") %} + {% set remainder = remainder | replace(" " + defendantsText + ", ", " ") %} + + {# Rebuild: DEFENDANT(s), on #} + {% set particularsValue = defendantsText + ", on " + (remainder | trim) %} + + {% endif %} + + {{ govukTextarea({ id: "particularsOfOffenceText", name: "particularsOfOffenceText", @@ -291,8 +381,92 @@

Particulars of offence

+ {##############################################################################################} + {############################# RIGHT (1/3) — selected charge + details list ###################} + {##############################################################################################}
- {# ... right column unchanged ... #} + +

Charge

+ +

+ {% if defendantNames.length %} + {{ defendantNames | join(" and ") }} + {% else %} + [DEFENDANT(S)] + {% endif %} + on {{ dateText }} at {{ locationText }} + {% if primaryChargeText %} + {{ primaryChargeText | lower }} + {% endif %} + {% if victimNames.length %} + {{ victimNames | join(" and ") }} + {% else %} + [VICTIM] + {% endif %}. +

+ + {# ------------------------------------------------------------ + Details: All related charges + - Put selected charge (from date-and-charges) first + - Then a divider + all other available charges + ------------------------------------------------------------ #} + + {# Selected charge identity #} + {% set selectedChargeCode = (draftCount.chargeCode or "") %} + {% set selectedChargeLabel = (draftCount.chargeLabel or "") %} + {% set selectedChargeText = "" %} + {% if selectedChargeCode and selectedChargeLabel %} + {% set selectedChargeText = selectedChargeCode + ": " + selectedChargeLabel %} + {% elif selectedChargeLabel %} + {% set selectedChargeText = selectedChargeLabel %} + {% elif selectedChargeCode %} + {% set selectedChargeText = selectedChargeCode %} + {% endif %} + + {% set allChargesListHtml %} + +

Charge you are working on

+ + {% if selectedChargeText %} +

{{ selectedChargeText }}

+ {% else %} +

No charge selected yet.

+ {% endif %} + +
+ +

Other charges

+ + {% if dedupedCharges.length %} +
    + {% for ch in dedupedCharges %} + + {# hide the selected one from the list below #} + {% set isSelected = false %} + {% if selectedChargeCode and ch.chargeCode and (ch.chargeCode == selectedChargeCode) %} + {% set isSelected = true %} + {% endif %} + + {% if not isSelected %} +
  • + {% if ch.chargeCode %}{{ ch.chargeCode }}:{% endif %} + {{ ch.description }} +
  • + {% endif %} + + {% endfor %} +
+ {% else %} +

No charges recorded for this case.

+ {% endif %} + + {% endset %} + + {{ govukDetails({ + summaryText: "All charges", + html: allChargesListHtml + }) }} +
{% endblock %} diff --git a/app/views/cases/indictment/counts/precedent-charges-or-offence.html b/app/views/cases/indictment/counts/precedent-charges-or-offence.html index d6390cb3..9ce9fc57 100644 --- a/app/views/cases/indictment/counts/precedent-charges-or-offence.html +++ b/app/views/cases/indictment/counts/precedent-charges-or-offence.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Precedent charges or offence' %} +{% set pageName = 'Select precedent charges or offence for count' %} {% block beforeContent %} {{ govukBackLink({ @@ -27,7 +27,11 @@ html: html }) }} - Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{# Search form submits query + category #} diff --git a/app/views/cases/indictment/counts/select-and-order-defendants.html b/app/views/cases/indictment/counts/select-and-order-defendants.html index 3e334620..495abdb2 100644 --- a/app/views/cases/indictment/counts/select-and-order-defendants.html +++ b/app/views/cases/indictment/counts/select-and-order-defendants.html @@ -3,7 +3,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Select and order defendants' %} +{% set pageName = 'Select defendants for indictment' %} {% block beforeContent %} {{ govukBackLink({ @@ -16,7 +16,11 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{# ✅ FIX: use the variable name you pass from the route #} @@ -31,7 +35,7 @@

{{ pageName }}

Reorder defendants by entering new order numbers. Defendant positions will move up and down accordingly.

-

Select the defendant(s) that apply to this indictment

+

Select all that apply

{% if returnTo %}{% endif %} diff --git a/app/views/cases/indictment/counts/select-and-order-victims.html b/app/views/cases/indictment/counts/select-and-order-victims.html index a3ad5093..f28304fa 100644 --- a/app/views/cases/indictment/counts/select-and-order-victims.html +++ b/app/views/cases/indictment/counts/select-and-order-victims.html @@ -2,7 +2,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Select and order victims' %} +{% set pageName = 'Select victims for indictment' %} {% block beforeContent %} {{ govukBackLink({ @@ -15,7 +15,11 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{% if showVictimReorderSuccess %} @@ -29,7 +33,7 @@

{{ pageName }}

Reorder defendants by entering new order numbers. Defendant positions will move up and down accordingly.

-

Select the victim(s) that apply to this indictment

+

Select all that apply

{% if returnTo %}{% endif %} diff --git a/app/views/cases/indictment/counts/select-and-order-witnesses.html b/app/views/cases/indictment/counts/select-and-order-witnesses.html index 673a2a77..13c82afd 100644 --- a/app/views/cases/indictment/counts/select-and-order-witnesses.html +++ b/app/views/cases/indictment/counts/select-and-order-witnesses.html @@ -2,7 +2,7 @@ {% extends "layouts/main.html" %} {% set navId = 'cases' %} {% set secondaryNavId = 'indictment' %} -{% set pageName = 'Select and order witnesses' %} +{% set pageName = 'Select witnesses for indictment' %} {% block beforeContent %} {{ govukBackLink({ @@ -15,7 +15,11 @@
- Indictment - Draft count + {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} +

{{ pageName }}

{% if showWitnessReorderSuccess %} diff --git a/app/views/cases/indictment/index.html b/app/views/cases/indictment/index.html index 0095551d..1befc77c 100644 --- a/app/views/cases/indictment/index.html +++ b/app/views/cases/indictment/index.html @@ -234,17 +234,17 @@

{{ pageName }}

{% set _ = summaryRows.push({ - key: { text: "Defendant(s)" }, + key: { text: "Defendants" }, value: { html: defendantsValue } }) %} {% set _ = summaryRows.push({ - key: { text: "Victim(s)" }, + key: { text: "Victims" }, value: { html: victimsValue } }) %} {% set _ = summaryRows.push({ - key: { text: "Witness(es)" }, + key: { text: "Witnesses" }, value: { html: witnessesValue } }) %} diff --git a/app/views/cases/indictment/preview/index.html b/app/views/cases/indictment/preview/index.html index 9779a2dd..c4942065 100644 --- a/app/views/cases/indictment/preview/index.html +++ b/app/views/cases/indictment/preview/index.html @@ -2,7 +2,7 @@ {% extends "layouts/main.html" %} -{% set pageName = "Preview and edit indictment" %} +{% set pageName = "Preview indictment" %} {% block beforeContent %} {{ govukBreadcrumbs({ @@ -30,8 +30,12 @@ html: "

Draft count added to Indictment

" }) }} #} - Build indictment -

{{ pageName }}

+ {{_case.reference}} - {{_case.defendants[0].firstName}} {{_case.defendants[0].lastName}} + {% if _case.defendants.length > 1 %} + and {{_case.defendants.length - 1}} more + {% endif %} + +

{{ pageName }}

{# --- Build defendant display name list (UPPERCASE) --- #}