Works on ingredients

This commit is contained in:
2019-02-03 15:17:43 +01:00
parent 28afe8ece0
commit d3259c82b3
10 changed files with 151 additions and 61 deletions

View File

@@ -20,7 +20,7 @@
<h4 class="title">{{ items[active_view].title }}</h4>
<h6 class="subtitle">{{ categories[items[active_view].category].name }}</h6>
<p><strong>{{ items[active_view].ingredients }}</strong></p>
<button @click="deleteRecipe(active_view + 1)" class="button is-danger is-pulled-right">DELETE !</button>
<button @click="deleteRecipe(items[active_view].id)" class="button is-danger is-pulled-right">DELETE !</button>
</div>
</section>
<!-- Category List View -->
@@ -75,9 +75,15 @@
deleteRecipe: function(id) {
fetch("/api/delete/" + id)
.then((res) => res.json())
.then((data) => console.log("Deleted :" + data))
.then((data) => {
if (data === true) {
this.items.splice(this.active_view, 1);
this.closeActiveView();
console.log("Deleted :" + data);
} else {
console.log("Error deleting");
}})
.catch((err) => console.error(err));
this.closeActiveView();
},
fetchRecipesList: function() {
fetch("/api/list")

View File

@@ -40,7 +40,7 @@ mod api {
id: rec.id,
title: rec.title,
category: rec.category as i16,
ingredients: rec.ingredients,
ingredients: rec.ingredients.as_string(),
preparation: rec.preparation,
}
}