generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Man 183 arrange an appointment (#237)
* MAN-183 create appointment pages initial route setup * MAN-183 create mock endpoint for user locations * MAN-183 add store session data middleware * MAN-183 add form element decorator nunjucks filter * MAN-193 templating wip * MAN-183 add validation middleware * MAN-183 add timepicker package * MAN-183 create appointments wizard pages wip * MAN-183 create appointments wizard pages wip * MAN-183 create appointments wizard pages wip * MAN-183 update wiremocks for user locations and sentences * MAN-183 functional create appointments wizard pages * MAN-183 e2e test specs wip * MAN-183 e2e test specs wip * MAN-183 e2e test specs wip * MAN-183 final test specs * MAN-183 refactor decorate form attribute nunjucks filter init * MAN-183 fix ci security exception * MAN-183 fix ci reliability exception * MAN-183 fix ci reliability exception * MAN-183 fix ci reliability exception * MAN-183 fix ci reliability exception * MAN-183 review fixes * Remove .DS_Store files * Add DS_Store to gitignore * MAN-183 review fixes * For ci to install npm v10 rather than latest * MAN-183 Fix type page test spec * MAN-183 fix sonar code issues wip * MAN-183 fix sonar code issues wip * MAN-183 fix sonar code issues wip * MAN-183 fix sonar code issues wip * MAN-183 remove timepicker package from project * MAN-183 fix sonar code issues wip * MAN-183 fix sonar code issues * MAN-183 clean install to regen package-lock
- Loading branch information
1 parent
3f52772
commit 53134fc
Showing
78 changed files
with
7,338 additions
and
2,676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,4 @@ integration_tests/screenshots/ | |
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable no-restricted-globals */ | ||
const lastAppointment = () => { | ||
const repeatingFrequency = document.querySelector('div[data-repeating-frequency]') | ||
if (repeatingFrequency) { | ||
const repeatingFrequencyRadios = repeatingFrequency.querySelectorAll('input[type="radio"]') | ||
const repeatingCount = document.querySelector('div[data-repeating-count] input') | ||
const lastAppointmentElm = document.querySelector('div[data-last-appointment') | ||
const lastAppointmentHandler = async () => { | ||
const repeatingFrequencyRadioSelected = repeatingFrequency.querySelector('input:checked') | ||
if (parseInt(repeatingCount.value, 10) > 0 && repeatingFrequencyRadioSelected) { | ||
const divider = location.href.includes('?') ? '&' : '?' | ||
const url = `${location.href}${divider}repeating-frequency=${encodeURI(repeatingFrequencyRadioSelected.value)}&repeating-count=${repeatingCount.value}` | ||
const headers = { | ||
Accept: '*/*', | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
} | ||
const response = await fetch(url, { | ||
method: 'GET', | ||
cache: 'no-cache', | ||
credentials: 'same-origin', | ||
headers, | ||
}) | ||
const html = await response.text() | ||
const parser = new DOMParser() | ||
const doc = parser.parseFromString(html, 'text/html') | ||
const element = doc.querySelector('div[data-last-appointment]').innerHTML | ||
document.querySelector('div[data-last-appointment]').innerHTML = element | ||
} else { | ||
lastAppointmentElm.innerHTML = '' | ||
} | ||
} | ||
repeatingFrequencyRadios.forEach(input => input.addEventListener('click', lastAppointmentHandler)) | ||
repeatingCount.addEventListener('keyup', lastAppointmentHandler) | ||
} | ||
} | ||
const resetConditionals = () => { | ||
const handleReset = () => { | ||
document.querySelectorAll('.govuk-radios__conditional input').forEach(radioBtn => { | ||
radioBtn.checked = false | ||
}) | ||
} | ||
const elm = document.querySelector('[data-reset-conditional-radios]') | ||
if (elm) { | ||
document.querySelectorAll('[data-reset-conditional-radios]').forEach(elm => { | ||
elm.addEventListener('click', handleReset) | ||
}) | ||
} | ||
} | ||
lastAppointment() | ||
resetConditionals() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.