Remove the ‘manage templates’ page

The ‘manage templates’ page was almost identical to the ‘send text messages’
page.

This commit consolidates them into one and makes them all hang together.

Part of this means tweaks to the javascript so that files upload as soon as
you’ve chosen them.
This commit is contained in:
Chris Hill-Scott
2016-02-22 12:16:19 +00:00
parent bf3f6d7d3e
commit 97a3bf9225
14 changed files with 37 additions and 76 deletions

View File

@@ -3,22 +3,20 @@
Modules.FileUpload = function() {
let $field, $button, $filename;
let $field;
this.update = function() {
this.submit = function() {
$filename.text($field.val().split('\\').pop());
$field.parents('form').trigger('submit');
};
this.start = function(component) {
$field = $('.file-upload-field', component);
$button = $('.file-upload-button', component);
$filename = $('.file-upload-filename', component);
// Need to put the event on the container, not the input for it to work properly
$(component).on('change', '.file-upload-field', this.update);
$(component).on('change', '.file-upload-field', this.submit);
};

View File

@@ -23,7 +23,7 @@
}
&-button {
@include button($panel-colour);
@include button($button-colour);
display: inline-block;
}

View File

@@ -55,10 +55,6 @@
background-image: file-url('tick.png');
}
&-no {
background-image: file-url('cross.png');
}
&-missing {
color: $error-colour;
font-weight: bold;

View File

@@ -15,22 +15,10 @@ from app.main.dao import services_dao as sdao
@main.route("/services/<service_id>/templates")
@login_required
def manage_service_templates(service_id):
try:
jobs = job_api_client.get_job(service_id)['data']
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
return render_template(
'views/manage-templates.html',
service_id=service_id,
has_jobs=bool(jobs),
templates=[
Template(template)
for template in tdao.get_service_templates(service_id)['data']
]
)
return redirect(url_for(
'.choose_sms_template',
service_id=service_id
))
@main.route("/services/<service_id>/templates/add", methods=['GET', 'POST'])
@@ -50,10 +38,10 @@ def add_service_template(service_id):
tdao.insert_service_template(
form.name.data, form.template_content.data, service_id)
return redirect(url_for(
'.manage_service_templates', service_id=service_id))
'.choose_sms_template', service_id=service_id))
return render_template(
'views/edit-template.html',
h1='Add template',
h1='Add a text message template',
form=form,
service_id=service_id)
@@ -69,7 +57,7 @@ def edit_service_template(service_id, template_id):
tdao.update_service_template(
template_id, form.name.data,
form.template_content.data, service_id)
return redirect(url_for('.manage_service_templates', service_id=service_id))
return redirect(url_for('.choose_sms_template', service_id=service_id))
return render_template(
'views/edit-template.html',

View File

@@ -1,7 +1,7 @@
{% macro file_upload(field, button_text="Choose file") %}
<div class="form-group{% if field.errors %} error{% endif %}" data-module="file-upload">
<label class="file-upload-label" for="{{ field.name }}">
{{ field.label }}
<span class="visually-hidden">{{ field.label }}</span>
{% if hint %}
<span class="form-hint">
{{ hint }}

View File

@@ -13,14 +13,14 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="button{% if destructive %}-destructive{% endif %}" value="{{ button_text }}" />
{% endif %}
{% if delete_link %}
<span class="page-footer-delete-link">
or <a href="{{ delete_link }}">{{ delete_link_text }}</a>
</span>
{% endif %}
{% if back_link %}
<a class="page-footer-back-link" href="{{ back_link }}">{{ back_link_text }}</a>
{% endif %}
{% if delete_link %}
<span class="page-footer-delete-link">
<a href="{{ delete_link }}">{{ delete_link_text }}</a>
</span>
{% endif %}
{% if secondary_link and secondary_link_text %}
<a class="page-footer-secondary-link" href="{{ secondary_link }}">{{ secondary_link_text }}</a>
{% endif %}

View File

@@ -7,12 +7,11 @@
<li><a href="{{ url_for('.send_email', service_id=service_id) }}">Send emails</a></li>
</ul>
<ul>
<li><a href="{{ url_for('.manage_service_templates', service_id=service_id) }}">Manage templates</a></li>
<li><a href="{{ url_for('.manage_users', service_id=service_id) }}">Manage team</a></li>
<li><a href="{{ url_for('.service_settings', service_id=service_id) }}">Manage service settings</a></li>
<li><a href="{{ url_for('.service_settings', service_id=service_id) }}">Manage settings</a></li>
</ul>
<ul>
<li><a href="{{ url_for('.documentation', service_id=service_id) }}">Developer documentation</a></li>
<li><a href="{{ url_for('.api_keys', service_id=service_id) }}">API keys</a></li>
<li><a href="{{ url_for('.documentation', service_id=service_id) }}">Developer documentation</a></li>
</ul>
</nav>

View File

@@ -23,18 +23,16 @@
<div class="sms-message-use-links">
<a href="{{ url_for(".send_sms", service_id=service_id, template_id=template.id) }}">Add recipients</a>
<a href="{{ url_for(".send_sms_to_self", service_id=service_id, template_id=template.id) }}">Send yourself a test</a>
<a href="{{ url_for(".edit_service_template", service_id=service_id, template_id=template.id) }}">Edit template</a>
</div>
</div>
{% endfor %}
</div>
{% else %}
{{ banner(
'<a href="{}">Add a text message template</a> to start sending messages'.format(
url_for(".add_service_template", service_id=service_id)
)|safe,
type="tip"
)}}
{% endif %}
<p>
<a href="{{ url_for('.add_service_template', service_id=service_id) }}" class="button">Add a new template</a>
</p>
</form>
{% endblock %}

View File

@@ -30,9 +30,9 @@
{{ page_footer(
'Save',
delete_link=url_for('.delete_service_template', service_id=service_id, template_id=template_id) if template_id or None,
delete_link_text='delete this template',
secondary_link=url_for('.manage_service_templates', service_id=service_id),
secondary_link_text='Back to templates'
delete_link_text='Delete this template',
back_link=url_for('.choose_sms_template', service_id=service_id),
back_link_text='Cancel'
) }}
</form>

View File

@@ -18,7 +18,7 @@ Manage users GOV.UK Notify
{% if user %}
<p class='bottom-gutter'>
{{ user.email_localpart }}@digital.cabinet-office.gov.uk
{{ current_user.email_address }}
</p>
{% else %}
{{ textbox(form.email_address, hint='Email address must end in .gov.uk', width='1-1') }}
@@ -37,7 +37,9 @@ Manage users GOV.UK Notify
{{ page_footer(
'Save',
delete_link=url_for('.delete_user', service_id=service_id, user_id=user_id),
delete_link_text='delete this account'
delete_link_text='Delete this account',
back_link=url_for('.manage_users', service_id=service_id),
back_link_text='Cancel'
) }}
{% else %}
{{ page_footer('Send invitation email') }}

View File

@@ -20,16 +20,11 @@
</div>
</div>
{{file_upload(form.file, button_text='Choose a CSV file')}}
<p>
<a href="{{ url_for('.get_example_csv', service_id=service_id, template_id=template.id) }}">Download an example CSV file</a>
</p>
{{ page_footer(
"Continue to preview"
) }}
{{file_upload(form.file, button_text='Upload a CSV file')}}
</form>
{% endblock %}

View File

@@ -25,21 +25,9 @@
{% if not jobs %}
{{ banner(
"""
<ol>
<li>
<a href='{}'>Add a template</a>
</li>
<li>
<a href='{}'>Send yourself a text message</a>
</li>
</ol>
""".format(
url_for(".add_service_template", service_id=service_id),
url_for(".choose_sms_template", service_id=service_id)
)|safe,
'Send yourself a text message',
subhead='Get started',
type="tip"
type='tip'
)}}
{% else %}
{% call(item) list_table(