diff --git a/app/assets/javascripts/previewPane.js b/app/assets/javascripts/previewPane.js index 2dac47421..9c6bd50e3 100644 --- a/app/assets/javascripts/previewPane.js +++ b/app/assets/javascripts/previewPane.js @@ -4,7 +4,7 @@ $ = global.jQuery; - let branding_style = $('.multiple-choice input[name="branding_style"]:checked'); + let branding_style = $('.govuk-radios__item input[name="branding_style"]:checked'); if (!branding_style.length) { return; } diff --git a/app/main/forms.py b/app/main/forms.py index 53ee5bdfe..b276f8215 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -951,6 +951,10 @@ class OrganisationTypeField(GovukRadiosField): ) +class GovukRadiosFieldWithNoneOption(FieldWithNoneOption, GovukRadiosField): + pass + + # guard against data entries that aren't a role in permissions def filter_by_permissions(valuelist): if valuelist is None: @@ -1728,8 +1732,9 @@ class ServiceSwitchChannelForm(ServiceOnOffSettingForm): class SetEmailBranding(StripWhitespaceForm): - branding_style = RadioFieldWithNoneOption( + branding_style = GovukRadiosFieldWithNoneOption( 'Branding style', + param_extensions={'fieldset': {'legend': {'classes': 'govuk-visually-hidden'}}}, thing='a branding style', ) diff --git a/app/templates/views/organisations/organisation/settings/set-email-branding.html b/app/templates/views/organisations/organisation/settings/set-email-branding.html index 6c9ef0995..fa76c6ea3 100644 --- a/app/templates/views/organisations/organisation/settings/set-email-branding.html +++ b/app/templates/views/organisations/organisation/settings/set-email-branding.html @@ -1,5 +1,4 @@ {% extends "org_template.html" %} -{% from "components/radios.html" import radios %} {% from "components/page-footer.html" import page_footer %} {% from "components/page-header.html" import page_header %} {% from "components/live-search.html" import live_search %} @@ -25,13 +24,13 @@
{{ live_search( - target_selector='.multiple-choice', + target_selector='.govuk-radios__item', show=True, form=search_form, label='Search branding styles by name', autofocus=True ) }} - {{ radios(form.branding_style) }} + {{ form.branding_style }}
diff --git a/app/templates/views/organisations/organisation/settings/set-letter-branding.html b/app/templates/views/organisations/organisation/settings/set-letter-branding.html index a612c9696..3dd3d5d7a 100644 --- a/app/templates/views/organisations/organisation/settings/set-letter-branding.html +++ b/app/templates/views/organisations/organisation/settings/set-letter-branding.html @@ -1,5 +1,4 @@ {% extends "org_template.html" %} -{% from "components/radios.html" import radios %} {% from "components/live-search.html" import live_search %} {% from "components/page-footer.html" import page_footer %} {% from "components/page-header.html" import page_header %} @@ -25,13 +24,13 @@
{{ live_search( - target_selector='.multiple-choice', + target_selector='.govuk-radios__item', show=True, form=search_form, label='Search by name', autofocus=True ) }} - {{ radios(form.branding_style, hide_legend=True) }} + {{ form.branding_style }}
diff --git a/app/templates/views/service-settings/set-email-branding.html b/app/templates/views/service-settings/set-email-branding.html index e8baba461..7945b024a 100644 --- a/app/templates/views/service-settings/set-email-branding.html +++ b/app/templates/views/service-settings/set-email-branding.html @@ -1,5 +1,4 @@ {% extends "withnav_template.html" %} -{% from "components/radios.html" import radios %} {% from "components/page-header.html" import page_header %} {% from "components/page-footer.html" import page_footer, sticky_page_footer %} {% from "components/live-search.html" import live_search %} @@ -25,13 +24,13 @@
{{ live_search( - target_selector='.multiple-choice', + target_selector='.govuk-radios__item', show=True, form=search_form, label='Search branding styles by name', autofocus=True ) }} - {{ radios(form.branding_style) }} + {{ form.branding_style }}
{{ sticky_page_footer('Preview') }} diff --git a/app/templates/views/service-settings/set-letter-branding.html b/app/templates/views/service-settings/set-letter-branding.html index 4cb919a81..28ada9262 100644 --- a/app/templates/views/service-settings/set-letter-branding.html +++ b/app/templates/views/service-settings/set-letter-branding.html @@ -1,5 +1,4 @@ {% extends "withnav_template.html" %} -{% from "components/radios.html" import radios %} {% from "components/live-search.html" import live_search %} {% from "components/page-header.html" import page_header %} {% from "components/page-footer.html" import page_footer %} @@ -25,13 +24,13 @@
{{ live_search( - target_selector='.multiple-choice', + target_selector='.govuk-radios__item', show=True, form=search_form, label='Search by name', autofocus=True ) }} - {{ radios(form.branding_style, hide_legend=True) }} + {{ form.branding_style }}
diff --git a/tests/javascripts/liveSearch.test.js b/tests/javascripts/liveSearch.test.js index ba7422b92..59ff768bd 100644 --- a/tests/javascripts/liveSearch.test.js +++ b/tests/javascripts/liveSearch.test.js @@ -29,51 +29,42 @@ describe('Live search', () => { searchLabelText = "Search branding styles by name"; - function getRadiosHTML (departments) { - - let result = ''; - - departments.forEach((department, idx) => result += ` -
- - -
- `); - - return result; - - }; - beforeEach(() => { - const departments = [ - { - 'label': 'NHS', - 'id': 'nhs', - 'name': 'branding' - }, - { - 'label': 'Department for Work and Pensions', - 'id': 'dwp', - 'name': 'branding' - }, - { - 'label': 'Department for Education', - 'id': 'dfe', - 'name': 'branding' - }, - { - 'label': 'Home Office', - 'id': 'home-office', - 'name': 'branding' - } - ]; + const departmentData = { + name: 'departments', + hideLegend: true, + fields: [ + { + 'label': 'NHS', + 'id': 'nhs', + 'name': 'branding', + 'value': 'nhs' + }, + { + 'label': 'Department for Work and Pensions', + 'id': 'dwp', + 'name': 'branding', + 'value': 'dwp' + }, + { + 'label': 'Department for Education', + 'id': 'dfe', + 'name': 'branding', + 'value': 'dfe' + }, + { + 'label': 'Home Office', + 'id': 'home-office', + 'name': 'branding', + 'value': 'home-office' + } + ] + }; // set up DOM document.body.innerHTML = ` -