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.
Merge remote-tracking branch 'origin/main' into MAN-225-merge
- Loading branch information
Showing
131 changed files
with
9,784 additions
and
3,019 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 was deleted.
Oops, something went wrong.
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 |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* 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 => { | ||
// eslint-disable-next-line no-param-reassign | ||
radioBtn.checked = false | ||
}) | ||
} | ||
const elm = document.querySelector('[data-reset-conditional-radios]') | ||
if (elm) { | ||
// eslint-disable-next-line no-shadow | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { initAll } from '/assets/govuk/govuk-frontend.min.js' | ||
// eslint-disable-next-line import/no-unresolved,import/extensions | ||
import { initAll } from './govuk/govuk-frontend.min.js' | ||
|
||
initAll() |
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.