diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html
index 7e6d83750..d71ba9287 100644
--- a/cookbook/templates/forms/edit_internal_recipe.html
+++ b/cookbook/templates/forms/edit_internal_recipe.html
@@ -10,9 +10,6 @@
{% include 'include/vue_base.html' %}
-
-
-
@@ -450,6 +447,7 @@
},
methods: {
makeToast: function(title, message, variant=null) {
+ //TODO remove duplicate function in favor of central one
this.$bvToast.toast(message, {
title: title,
variant: variant,
diff --git a/cookbook/templates/include/vue_base.html b/cookbook/templates/include/vue_base.html
index f2a07ee04..b25455dc7 100644
--- a/cookbook/templates/include/vue_base.html
+++ b/cookbook/templates/include/vue_base.html
@@ -10,4 +10,7 @@
-
\ No newline at end of file
+
+
+
+
diff --git a/cookbook/templates/meal_plan.html b/cookbook/templates/meal_plan.html
index f57243fc8..792716e95 100644
--- a/cookbook/templates/meal_plan.html
+++ b/cookbook/templates/meal_plan.html
@@ -367,6 +367,15 @@
this.getRecipes();
},
methods: {
+ makeToast: function(title, message, variant=null) {
+ //TODO remove duplicate function in favor of central one
+ this.$bvToast.toast(message, {
+ title: title,
+ variant: variant,
+ toaster: 'b-toaster-top-center',
+ solid: true
+ })
+ },
updatePlan: function () {
let planEntryPromise = this.getPlanEntries();
let planTypePromise = this.getPlanTypes();
@@ -380,6 +389,7 @@
this.plan_entries = response.data;
}).catch((err) => {
console.log("getPlanEntries error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
getPlanTypes: function () {
@@ -391,6 +401,7 @@
}
}).catch((err) => {
console.log("getPlanTypes error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
buildGrid: function () {
@@ -440,6 +451,7 @@
this.recipes = response.data;
}).catch((err) => {
console.log("getRecipes error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
getMdNote: function () {
@@ -452,6 +464,7 @@
this.recipes = response.data;
}).catch((err) => {
console.log("getRecipes error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
updateUserNames: function () {
@@ -466,6 +479,7 @@
}).catch((err) => {
console.log("updateUserNames error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
dragChanged: function (date, meal_type, evt) {
@@ -491,6 +505,7 @@
this.$http.put(`{% url 'api:mealplan-list' %}${plan_entry.id}/`, plan_entry).then((response) => {
}).catch((err) => {
console.log("dragChanged update error", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
}
}
@@ -501,6 +516,7 @@
this.meal_plan[entry.meal_type_name].days[entry.date].items = this.meal_plan[entry.meal_type_name].days[entry.date].items.filter(item => item !== entry)
}).catch((err) => {
console.log("deleteEntry error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
updatePlanTypes: function () {
@@ -514,12 +530,14 @@
promise_list.push(this.$http.post("{% url 'api:mealtype-list' %}", x).then((response) => {
}).catch((err) => {
console.log("updatePlanTypes create error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
}))
} else if (x.delete) {
if (x.id !== undefined) {
promise_list.push(this.$http.delete(`{% url 'api:mealtype-list' %}${x.id}/`, x).then((response) => {
}).catch((err) => {
console.log("updatePlanTypes delete error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
}))
}
} else {
@@ -527,6 +545,7 @@
}).catch((err) => {
console.log("updatePlanTypes update error: ", err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
}))
}
}
diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html
index 9135d2b55..939bad8fa 100644
--- a/cookbook/templates/url_import.html
+++ b/cookbook/templates/url_import.html
@@ -281,6 +281,15 @@
this.searchIngredients('')
},
methods: {
+ makeToast: function (title, message, variant = null) {
+ //TODO remove duplicate function in favor of central one
+ this.$bvToast.toast(message, {
+ title: title,
+ variant: variant,
+ toaster: 'b-toaster-top-center',
+ solid: true
+ })
+ },
loadRecipe: function () {
this.recipe_data = undefined
this.error = undefined
@@ -292,6 +301,7 @@
this.error = err.data
this.loading = false
console.log(err)
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
importRecipe: function () {
@@ -299,7 +309,8 @@
this.$http.post(`{% url 'data_import_url' %}`, this.recipe_data).then((response) => {
location.href = response.data
}).catch((err) => {
- console.log("dragChanged create error", err);
+ console.log(err);
+ this.makeToast('{% trans 'Error' %}','{% trans 'An error occurred while trying to import this recipe!' %}' + err.bodyText, 'danger')
})
},
deleteIngredient: function (i) {
@@ -341,6 +352,7 @@
this.keywords_loading = false
}).catch((err) => {
console.log(err)
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
searchUnits: function (query) {
@@ -358,6 +370,7 @@
this.units_loading = false
}).catch((err) => {
console.log(err)
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
searchIngredients: function (query) {
@@ -376,6 +389,7 @@
this.ingredients_loading = false
}).catch((err) => {
console.log(err)
+ this.makeToast('{% trans 'Error' %}','{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
})
},
}