Mercurial > farol
changeset 69:42915aaa6888
Move the delete_button to the common macros
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 10:11:35 +0200 |
parents | 33cdb9faed64 |
children | 727c01e8e3e9 |
files | farol/templates/document/view.j2 farol/templates/macros.j2 |
diffstat | 2 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/templates/document/view.j2 Thu Oct 09 10:10:48 2014 +0200 +++ b/farol/templates/document/view.j2 Thu Oct 09 10:11:35 2014 +0200 @@ -24,7 +24,7 @@ -#} {% extends "base.j2" %} -{% from "macros.j2" import panel, label_value %} +{% from "macros.j2" import panel, label_value, delete_button %} {% block title %}Document{% endblock %} {% set active='document' %} @@ -62,7 +62,7 @@ <div class="form-horizontal"> <div class="pull-right"> <a href="{{ url_for('.edit_revision', index=loop.index0) }}"><span class="label label-default">edit</span></a> - <form class="delete" role="button" action="{{ url_for('.del_revision') }}" method="POST"><input type=hidden name="index", value="{{ loop.index0 }}"><button type="submit" class="btn btn-link btn-xs"><span class="label label-danger"><strong>delete</strong></span></button></form> + {{ delete_button(url_for('.del_revision'), {'index': loop.index0}) }} </div> {{ label_value('Number', revision._number | join('.'), right=8) }} {{ label_value('Date', revision._date) }}
--- a/farol/templates/macros.j2 Thu Oct 09 10:10:48 2014 +0200 +++ b/farol/templates/macros.j2 Thu Oct 09 10:11:35 2014 +0200 @@ -168,3 +168,16 @@ </ul> {% endif %} {% endmacro %} + +{% macro delete_button(url, hiddens, text="delete") %} +<form class="delete" role="button" action="{{ url }}" method="POST"> + {% for elem in hiddens %} + <input type=hidden name="{{ elem }}", value="{{ hiddens[elem] }}"> + {% endfor %} + <button type="submit" class="btn btn-link btn-xs"> + <span class="label label-danger"> + <strong>{{ text }}</strong> + </span> + </button> +</form> +{% endmacro %}