TandoorRecipes/cookbook/templates/shopping_list.html
2020-02-17 00:24:33 +01:00

44 lines
1.2 KiB
HTML

{% extends "base.html" %}
{% load django_tables2 %}
{% load crispy_forms_tags %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "Cookbook" %}{% endblock %}
{% block extra_head %}
{{ form.media }}
{% endblock %}
{% block content %}
<h2><i class="fas fa-shopping-cart"></i> {% trans 'Shopping List' %}</h2>
<form action="{% url 'view_shopping' %}" method="post">
{% csrf_token %}
{{ form|crispy }}
<button class="btn btn-success" type="submit"><i class="fas fa-sync-alt"></i> {% trans 'Load' %}</button>
</form>
<br/>
<br/>
<button class="btn btn-success" onclick="copy()"><i class="far fa-copy"></i></button>
<div class="row">
<div class="col col-md-12">
<!--// @formatter:off-->
<textarea id="id_list" style="height: 50vh" class="form-control">{% for i in ingredients %}- [ ] {{ i.amount.normalize }} {{ i.unit }} {{ i.ingredient.name }}&#10;{% endfor %}</textarea>
<!--// @formatter:on-->
</div>
</div>
<script type="text/javascript">
function copy() {
let list = $('#id_list');
list.select();
document.execCommand("copy");
}
</script>
{% endblock %}