remove option for branding to sometimes not show search

it wouldn't show search if there were under a certain amount of letter
or email branding options - however we know there will always be more
than that amount so lets remove some complexity.

Also, rename the SearchTemplatesForm because it can search anything -
it just prompts you to search by name is all.
This commit is contained in:
Leo Hemsted
2019-02-06 17:32:13 +00:00
parent 7590b3dba9
commit f83910599c
10 changed files with 16 additions and 72 deletions

View File

@@ -960,7 +960,7 @@ class ChooseTemplateType(StripWhitespaceForm):
])
class SearchTemplatesForm(StripWhitespaceForm):
class SearchByNameForm(StripWhitespaceForm):
search = SearchField('Search by name')

View File

@@ -6,7 +6,7 @@ from notifications_utils.template import SMSPreviewTemplate
from app import current_service, notification_api_client, service_api_client
from app.main import main
from app.main.forms import SearchTemplatesForm
from app.main.forms import SearchByNameForm
from app.utils import user_has_permissions
@@ -50,7 +50,7 @@ def conversation_reply(
templates=templates,
show_search_box=(len(templates) > 7),
template_type='sms',
search_form=SearchTemplatesForm(),
search_form=SearchByNameForm(),
notification_id=notification_id,
)

View File

@@ -3,7 +3,7 @@ from flask_login import login_required
from app import email_branding_client
from app.main import main
from app.main.forms import SearchTemplatesForm, ServiceUpdateEmailBranding
from app.main.forms import SearchByNameForm, ServiceUpdateEmailBranding
from app.s3_client.s3_logo_client import (
TEMP_TAG,
delete_email_temp_file,
@@ -24,8 +24,7 @@ def email_branding():
return render_template(
'views/email-branding/select-branding.html',
email_brandings=brandings,
search_form=SearchTemplatesForm(),
show_search_box=len(brandings) > 9,
search_form=SearchByNameForm(),
agreement_info=AgreementInfo,
)

View File

@@ -14,7 +14,7 @@ from notifications_utils.template import HTMLEmailTemplate
from app import email_branding_client
from app.main import main
from app.main.forms import FieldWithNoneOption, SearchTemplatesForm
from app.main.forms import FieldWithNoneOption, SearchByNameForm
from app.main.views.sub_navigation_dictionaries import features_nav
from app.utils import AgreementInfo, get_logo_cdn_domain
@@ -74,7 +74,7 @@ def pricing():
(cc, country['names'], country['billable_units'])
for cc, country in INTERNATIONAL_BILLING_RATES.items()
], key=lambda x: x[0]),
search_form=SearchTemplatesForm(),
search_form=SearchByNameForm(),
agreement_info=AgreementInfo.from_current_user(),
)

View File

@@ -35,7 +35,7 @@ from app.main.forms import (
OrganisationTypeForm,
RenameServiceForm,
RequestToGoLiveForm,
SearchTemplatesForm,
SearchByNameForm,
ServiceContactDetailsForm,
ServiceDataRetentionEditForm,
ServiceDataRetentionForm,
@@ -773,8 +773,7 @@ def service_set_email_branding(service_id):
return render_template(
'views/service-settings/set-email-branding.html',
form=form,
search_form=SearchTemplatesForm(),
show_search_box=(len(email_branding) > 6)
search_form=SearchByNameForm()
)
@@ -820,8 +819,7 @@ def service_set_letter_branding(service_id):
return render_template(
'views/service-settings/set-letter-branding.html',
form=form,
search_form=SearchTemplatesForm(),
show_search_box=(len(letter_branding) > 6)
search_form=SearchByNameForm()
)

View File

@@ -22,7 +22,7 @@ from app.main.forms import (
EmailTemplateForm,
LetterTemplateForm,
LetterTemplatePostageForm,
SearchTemplatesForm,
SearchByNameForm,
SetTemplateSenderForm,
SMSTemplateForm,
TemplateAndFoldersSelectionForm,
@@ -149,7 +149,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
),
template_nav_items=get_template_nav_items(template_folder_id),
template_type=template_type,
search_form=SearchTemplatesForm(),
search_form=SearchByNameForm(),
templates_and_folders_form=templates_and_folders_form,
move_to_children=templates_and_folders_form.move_to.children(),
option_hints=option_hints
@@ -348,7 +348,7 @@ def choose_template_to_copy(
),
template_folder_path=service.get_template_folder_path(from_folder),
from_service=service,
search_form=SearchTemplatesForm(),
search_form=SearchByNameForm(),
)
else:
@@ -358,7 +358,7 @@ def choose_template_to_copy(
Service(service) for service in
user_api_client.get_services_for_user(current_user)
]),
search_form=SearchTemplatesForm(),
search_form=SearchByNameForm(),
)

View File

@@ -17,7 +17,7 @@
<a href="{{ url_for('.create_email_branding') }}" class="button align-with-heading">Add new brand</a>
</div>
</div>
{{ live_search(target_selector='.email-brand', show=show_search_box, form=search_form) }}
{{ live_search(target_selector='.email-brand', show=True, form=search_form) }}
<nav>
{% for brand in email_brandings %}
<div class="email-brand">

View File

@@ -18,7 +18,7 @@
</div>
<div class="grid-row">
<div class="column-full">
{{ live_search(target_selector='.multiple-choice', show=show_search_box, form=search_form, label='Search branding styles by name') }}
{{ live_search(target_selector='.multiple-choice', show=True, form=search_form, label='Search branding styles by name') }}
{{ radios(form.branding_style) }}
</div>
</div>