diff --git a/app/main/forms.py b/app/main/forms.py
index fab2f7771..f9897cf34 100644
--- a/app/main/forms.py
+++ b/app/main/forms.py
@@ -713,20 +713,6 @@ class ServicePreviewBranding(StripWhitespaceForm):
branding_style = HiddenField('branding_style')
-class ServiceSelectEmailBranding(StripWhitespaceForm):
-
- def __init__(self, email_brandings=[], *args, **kwargs):
- self.email_branding.choices = email_brandings
- super(ServiceSelectEmailBranding, self).__init__(*args, **kwargs)
-
- email_branding = RadioField(
- 'Email branding',
- validators=[
- DataRequired()
- ]
- )
-
-
class ServiceUpdateEmailBranding(StripWhitespaceForm):
name = StringField('Name of brand')
text = StringField('Text')
diff --git a/app/main/views/email_branding.py b/app/main/views/email_branding.py
index 5a4a5a963..30201d0b8 100644
--- a/app/main/views/email_branding.py
+++ b/app/main/views/email_branding.py
@@ -3,10 +3,7 @@ from flask_login import login_required
from app import email_branding_client
from app.main import main
-from app.main.forms import (
- ServiceSelectEmailBranding,
- ServiceUpdateEmailBranding,
-)
+from app.main.forms import SearchTemplatesForm, ServiceUpdateEmailBranding
from app.main.s3_client import (
TEMP_TAG,
delete_temp_file,
@@ -14,10 +11,7 @@ from app.main.s3_client import (
persist_logo,
upload_logo,
)
-from app.main.views.service_settings import (
- get_branding_as_dict,
- get_branding_as_value_and_label,
-)
+from app.main.views.service_settings import get_branding_as_value_and_label
from app.utils import get_cdn_domain, user_is_platform_admin
@@ -27,19 +21,11 @@ from app.utils import get_cdn_domain, user_is_platform_admin
def email_branding():
brandings = email_branding_client.get_all_email_branding(sort_key='name')
- form = ServiceSelectEmailBranding()
- email_brandings = get_branding_as_value_and_label(brandings)
- form.email_branding.choices = email_brandings + [('None', 'Create a new email branding')]
- if form.validate_on_submit():
- if form.email_branding.data != 'None':
- return redirect(url_for('.update_email_branding', branding_id=form.email_branding.data))
- else:
- return redirect(url_for('.create_email_branding'))
-
return render_template(
'views/email-branding/select-branding.html',
- form=form,
- branding_dict=get_branding_as_dict(brandings),
+ email_brandings=get_branding_as_value_and_label(brandings),
+ search_form=SearchTemplatesForm(),
+ show_search_box=len(brandings) > 9,
)
@@ -106,6 +92,7 @@ def update_email_branding(branding_id, logo=None):
@user_is_platform_admin
def create_email_branding(logo=None):
form = ServiceUpdateEmailBranding()
+
if form.validate_on_submit():
if form.file.data:
upload_filename = upload_logo(
diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py
index 5eb1b21f6..e7c87f6a7 100644
--- a/app/main/views/service_settings.py
+++ b/app/main/views/service_settings.py
@@ -34,6 +34,7 @@ from app.main.forms import (
OrganisationTypeForm,
RenameServiceForm,
RequestToGoLiveForm,
+ SearchTemplatesForm,
ServiceContactDetailsForm,
ServiceDataRetentionEditForm,
ServiceDataRetentionForm,
@@ -886,7 +887,9 @@ def service_set_email_branding(service_id):
return render_template(
'views/service-settings/set-email-branding.html',
form=form,
- branding_dict=get_branding_as_dict(email_branding)
+ branding_dict=get_branding_as_dict(email_branding),
+ search_form=SearchTemplatesForm(),
+ show_search_box=(len(email_branding) > 6)
)
diff --git a/app/templates/components/live-search.html b/app/templates/components/live-search.html
new file mode 100644
index 000000000..f60b8f60c
--- /dev/null
+++ b/app/templates/components/live-search.html
@@ -0,0 +1,21 @@
+{% from "components/textbox.html" import textbox %}
+
+{% macro live_search(
+ target_selector=None,
+ show=False,
+ form=None,
+ label=None
+) %}
+ {%- set search_label = label or form.search.label.text %}
+ {% if show %}
+
+
+ {{ textbox(
+ form.search,
+ width='1-1',
+ label=search_label
+ ) }}
+
+
+ {% endif %}
+{% endmacro %}
diff --git a/app/templates/views/email-branding/manage-branding.html b/app/templates/views/email-branding/manage-branding.html
index e564bf99b..5b303cc01 100644
--- a/app/templates/views/email-branding/manage-branding.html
+++ b/app/templates/views/email-branding/manage-branding.html
@@ -10,7 +10,7 @@
{% block platform_admin_content %}
- {{ '{} email branding'.format('Update' if email_branding else 'Create')}}
+ {{ '{} email branding'.format('Update' if email_branding else 'Add')}}
{% if logo %}
diff --git a/app/templates/views/email-branding/select-branding.html b/app/templates/views/email-branding/select-branding.html
index b5a2bc12f..6fa134f57 100644
--- a/app/templates/views/email-branding/select-branding.html
+++ b/app/templates/views/email-branding/select-branding.html
@@ -1,26 +1,31 @@
{% extends "views/platform-admin/_base_template.html" %}
{% from "components/radios.html" import radios %}
{% from "components/page-footer.html" import page_footer %}
+{% from "components/live-search.html" import live_search %}
{% block service_page_title %}
- Select email branding
+ Email branding
{% endblock %}
{% block platform_admin_content %}
-
-
Select an email branding to update
- or create a new email branding
-
-
-
-
+
+ {{ live_search(target_selector='.message-name', show=show_search_box, form=search_form) }}
+
{% endblock %}
diff --git a/app/templates/views/manage-users.html b/app/templates/views/manage-users.html
index d625d8e5a..d7503a4c9 100644
--- a/app/templates/views/manage-users.html
+++ b/app/templates/views/manage-users.html
@@ -3,6 +3,7 @@
{% from "components/page-footer.html" import page_footer %}
{% from "components/tick-cross.html" import tick_cross %}
{% from "components/textbox.html" import textbox %}
+{% from "components/live-search.html" import live_search %}
{% set table_options = {
'field_headings': [
@@ -33,12 +34,7 @@
{% if show_search_box %}
-
- {{ textbox(
- form.search,
- width='1-1'
- ) }}
-
+ {{ live_search(target_selector='.user-list-item', show=True, form=form) }}
{% endif %}
diff --git a/app/templates/views/organisations/organisation/users/index.html b/app/templates/views/organisations/organisation/users/index.html
index 896be8dc4..f2a4d7b10 100644
--- a/app/templates/views/organisations/organisation/users/index.html
+++ b/app/templates/views/organisations/organisation/users/index.html
@@ -3,6 +3,7 @@
{% from "components/page-footer.html" import page_footer %}
{% from "components/tick-cross.html" import tick_cross %}
{% from "components/textbox.html" import textbox %}
+{% from "components/live-search.html" import live_search %}
{% block org_page_title %}
Team members
@@ -23,12 +24,7 @@
{% if show_search_box %}
-
- {{ textbox(
- form.search,
- width='1-1'
- ) }}
-
+ {{ live_search(target_selector='.user-list-item', show=True, form=form) }}
{% endif %}
diff --git a/app/templates/views/pricing.html b/app/templates/views/pricing.html
index 20d612d93..7171b15fb 100644
--- a/app/templates/views/pricing.html
+++ b/app/templates/views/pricing.html
@@ -1,5 +1,6 @@
{% from "components/table.html" import mapping_table, row, text_field, field, row_heading %}
{% from "components/textbox.html" import textbox %}
+{% from "components/live-search.html" import live_search %}
{% extends "withoutnav_template.html" %}
@@ -62,13 +63,7 @@
International text message rates
-
- {{ textbox(
- search_form.search,
- width='1-1',
- label='Search by country name or code'
- ) }}
-
+ {{ live_search(target_selector='#international-pricing .table-row', show=True, form=search_form, label='Search by country name or code') }}
{% call mapping_table(
diff --git a/app/templates/views/service-settings/set-email-branding.html b/app/templates/views/service-settings/set-email-branding.html
index 62661d00d..bbdd7d86c 100644
--- a/app/templates/views/service-settings/set-email-branding.html
+++ b/app/templates/views/service-settings/set-email-branding.html
@@ -1,6 +1,7 @@
{% extends "withnav_template.html" %}
{% from "components/radios.html" import radios %}
{% from "components/page-footer.html" import page_footer %}
+{% from "components/live-search.html" import live_search %}
{% block service_page_title %}
Set email branding
@@ -10,11 +11,16 @@
Set email branding