Merge pull request #2452 from alphagov/create-template-folders

Create template folders
This commit is contained in:
Alexey Bezhan
2018-11-08 11:58:39 +00:00
committed by GitHub
23 changed files with 428 additions and 44 deletions

View File

@@ -15,7 +15,7 @@
<div class="dashboard">
<h1 class="visuallyhidden">Dashboard</h1>
{% if current_user.has_permissions('manage_templates') and not current_service.templates %}
{% if current_user.has_permissions('manage_templates') and not current_service.all_templates %}
{% include 'views/dashboard/write-first-messages.html' %}
{% endif %}

View File

@@ -1,3 +1,4 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}

View File

@@ -0,0 +1,20 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% from "components/form.html" import form_wrapper %}
{% block service_page_title %}
Add a folder
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Add a folder</h1>
{% call form_wrapper() %}
{{ textbox(form.name) }}
{{ page_footer('Save') }}
{% endcall %}
{% endblock %}

View File

@@ -5,12 +5,12 @@
{% extends "withnav_template.html" %}
{% block service_page_title %}
Add new template
Add new template or folder
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Add new template</h1>
<h1 class="heading-large">What do you want to add?</h1>
{% call form_wrapper() %}
{{ radios(form.template_type) }}

View File

@@ -9,13 +9,18 @@
{% block service_page_title %}
{{ page_title }}
{% for folder in template_folder_path %}
/ {{ folder.name }}
{% endfor %}
{% endblock %}
{% block maincolumn_content %}
{% if not templates %}
{% if (not templates) and (not template_folder_path) %}
<h1 class="heading-large">{{ page_title }}</h1>
<h1 class="heading-large">
{{ page_title }}
</h1>
{% if current_user.has_permissions('manage_templates') %}
<p class="bottom-gutter">
You need a template before you can send
@@ -41,11 +46,25 @@
<div class="grid-row bottom-gutter-2-3">
<div class="column-two-thirds">
<h1 class="heading-large">{{ page_title }}</h1>
<h1 class="heading-large">
{% if template_folder_path %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type) }}">{{ page_title }}</a>
{% else %}
{{ page_title }}
{% endif %}
{% for folder in template_folder_path %}
/
{% if loop.last %}
{{ folder.name }}
{% else %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=folder.id) }}">{{ folder.name }}</a>
{% endif %}
{% endfor %}
</h1>
</div>
{% if current_user.has_permissions('manage_templates') %}
<div class="column-one-third">
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id) }}" class="button align-with-heading">Add new template</a>
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id, template_folder_id=current_template_folder_id) }}" class="button align-with-heading">Add new template</a>
</div>
{% endif %}
</div>
@@ -59,6 +78,16 @@
{{ live_search(target_selector='#template-list .column-whole', show=show_search_box, form=search_form) }}
<nav class="grid-row" id=template-list>
{% for template_folder in template_folders %}
<div class="column-whole">
<h2 class="message-name">
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=template_folder.id) }}">
{{ template_folder.name }}
</a>
</h2>
<p class="message-type">Folder containing {{ template_count }} template{% if template_count != 1 %}s{% endif %}</p>
</div>
{% endfor %}
{% for template in templates %}
<div class="column-whole">
<h2 class="message-name">

View File

@@ -13,7 +13,7 @@
</div>
<nav>
{% for service in services %}
{% set templates = service.templates_by_type(current_service.permissions) %}
{% set templates = service.get_templates(current_service.permissions) %}
{% if templates and services|length > 1 %}
<h2 class="">
{{ service.name }}