diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html index a858a0851..f846511ad 100644 --- a/cookbook/templates/forms/edit_internal_recipe.html +++ b/cookbook/templates/forms/edit_internal_recipe.html @@ -4,6 +4,11 @@ {% block title %}{% trans 'Edit Recipe' %}{% endblock %} +{% block extra_head %} + + +{% endblock %} + {% block content %}

{% trans 'Edit Recipe' %}

@@ -11,6 +16,8 @@
{% csrf_token %} {{ form|crispy }} +
+
@@ -19,6 +26,31 @@ //shitty solution that needs to be redone at some point $(document).ready(function () { $('#id_keywords').select2(); + + var data = [] + + var table = new Tabulator("#ingredients-table", { + index: "id", + layout: "fitColumns", + reactiveData: true, + data: data, + columns: [ + {title: "{% trans 'ingredient' %}", field: "ingredient", validator: "required", editor:"select", editorParams:{values:{"test1":"Test1", "test2":"Test2"}}}, + {title: "{% trans 'amount' %}", field: "amount", validator: "required", editor: "input"}, + {title: "{% trans 'unit' %}", field: "unit", validator: "required", editor: "input"}, + {title: "{% trans 'delete' %}", field:"delete", align:"center", editor:true, formatter:"tickCross"}, + {title: "id", field: "id", visible: false} + ], + dataEdited: function (data) { + $('#ingredients_data_input').val(JSON.stringify(data)) + + data.forEach(function (cur, i) { + if(cur.delete) { + table.deleteRow(cur.id); + } + }) + } + }); }); {% endblock %} \ No newline at end of file