importing improvements

This commit is contained in:
vabene1111
2020-06-23 11:04:49 +02:00
parent 8594346488
commit 98c278fe60
5 changed files with 46 additions and 8 deletions

View File

@@ -73,6 +73,7 @@
<th>{% trans 'Amount' %}</th>
<th>{% trans 'Unit' %}</th>
<th>{% trans 'Ingredient' %}</th>
<th></th>
</tr>
</thead>
<tbody>
@@ -81,9 +82,18 @@
<td><input class="form-control" v-model="i.amount"></td>
<td><input class="form-control" v-model="i.unit"></td>
<td><input class="form-control" v-model="i.ingredient"></td>
<td style="vertical-align: middle;text-align: center">
<button class="btn btn-outline-danger" type="button" @click="deleteIngredient(i)"><i
class="fas fa-trash-alt"></i></button>
</td>
</tr>
</tbody>
</table>
<div style="text-align: center">
<button class="btn btn-success" type="button" @click="addIngredient()"><i class="fas fa-plus"></i></button>
<br/><br/>
</div>
</div>
</div>
@@ -179,7 +189,7 @@
delimiters: ['[[', ']]'],
el: '#app',
data: {
remote_url: 'https://www.rezeptschachtel.de/schwarzwaelder_kirschtorte_rezept.html',
remote_url: '',
keywords: [],
recipe_data: undefined,
error: undefined,
@@ -187,7 +197,6 @@
all_keywords: false,
},
mounted: function () {
this.loadRecipe();
this.getKeywords();
},
methods: {
@@ -212,6 +221,16 @@
console.log("dragChanged create error", err);
})
},
deleteIngredient: function (i) {
this.recipe_data.recipeIngredient = this.recipe_data.recipeIngredient.filter(item => item !== i)
},
addIngredient: function (i) {
this.recipe_data.recipeIngredient.push({
unit: '{{ request.user.userpreference.default_unit }}',
amount: 0,
ingredient: ''
})
},
getKeywords: function () {
this.$http.get("{% url 'dal_keyword' %}").then((response) => {
this.keywords = response.data.results;