Skip to content

Commit

Permalink
Changes to merged cases on the remand to sentence journey. Show the u…
Browse files Browse the repository at this point in the history
…ser offences that have outcomes changed, and those that have not
  • Loading branch information
ashley-wheat committed Jan 29, 2025
1 parent 380387d commit ca59cb3
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 37 deletions.
9 changes: 8 additions & 1 deletion app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ router.post("/:prototypeVersion/persist-appearance", function (req, res) {
const prototypeVersion = req.params.prototypeVersion;
var appearanceDetailsComplete = 0;
const route = req.session.data.route;
console.log("Route: " + route)
if (req.session.data.appearanceIndex !== undefined) {
req.session.data.courtCases[req.session.data.courtCaseIndex].appearances[
req.session.data.appearanceIndex
Expand Down Expand Up @@ -761,12 +762,16 @@ router.post("/:prototypeVersion/persist-appearance", function (req, res) {
"Appearance status: " + req.session.data.appearance["status"]
);
return res.redirect(`/${prototypeVersion}/court-cases/`);
}
} else if (req.session.data.postSaveEdit == "true") {
return res.redirect(`/${prototypeVersion}/court-cases/appearance-detail`);
} else if (req.session.data.postSaveEditComplete == "true") {
return res.redirect(`/${prototypeVersion}/court-cases/confirmation-edit`);
} else {
return res.redirect(
`/${prototypeVersion}/court-cases/add-a-court-appearance/confirmation`
);
}
}
});

