mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Merge pull request #2230 from alphagov/add-branding-name-to-ui
Show the 'name' of the email branding in the adding and editing screens
This commit is contained in:
@@ -729,7 +729,8 @@ class ServiceSelectEmailBranding(StripWhitespaceForm):
|
||||
|
||||
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name')
|
||||
name = StringField('Name of brand')
|
||||
text = StringField('Text')
|
||||
colour = StringField(
|
||||
'Colour',
|
||||
render_kw={'onchange': 'update_colour(this)'},
|
||||
@@ -742,7 +743,8 @@ class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
class ServiceCreateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name')
|
||||
name = StringField('Name of brand')
|
||||
text = StringField('Text')
|
||||
colour = StringField(
|
||||
'Colour',
|
||||
render_kw={'onchange': 'update_colour(this)'},
|
||||
|
||||
@@ -78,12 +78,14 @@ def update_email_branding(branding_id, logo=None):
|
||||
branding_id=branding_id,
|
||||
logo=logo,
|
||||
name=form.name.data,
|
||||
text=form.text.data,
|
||||
colour=form.colour.data
|
||||
)
|
||||
|
||||
return redirect(url_for('.email_branding', branding_id=branding_id))
|
||||
|
||||
form.name.data = email_branding['name']
|
||||
form.text.data = email_branding['text']
|
||||
form.colour.data = email_branding['colour']
|
||||
|
||||
return render_template(
|
||||
@@ -124,6 +126,7 @@ def create_email_branding(logo=None):
|
||||
email_branding_client.create_email_branding(
|
||||
logo=logo,
|
||||
name=form.name.data,
|
||||
text=form.text.data,
|
||||
colour=form.colour.data
|
||||
)
|
||||
|
||||
|
||||
@@ -15,18 +15,20 @@ class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
def get_letter_email_branding(self):
|
||||
return self.get(url='/dvla_organisations')
|
||||
|
||||
def create_email_branding(self, logo, name, colour):
|
||||
def create_email_branding(self, logo, name, text, colour):
|
||||
data = {
|
||||
"logo": logo,
|
||||
"name": name,
|
||||
"text": text,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post(url="/email-branding", data=data)
|
||||
|
||||
def update_email_branding(self, branding_id, logo, name, colour):
|
||||
def update_email_branding(self, branding_id, logo, name, text, colour):
|
||||
data = {
|
||||
"logo": logo,
|
||||
"name": name,
|
||||
"text": text,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post(url="/email-branding/{}".format(branding_id), data=data)
|
||||
|
||||
@@ -91,51 +91,6 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro branding_radios(
|
||||
field,
|
||||
hint=None,
|
||||
branding_dict={},
|
||||
show_header=True
|
||||
) %}
|
||||
<div class="form-group {% if field.errors %} form-group-error{% endif %}">
|
||||
<fieldset>
|
||||
<legend class="form-label">
|
||||
{% if show_header %}
|
||||
{{ field.label.text }}
|
||||
{% endif %}
|
||||
{% if field.errors %}
|
||||
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
||||
{{ field.errors[0] }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</legend>
|
||||
{% for value, option, checked in field.iter_choices() %}
|
||||
<div class="multiple-choice branding-radio">
|
||||
<input
|
||||
type="radio"
|
||||
name="{{ field.name }}"
|
||||
id="{{ field.name }}-{{ loop.index }}"
|
||||
value="{{ value }}"
|
||||
{% if checked %}checked="checked"{% endif %}
|
||||
/>
|
||||
<label class="block-label" for="{{ field.name }}-{{ loop.index }}">
|
||||
{% if branding_dict.get(value, {}).get('colour') %}
|
||||
<span style="background: {{ branding_dict[value].colour }}; display: inline-block; width: 3px; height: 27px;"></span>
|
||||
{% endif %}
|
||||
{% if branding_dict.get(value, {}).get('logo') %}
|
||||
<img
|
||||
src="{{ branding_dict[value].logo }}"
|
||||
height="27"
|
||||
/>
|
||||
{% endif %}
|
||||
{{option}}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro conditional_radio_panel(id) %}
|
||||
<div class="conditional-radios-panel" id="panel-{{ id }}">
|
||||
{{ caller() }}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<div style='margin-top:15px;'>{{textbox(form.name)}}</div>
|
||||
<div style='margin-top:15px;'>{{textbox(form.text)}}</div>
|
||||
{{colour_textbox(form.colour, width='1-4', colour=email_branding.colour if email_branding)}}
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "views/platform-admin/_base_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<form method="post">
|
||||
{{ branding_radios(form.email_branding, branding_dict=branding_dict, show_header=False) }}
|
||||
{{ radios(form.email_branding) }}
|
||||
{{ page_footer(
|
||||
'Next'
|
||||
) }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
@@ -15,7 +15,7 @@
|
||||
{{ radios(form.branding_type) }}
|
||||
</div>
|
||||
<div class="column-one-half">
|
||||
{{ branding_radios(form.branding_style, branding_dict=branding_dict) }}
|
||||
{{ radios(form.branding_style) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-row">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios, branding_radios %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
|
||||
Reference in New Issue
Block a user