From d5b78fac17eba26e02700ccb8008b7df8f025b8e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 18 Apr 2017 13:01:58 +0100 Subject: [PATCH] Move delete link from edit to view template page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users were having trouble finding the delete template link. It sort of made sense having it on the edit page before we had the view template page. But it doesn’t make sense now – having to choose to ‘edit’ the template before you can delete is counterintuitive. The single template page is where you go to choose an action to perform on your template. Deleting is a good example of an action you can perform on a template. So this commit moves the delete link from the edit template page to the view template page. It also puts the confirm banner on same page as the delete link The idea being that, in order to make a decision about whether to delete the template, it’s useful to be able to see the template you’re deleting. There’s no user need to edit the template before you delete it. --- app/main/views/templates.py | 17 ++++++++++------- app/templates/views/edit-email-template.html | 4 +--- app/templates/views/edit-letter-template.html | 4 +--- app/templates/views/edit-sms-template.html | 4 +--- app/templates/views/templates/template.html | 11 ++++++++++- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 203ae0b64..9a7056e51 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -350,9 +350,6 @@ def delete_service_template(service_id, template_id): template_type=template['template_type'] )) - template['template_content'] = template['content'] - form = form_objects[template['template_type']](**template) - try: last_used_notification = template_statistics_client.get_template_statistics_for_template( service_id, template['id'] @@ -370,11 +367,17 @@ def delete_service_template(service_id, template_id): raise e flash('{}. Are you sure you want to delete it?'.format(message), 'delete') + return render_template( - 'views/edit-{}-template.html'.format(template['template_type']), - h1='Edit template', - form=form, - template_id=template_id) + 'views/templates/template.html', + template=get_template( + template, + current_service, + expand_emails=True, + letter_preview_url=url_for('.view_template', service_id=service_id, template_id=template['id']), + show_recipient=True, + ) + ) @main.route('/services//templates//versions') diff --git a/app/templates/views/edit-email-template.html b/app/templates/views/edit-email-template.html index 0319820a1..a309b1e00 100644 --- a/app/templates/views/edit-email-template.html +++ b/app/templates/views/edit-email-template.html @@ -23,9 +23,7 @@ {{ radios(form.process_type) }} {% endif %} {{ page_footer( - 'Save', - delete_link=url_for('.delete_service_template', service_id=current_service.id, template_id=template_id) if template_id or None, - delete_link_text='Delete this template' + 'Save' ) }}