router.get("/:prototypeVersion/close-success-message", function (req, res) {
Expand Down Expand Up @@ -1698,6 +1703,8 @@ router.post(
var addSentenceInformationComplete = 1;
var offencesComplete = 1;
const route = req.session.data.route;
console.log("Offences: " + req.session.data.appearance.offences.length)
console.log("Sentences: " + req.session.data.appearance.sentences.length)
if (route == "new-court-case") {
if (warrantType == "Remand") {
req.session.data.offencesComplete = offencesComplete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ <h1 class="govuk-heading-l">
<button class="govuk-button govuk-button--link govuk-!-margin-bottom-2" data-module="govuk-button" formaction="/{{data.prototypeVersion}}/create-sentence?route=remand-to-sentence&path=rts-new-offence&edit=false" method="post">
Add an offence
</button>
<!-- <h2 class="govuk-heading-m govuk-!-margin-top-8 govuk-!-margin-bottom-6">Offences that have not been sentenced</h2> -->
<h2 class="govuk-heading-m govuk-!-margin-top-8 govuk-!-margin-bottom-6">Offences with outcomes that need updating</h2>
{% set no_match3 = true %}
{% for offence in data.appearance.offences %}
{% if sentence['sentence-type'] == null %}
{% if (sentence['sentence-type'] == null) and (offence['outcome-changed'] != 'true') %}
{% set no_match3 = false %}
<div class="offence-card">
<div class="offence-card-offence-details">
<h4 class="govuk-heading-s">{{ offence['offence-name'] }}</h4>
Expand Down Expand Up @@ -93,6 +95,11 @@ <h4 class="govuk-heading-s">{{ offence['offence-name'] }}</h4>
</div>
{% endif %}
{% endfor %}
{% if no_match3 %}
<div class="govuk-inset-text govuk-!-margin-top-2">
There are no offences with outcomes that need updating
</div>
{% endif %}
{% if data.appearance['warrant-type'] == "Sentencing" %}
<!-- <h2 class="govuk-heading-m govuk-!-margin-top-8 govuk-!-margin-bottom-6">Offences that have been sentenced</h2> -->
<!-- {% if data.appearance.sentences.length < 1 %}
Expand All @@ -101,7 +108,7 @@ <h4 class="govuk-heading-s">{{ offence['offence-name'] }}</h4>
</div>
{% endif %} -->
{% for sentence in data.appearance.sentences %}

{% if sentence['outcome-changed'] != 'true' %}
<div class="offence-card sentence-card">
<div class="offence-card-offence-details">
{% if sentence['count-number'] %}
Expand Down Expand Up @@ -206,8 +213,193 @@ <h4 class="govuk-heading-s">{{ sentence['offence-name'] }}
</ul>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
<h2 class="govuk-heading-m govuk-!-margin-top-8">Offences with updated outcomes</h2>
<h3 class="govuk-heading-s ">Offences with custodial outcomes</h3>
{% if data.appearance['warrant-type'] == "Sentencing" %}
{% set no_matches = true %}
{% for sentence in data.appearance.sentences %}
{% if sentence['outcome-changed'] == 'true' %}
{% set no_matches = false %}
<div class="offence-card sentence-card">
<div class="offence-card-offence-details">
{% if sentence['count-number'] %}
<span class="govuk-body">Count {{ sentence['count-number'] }}</span>
{% endif %}
<h4 class="govuk-heading-s">{{ sentence['offence-name'] }}
{% if sentence['terror-related'] == 'Yes' %}
<br><strong class="govuk-tag govuk-!-margin-top-2">
Terror-related
</strong>
{% endif %}</h4>
<dl class="govuk-summary-list govuk-summary-list--no-border">
{% if sentence['offence-start-date-day'] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Commited on
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['offence-start-date-day'] }}/{{ sentence['offence-start-date-month'] }}/{{ sentence['offence-start-date-year'] }}
{% if sentence['offence-end-date-day'] > 0 %}
to
{{ sentence['offence-end-date-day'] }}/{{ sentence['offence-end-date-month'] }}/{{ sentence['offence-end-date-year'] }}
{% endif %}
</dd>
</div>
{% endif %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Outcome
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['outcome'] }} {% if sentence['outcome-changed'] == 'true' %} <strong class="govuk-tag govuk-!-font-size-16 govuk-!-margin-left-1">
Updated
</strong>{% endif %}
</dd>
</div>
{% if sentence['sentence-type'] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Sentence type
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['sentence-type'] }}
</dd>
</div>
{% endif %}
{% if sentence['sentence-length-years'] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Sentence length
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['sentence-length-years'] }} years {{ sentence['sentence-length-months'] }} months {{ sentence['sentence-length-weeks'] }} weeks {{ sentence['sentence-length-days'] }} days
</dd>
</div>
{% endif %}
{% if sentence['licence-period-years'] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Licence period
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['licence-period-years'] }} years {{ sentence['licence-period-months'] }} months {{ sentence['licence-period-weeks'] }} weeks {{ sentence['licence-period-days'] }} days
</dd>
</div>
{% endif %}
{% if sentence['consecutive-concurrent'] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Consecutive or concurrent
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['consecutive-concurrent'] }}
{% if sentence['forthwith'] == 'Yes' %}
(forthwith)
{% endif %}
{% if sentence['consecutive-concurrent'] == 'Consecutive' %}
to count {{ sentence['consecutive-to'] }}
{% endif %}
</dd>
</div>
{% endif %}
{% if sentence["merged-from"] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Merged from
</dt>
<dd class="govuk-summary-list__value">
{{ sentence['merged-from'] }}
</dd>
</div>
{% endif %}
</dl>
{% if sentence['status'] == 'draft' %}
<p class="govuk-body govuk-!-margin-top-4 govuk-!-margin-bottom-2"><a href="{{ data.savedURL }}">Continue adding sentence information</a></p>
{% endif %}
</div>
<div class="offence-card-actions">
<ul class="offence-card-actions-list">
<li class="offence-card-action-link"><a href="/{{data.prototypeVersion}}/update-sentence?index={{loop.index0}}&route=remand-to-sentence">Edit</a></li>
<!-- <li class="offence-card-action-link"><a href="/{{data.prototypeVersion}}/confirm-delete?index={{loop.index0}}&route=add-a-court-case">Delete</a></li> -->
</ul>
</div>
</div>
{% endif %}
{% endfor %}
{% if no_matches %}
<div class="govuk-inset-text govuk-!-margin-top-2">
There are no offences with non-custodial outcomes.
</div>
{% endif %}
{% endif %}
<h3 class="govuk-heading-s govuk-!-margin-top-7">Offences with non-custodial outcomes</h3>
{% set no_matches2 = true %}
{% for offence in data.appearance.offences %}
{% if (sentence['sentence-type'] == null) and (offence['outcome-changed'] == 'true') %}
{% set no_matches2 = false %}
<div class="offence-card">
<div class="offence-card-offence-details">
<h4 class="govuk-heading-s">{{ offence['offence-name'] }}</h4>
<dl class="govuk-summary-list govuk-summary-list--no-border">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Commited on
</dt>
<dd class="govuk-summary-list__value">
{{ offence['offence-start-date-day'] }}/{{ offence['offence-start-date-month'] }}/{{ offence['offence-start-date-year'] }}
{% if offence['offence-end-date-day'] > 0 %}
to
{{ offence['offence-end-date-day'] }}/{{ offence['offence-end-date-month'] }}/{{ offence['offence-end-date-year'] }}
{% endif %}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key offence-card-offence-details-key">
Outcome
</dt>
<dd class="govuk-summary-list__value">
{{ offence['outcome'] }}{{ sentence['outcome'] }} {% if offence['outcome-changed'] == 'true' %} <strong class="govuk-tag govuk-!-font-size-16 govuk-!-margin-left-1">
Updated
</strong>{% endif %}
</dd>
</div>
{% if offence["merged-from"] %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Merged from
</dt>
<dd class="govuk-summary-list__value">
{{ offence['merged-from'] }}
</dd>
</div>
{% endif %}
</dl>
{% if offence['outcome-changed'] != 'true' %}
<ul class="govuk-list govuk-!-margin-top-4 govuk-!-margin-bottom-2">
{% if offence['status'] == 'draft' %}
<a href="{{data.savedURL}}">Continue updating outcome</a></li>
{% else %}
<li><a href="/{{data.prototypeVersion}}/update-outcome?index={{loop.index0}}&edit=false">Update outcome</a></li>
{% endif %}
</ul>
{% endif %}
</div>
<div class="offence-card-actions">
<ul class="offence-card-actions-list">
<li class="offence-card-action-link"><a href="/{{data.prototypeVersion}}/update-offence?index={{loop.index0}}&route=remand-to-sentence">Edit</a></li>
</ul>
</div>
</div>
{% endif %}
{% endfor %}
{% if no_matches2 %}
<div class="govuk-inset-text govuk-!-margin-top-2">
There are no offences with non-custodial outcomes.
</div>
{% endif %}
</div>
<div class="govuk-form-group govuk-!-margin-top-8">
<fieldset class="govuk-fieldset">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ <h1 class="govuk-heading-l">
Tagged bail
</dt>
<dd class="govuk-summary-list__value">
{% if data['appearance']['tagged-bail'] | first != 'No' %}
{{ data['appearance']['tagged-bail'] | last }} days
{% if data['appearance']['tagged-bail'] | first == 'Yes' %}
{{ data['appearance']['tagged-bail'] | last + " days" }}
{% else %}
None
None
{% endif %}
</dd>
<dd class="govuk-summary-list__actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% block content %}
<div class="govuk-grid-row govuk-!-margin-top-4">
<div class="govuk-grid-column-two-thirds">
<form class="form" action="confirmation" method="post">
<form class="form" action="/{{data.prototypeVersion}}/persist-appearance" method="post">
<div class="govuk-form-group">
<h1 class="govuk-heading-l">
Add a court appearance
Expand Down
Loading

0 comments on commit ca59cb3

Please sign in to comment.