diff --git a/src/humulus/templates/_macros.html b/src/humulus/templates/_macros.html index 3e60d5a..889274f 100644 --- a/src/humulus/templates/_macros.html +++ b/src/humulus/templates/_macros.html @@ -13,9 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. -#} -{% macro render_field_with_errors(field, size='') %} + +{# + Macro for rendering WTF fields. + field is a FormField, and class is an additional class that gets added onto the field. +#} +{% macro render_field_with_errors(field, class='') %}
- {{ field.label }} {{ field(class_='form-control ' + size, **kwargs)|safe }} + {{ field.label }} {{ field(class_='form-control ' + class, **kwargs)|safe }} {% if field.errors %} {% for error in field.errors %}
@@ -25,3 +30,43 @@ {% endif %}
{% endmacro %} + +{# + Macro to render a delete button that triggers a modal. + content goes inside the button. class is an additional class to add on the button. + id is the ID of the deleteModal. +#} +{% macro render_delete_button(content, id, class='') %} + +{% endmacro %} + +{# + Macro to render a delete modal. Starts as hidden. + path is the path to send the delete POST request to. id is the id of the modal. + name is used in the delete confirmation. +#} +{% macro render_delete_modal(path, id, name) %} + +{% endmacro %} diff --git a/src/humulus/templates/recipes/info.html b/src/humulus/templates/recipes/info.html index 93b4a7b..d073217 100644 --- a/src/humulus/templates/recipes/info.html +++ b/src/humulus/templates/recipes/info.html @@ -13,11 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. -#} -{% from "_macros.html" import render_field_with_errors %} +{% from "_macros.html" import render_field_with_errors, render_delete_button, render_delete_modal %} {% extends '_base.html' %} {% block title %}{{ recipe.name }}{% endblock %} {% block body %}

{{ recipe.name }}

+
+ {{ render_delete_button('Delete Recipe', 'deleteRecipe', 'btn-sm btn-danger') }} +
+{{ render_delete_modal(url_for('recipes.delete', id=recipe._id), 'deleteRecipe', recipe.name) }} {% endblock %}