mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Convert text inputs on ServiceUpdateEmailBranding
Includes changes to templates that use this form and associated tests.
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
this.start = component => {
|
this.start = component => {
|
||||||
|
|
||||||
this.$input = $('input', component);
|
this.$input = $(component);
|
||||||
|
|
||||||
$(component).append(
|
this.$input.closest('.govuk-form-group').append(
|
||||||
this.$preview = $('<span class="textbox-colour-preview"></span>')
|
this.$preview = $('<span class="textbox-colour-preview"></span>')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -48,3 +48,7 @@ $govuk-grid-widths: (
|
|||||||
seven-eighths: 87.5%,
|
seven-eighths: 87.5%,
|
||||||
full: 100%
|
full: 100%
|
||||||
);
|
);
|
||||||
|
|
||||||
|
.govuk-input--width-6 {
|
||||||
|
max-width: 14ex;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1554,13 +1554,17 @@ class PreviewBranding(StripWhitespaceForm):
|
|||||||
|
|
||||||
|
|
||||||
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||||
name = StringField('Name of brand')
|
name = GovukTextInputField('Name of brand')
|
||||||
text = StringField('Text')
|
text = GovukTextInputField('Text')
|
||||||
colour = StringField(
|
colour = GovukTextInputField(
|
||||||
'Colour',
|
'Colour',
|
||||||
validators=[
|
validators=[
|
||||||
Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code (starting with #)')
|
Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code (starting with #)')
|
||||||
]
|
],
|
||||||
|
param_extensions={
|
||||||
|
"classes": "govuk-input--width-6",
|
||||||
|
"attributes": {"data-module": "colour-preview"}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
||||||
brand_type = RadioField(
|
brand_type = RadioField(
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
{{ file_upload(form.file, button_text='{} logo'.format('Update' if email_branding else 'Upload')) }}
|
{{ file_upload(form.file, button_text='{} logo'.format('Update' if email_branding else 'Upload')) }}
|
||||||
{% call form_wrapper() %}
|
{% call form_wrapper() %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div style='margin-top:15px;'>{{textbox(form.name)}}</div>
|
<div style='margin-top:15px;'>{{form.name}}</div>
|
||||||
<div style='margin-top:15px;'>{{textbox(form.text)}}</div>
|
<div style='margin-top:15px;'>{{form.text}}</div>
|
||||||
{{ textbox(form.colour, width='1-4', colour_preview=True) }}
|
{{ form.colour }}
|
||||||
{{ radios(form.brand_type) }}
|
{{ radios(form.brand_type) }}
|
||||||
{{ page_footer(
|
{{ page_footer(
|
||||||
'Save',
|
'Save',
|
||||||
button_name='operation',
|
button_name='operation',
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ def test_create_email_branding_does_not_show_any_branding_info(
|
|||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
|
||||||
assert page.select_one('#logo-img > img') is None
|
assert page.select_one('#logo-img > img') is None
|
||||||
assert page.select_one('#name').attrs.get('value') == ''
|
assert page.select_one('#name').attrs.get('value') is None
|
||||||
assert page.select_one('#text').attrs.get('value') == ''
|
assert page.select_one('#text').attrs.get('value') is None
|
||||||
assert page.select_one('#colour').attrs.get('value') == ''
|
assert page.select_one('#colour').attrs.get('value') is None
|
||||||
|
|
||||||
|
|
||||||
def test_create_new_email_branding_without_logo(
|
def test_create_new_email_branding_without_logo(
|
||||||
@@ -141,7 +141,7 @@ def test_create_email_branding_requires_a_name_when_submitting_logo_details(
|
|||||||
_expected_status=200,
|
_expected_status=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert page.select_one('.error-message').text.strip() == 'This field is required'
|
assert page.select_one('.govuk-error-message').text.strip() == 'Error: This field is required'
|
||||||
assert mock_create_email_branding.called is False
|
assert mock_create_email_branding.called is False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ describe('Colour preview', () => {
|
|||||||
|
|
||||||
// set up DOM
|
// set up DOM
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<div class="form-group" data-module="colour-preview">
|
<div class="govuk-form-group">
|
||||||
<label class="form-label" for="colour">
|
<label class="govuk-form-label" for="colour">
|
||||||
Colour
|
Colour
|
||||||
</label>
|
</label>
|
||||||
<input class="form-control form-control-1-4" id="colour" name="colour" rows="8" type="text" value="">
|
<input class="govuk-input govuk-input--width-6" id="colour" name="colour" rows="8" type="text" value="" data-module="colour-preview">
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
field = document.querySelector('.form-group');
|
field = document.querySelector('.govuk-form-group');
|
||||||
textbox = document.querySelector('input[type=text]');
|
textbox = document.querySelector('input[type=text]');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user