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 branch 'main' into MAN-227-enable-github-actions
- Loading branch information
Showing
142 changed files
with
10,782 additions
and
3,003 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
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,48 @@ | ||
const openText = 'Open' | ||
const closeText = 'Close' | ||
|
||
const openAllButton = document.querySelector('[data-js="predictor-timeline__toggle-all"]') | ||
const openCloseButtons = document.querySelectorAll('[data-js="predictor-timeline__toggle-section"]') | ||
const sections = document.querySelectorAll('[data-js="predictor-timeline__section"]') | ||
const sectionHiddenClass = 'predictor-timeline-section--hidden' | ||
|
||
function toggleButton(button, newState) { | ||
const label = button.querySelector('[data-js="score-action-label"]') | ||
if (newState === 'open') { | ||
button.setAttribute('aria-expanded', 'true') | ||
label.innerText = closeText | ||
} else { | ||
button.setAttribute('aria-expanded', 'false') | ||
label.innerText = openText | ||
} | ||
} | ||
|
||
function openCloseButtonClick(e) { | ||
e.preventDefault() | ||
const button = e.currentTarget | ||
const isCurrentlyOpen = button.getAttribute('aria-expanded') === 'true' | ||
toggleButton(button, isCurrentlyOpen ? 'close' : 'open') | ||
const sectionId = button.getAttribute('aria-controls') | ||
const section = document.getElementById(sectionId) | ||
if (isCurrentlyOpen) { | ||
section.classList.add(sectionHiddenClass) | ||
} else { | ||
section.classList.remove(sectionHiddenClass) | ||
} | ||
} | ||
|
||
function openAllButtonClicked(e) { | ||
e.preventDefault() | ||
sections.forEach(section => section.classList.remove(sectionHiddenClass)) | ||
openCloseButtons.forEach(button => toggleButton(button, 'open')) | ||
openAllButton.setAttribute('aria-expanded', 'true') | ||
} | ||
|
||
function addPredictorTimelineListeners() { | ||
openCloseButtons.forEach(button => button.addEventListener('click', openCloseButtonClick)) | ||
if (openAllButton) { | ||
openAllButton.addEventListener('click', openAllButtonClicked) | ||
} | ||
} | ||
|
||
addPredictorTimelineListeners() |
Oops, something went wrong.