-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor determination javascript #6191
base: master
Are you sure you want to change the base?
Conversation
9ca53a3
to
32c0493
Compare
Kudos, SonarCloud Quality Gate passed!
|
32c0493
to
df855cd
Compare
a02e9ff
to
3ef1141
Compare
} | ||
|
||
cleanNumber = (element) => { | ||
element.value = element.value.replaceAll(/[^\d.]/g, '').replace(/^(\d*\.\d\d).*$/, '$1') |
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.
There is a better way to do this by splitting the string on the first .
to get the integer and mantissa parts and then remove all of the non-numeric characters from each part. As it is, a string like 12.3.4
does not get fixed.
|
9dfa988
to
4afb768
Compare
... and without jQuery.
For some reason Response is not being recognised even though it is part of Javascript (https://caniuse.com/?search=Response). This is possibly due to out of date dependencies preventing ES6 coding standards being checkd. It is added to the list of globals to allow `yarn standard` to pass. It may be possible to remove this after refactoring.
4afb768
to
7a33d4b
Compare
|
What
Rewrite the javascript for calculating determinations to follow the GovUK Javascript style guide.
Ticket
N/A
Why
Some motivation is written in
docs/javascript_restructure.md
In summary, the Javascript used in CCCD is written in inconsistent styles and have dependencies that are starting to make it difficult to keep the application up to date.
How
The determination calculation on the claim summary page for case workers was in
app/webpack/javascripts/modules/case_worker/claims/DeterminationCalculator.js
. The new version is now inapp/webpack/javascripts/modules/determination.js
and tests are inapp/webpack/javascripts/modules/determination_spec.mjs
.The GovUK
govuk-frontend
module is enabled by adding the classgovuk-frontend-supported
to the<body>
. This convention is for the newDetermination
class. The class is initialised inapp/webpack/packs/govuk-frontend.js
in the same way asgovuk-frontend
modules are initialised byrequire('govuk-frontend').initAll()
.