mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 07:38:26 -05:00
basics of ingredient unit normalization
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
<!-- Bootstrap 4 -->
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
||||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
|
||||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.js"
|
||||
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
|
||||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
|
||||
@@ -31,8 +31,8 @@
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Select2 for use with django autocomplete light -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css" rel="stylesheet"/>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" rel="stylesheet"/>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js"></script>
|
||||
|
||||
<!-- Bootstrap theme for select2 -->
|
||||
<link rel="stylesheet"
|
||||
|
||||
@@ -46,7 +46,54 @@
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
<select class="form-control" id="test"></select>
|
||||
|
||||
<script>
|
||||
|
||||
$('#test').select2({
|
||||
tags: true,
|
||||
ajax: {
|
||||
url: '{% url 'dal_unit' %}',
|
||||
dataType: 'json',
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var select2Editor = function (cell, onRendered, success, cancel, editorParams) {
|
||||
|
||||
//create input element to hold select
|
||||
var editor = document.createElement("select");
|
||||
editor.setAttribute("class", "form-control");
|
||||
editor.setAttribute("style", "height: 100%");
|
||||
|
||||
onRendered(function () {
|
||||
var select_2 = $(editor);
|
||||
|
||||
select_2.select2({
|
||||
tags: true,
|
||||
ajax: {
|
||||
url: '{% url 'dal_unit' %}',
|
||||
dataType: 'json'
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
select_2.on('change', function (e) {
|
||||
success(select_2.text());
|
||||
});
|
||||
|
||||
|
||||
select_2.on('blur', function (e) {
|
||||
cancel();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//add editor to cell
|
||||
return editor;
|
||||
}
|
||||
|
||||
function selectText(node) {
|
||||
|
||||
if (document.body.createTextRange) {
|
||||
@@ -73,9 +120,9 @@
|
||||
|
||||
ingredients.forEach(function (cur, i) {
|
||||
cur.delete = false
|
||||
})
|
||||
});
|
||||
|
||||
var data = ingredients
|
||||
var data = ingredients;
|
||||
|
||||
var table = new Tabulator("#ingredients-table", {
|
||||
index: "id",
|
||||
@@ -85,7 +132,15 @@
|
||||
movableRows: true,
|
||||
headerSort: false,
|
||||
columns: [
|
||||
{ title: "<i class='fas fa-sort'></i>", rowHandle:true, formatter:"handle", headerSort:false, frozen:true, width:36, minWidth:36},
|
||||
{
|
||||
title: "<i class='fas fa-sort'></i>",
|
||||
rowHandle: true,
|
||||
formatter: "handle",
|
||||
headerSort: false,
|
||||
frozen: true,
|
||||
width: 36,
|
||||
minWidth: 36
|
||||
},
|
||||
{
|
||||
title: "{% trans 'Ingredient' %}",
|
||||
field: "name",
|
||||
@@ -93,7 +148,7 @@
|
||||
editor: "input"
|
||||
},
|
||||
{title: "{% trans 'Amount' %}", field: "amount", validator: "required", editor: "input"},
|
||||
{title: "{% trans 'Unit' %}", field: "unit", validator: "required", editor: "input"},
|
||||
{title: "{% trans 'Unit' %}", field: "unit__name", validator: "required", editor: select2Editor},
|
||||
{
|
||||
title: "{% trans 'Delete' %}",
|
||||
field: "delete",
|
||||
@@ -113,9 +168,9 @@
|
||||
})
|
||||
},
|
||||
cellClick: function (e, cell) {
|
||||
input = cell.getElement().childNodes[0]
|
||||
input.focus()
|
||||
input.select()
|
||||
//input = cell.getElement().childNodes[0]
|
||||
//input.focus()
|
||||
//input.select()
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% for plan_key, plan_value in plan.items %}
|
||||
|
||||
<tr>
|
||||
<td colspan="7" style="text-align: center"><h5>{{ plan_value.type_name }}</h5></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user