-
Notifications
You must be signed in to change notification settings - Fork 0
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
ADJUST1-452 DR Edit remand #189
Conversation
@@ -18,4 +19,31 @@ export default class RemandChangeModel { | |||
public remandRelatedValidationSummary() { | |||
return remandRelatedValidationSummary(this.calculatedUnusedDeductions?.validationMessages) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we try and use more functional programming techniques in modern typescript, e.g. moving away from using traditional for loops and mutable variables.. something like this.
public isModified(): boolean {
if (!this.dbAdjustment) {
return false;
}
const sessionCharges = this.adjustment.remand.chargeId.sort((a, b) => a - b);
const dbCharges = this.dbAdjustment.remand.chargeId.sort((a, b) => a - b);
const chargeIdModified = !sessionCharges.every((chargeId, index) => chargeId === dbCharges[index]);
const dateModified = this.adjustment.toDate !== this.dbAdjustment.toDate ||
this.adjustment.fromDate !== this.dbAdjustment.fromDate;
return chargeIdModified || dateModified;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted this as you've suggested
{% if model.showUnusedMessage %} | ||
<p class="govuk-body">The updates will change the amount of unused deductions. Check the unused remand alert on NOMIS.</p> | ||
{% endif %} | ||
|
||
<form method="post"> | ||
<input type="hidden" name="_csrf" value="{{ csrfToken }}"/> | ||
<div class="govuk-button-group"> | ||
{% if not model.remandRelatedValidationSummary().errorList.length %} | ||
{% if not model.remandRelatedValidationSummary().errorList.length and model.isModified() %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth adding a unit test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've written 2 unit tests for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No description provided.