mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 15:48:25 -04:00
Merge pull request #2626 from alphagov/empty-service-state-folders
Use grey buttons to add templates when service is new
This commit is contained in:
@@ -111,6 +111,12 @@
|
|||||||
|
|
||||||
$('.template-list-selected-counter-count').html(numSelected);
|
$('.template-list-selected-counter-count').html(numSelected);
|
||||||
|
|
||||||
|
$('.template-list-selected-counter').toggle(this.hasCheckboxes());
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hasCheckboxes = function() {
|
||||||
|
return !!this.$form.find('input:checkbox').length;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.countSelectedCheckboxes = function() {
|
this.countSelectedCheckboxes = function() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% from "components/checkbox.html" import unlabelled_checkbox %}
|
{% from "components/checkbox.html" import unlabelled_checkbox %}
|
||||||
{% from "components/message-count-label.html" import folder_contents_count, message_count_label %}
|
{% from "components/message-count-label.html" import folder_contents_count, message_count_label %}
|
||||||
|
|
||||||
{% if not template_list.templates_to_show %}
|
{% if template_list.template_folder_id and not template_list.templates_to_show %}
|
||||||
<p class="template-list-empty">
|
<p class="template-list-empty">
|
||||||
{% if template_list.folder_is_empty %}
|
{% if template_list.folder_is_empty %}
|
||||||
This folder is empty
|
This folder is empty
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
{{ page_title }}
|
{{ page_title }}
|
||||||
</h1>
|
</h1>
|
||||||
{% if current_user.has_permissions('manage_templates') %}
|
{% if current_user.has_permissions('manage_templates') %}
|
||||||
<p class="bottom-gutter">
|
<p class="bottom-gutter top-gutter">
|
||||||
You need a template before you can send
|
You need a template before you can send
|
||||||
{% if 'letter' in current_service.permissions %}
|
{% if 'letter' in current_service.permissions %}
|
||||||
emails, text messages or letters
|
emails, text messages or letters
|
||||||
@@ -34,9 +34,8 @@
|
|||||||
emails or text messages
|
emails or text messages
|
||||||
{%- endif %}.
|
{%- endif %}.
|
||||||
</p>
|
</p>
|
||||||
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id) }}" class="button">Add a new template</a>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p class="top-gutter">
|
||||||
You need to ask your service manager to add templates before you can send
|
You need to ask your service manager to add templates before you can send
|
||||||
{% if 'letter' in current_service.permissions %}
|
{% if 'letter' in current_service.permissions %}
|
||||||
emails, text messages or letters
|
emails, text messages or letters
|
||||||
@@ -71,7 +70,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if show_template_nav %}
|
{% if show_template_nav %}
|
||||||
<div class="bottom-gutter">
|
<div class="bottom-gutter">
|
||||||
{{ pill(template_nav_items, current_value=template_type, show_count=False) }}
|
{{ pill(template_nav_items, current_value=template_type, show_count=False) }}
|
||||||
@@ -91,7 +90,10 @@
|
|||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include 'views/templates/_template_list.html' %}
|
{% include 'views/templates/_template_list.html' %}
|
||||||
|
{% if (not current_service.all_templates) and (not current_service.all_template_folders) and current_user.has_permissions('manage_templates') %}
|
||||||
|
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id) }}" class="button">Add a new template</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -35,21 +35,14 @@ from tests.conftest import service_one as create_sample_service
|
|||||||
from tests.conftest import single_letter_contact_block
|
from tests.conftest import single_letter_contact_block
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('extra_permissions', (
|
|
||||||
[],
|
|
||||||
['edit_folders'],
|
|
||||||
))
|
|
||||||
def test_should_show_empty_page_when_no_templates(
|
def test_should_show_empty_page_when_no_templates(
|
||||||
client_request,
|
client_request,
|
||||||
service_one,
|
service_one,
|
||||||
mock_get_organisations_and_services_for_user,
|
mock_get_organisations_and_services_for_user,
|
||||||
mock_get_service_templates_when_no_templates_exist,
|
mock_get_service_templates_when_no_templates_exist,
|
||||||
mock_get_template_folders,
|
mock_get_template_folders,
|
||||||
extra_permissions,
|
|
||||||
):
|
):
|
||||||
|
|
||||||
service_one['permissions'] += extra_permissions
|
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.choose_template',
|
'main.choose_template',
|
||||||
service_id=service_one['id'],
|
service_id=service_one['id'],
|
||||||
@@ -68,6 +61,36 @@ def test_should_show_empty_page_when_no_templates(
|
|||||||
assert len(page.select('main a')) == 1
|
assert len(page.select('main a')) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_show_add_template_form_if_service_has_folder_permission(
|
||||||
|
client_request,
|
||||||
|
service_one,
|
||||||
|
mock_get_organisations_and_services_for_user,
|
||||||
|
mock_get_service_templates_when_no_templates_exist,
|
||||||
|
mock_get_template_folders,
|
||||||
|
):
|
||||||
|
|
||||||
|
service_one['permissions'] += ['edit_folders']
|
||||||
|
|
||||||
|
page = client_request.get(
|
||||||
|
'main.choose_template',
|
||||||
|
service_id=service_one['id'],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert normalize_spaces(page.select_one('h1').text) == (
|
||||||
|
'Templates'
|
||||||
|
)
|
||||||
|
assert normalize_spaces(page.select_one('main p').text) == (
|
||||||
|
'You need a template before you can send emails or text messages.'
|
||||||
|
)
|
||||||
|
assert [
|
||||||
|
(item['name'], item['value']) for item in page.select('[type=radio]')
|
||||||
|
] == [
|
||||||
|
('add_template_by_template_type', 'email'),
|
||||||
|
('add_template_by_template_type', 'sms'),
|
||||||
|
]
|
||||||
|
assert not page.select('main a')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'user, expected_page_title, extra_args, expected_nav_links, expected_templates',
|
'user, expected_page_title, extra_args, expected_nav_links, expected_templates',
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user