fixed shopping list escaping issue

This commit is contained in:
vabene1111
2021-05-18 18:20:41 +02:00
parent 200adb2fcf
commit 149020f930

View File

@@ -618,7 +618,7 @@
this.addRecipeToList(response.data, servings) this.addRecipeToList(response.data, servings)
}).catch((err) => { }).catch((err) => {
console.log("getRecipes error: ", err); console.log("getRecipes error: ", err);
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
loadShoppingList: function (autosync = false) { loadShoppingList: function (autosync = false) {
@@ -648,7 +648,7 @@
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
} else { } else {
this.shopping_list = { this.shopping_list = {
@@ -685,7 +685,7 @@
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error updating a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error updating a resource!") + err.bodyText, 'danger')
})) }))
} }
} }
@@ -696,7 +696,7 @@
if (this.shopping_list.id === undefined) { if (this.shopping_list.id === undefined) {
return this.$http.post("{% url 'api:shoppinglist-list' %}", this.shopping_list, {}).then((response) => { return this.$http.post("{% url 'api:shoppinglist-list' %}", this.shopping_list, {}).then((response) => {
console.log(response) console.log(response)
this.makeToast(gettext('Updated'), gettext('Object created successfully!'), 'success') this.makeToast(gettext('Updated'), gettext("Object created successfully!"), 'success')
this.loading = false this.loading = false
this.shopping_list = response.body this.shopping_list = response.body
@@ -705,18 +705,18 @@
window.history.pushState('shopping_list', '{% trans 'Shopping List' %}', "{% url 'view_shopping' 123456 %}".replace('123456', this.shopping_list_id)); window.history.pushState('shopping_list', '{% trans 'Shopping List' %}', "{% url 'view_shopping' 123456 %}".replace('123456', this.shopping_list_id));
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
this.makeToast(gettext('Error'), '{% trans 'There was an error creating a resource!' %}' + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error creating a resource!") + err.bodyText, 'danger')
this.loading = false this.loading = false
}) })
} else { } else {
return this.$http.put("{% url 'api:shoppinglist-detail' 123456 %}".replace('123456', this.shopping_list.id), this.shopping_list, {}).then((response) => { return this.$http.put("{% url 'api:shoppinglist-detail' 123456 %}".replace('123456', this.shopping_list.id), this.shopping_list, {}).then((response) => {
console.log(response) console.log(response)
this.shopping_list = response.body this.shopping_list = response.body
this.makeToast(gettext('Updated'), gettext('Changes saved successfully!'), 'success') this.makeToast(gettext('Updated'), gettext("Changes saved successfully!"), 'success')
this.loading = false this.loading = false
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error updating a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error updating a resource!") + err.bodyText, 'danger')
this.loading = false this.loading = false
}) })
} }
@@ -837,7 +837,7 @@
this.recipes = response.data.results; this.recipes = response.data.results;
}).catch((err) => { }).catch((err) => {
console.log("getRecipes error: ", err); console.log("getRecipes error: ", err);
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
getRecipeUrl: function (id) { //TODO generic function that can be reused else were getRecipeUrl: function (id) { //TODO generic function that can be reused else were
@@ -868,7 +868,7 @@
} }
} }
}).catch((err) => { }).catch((err) => {
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
removeRecipeFromList: function (slr) { removeRecipeFromList: function (slr) {
@@ -882,7 +882,7 @@
this.keywords_loading = false this.keywords_loading = false
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
@@ -892,7 +892,7 @@
this.units = response.data; this.units = response.data;
this.units_loading = false this.units_loading = false
}).catch((err) => { }).catch((err) => {
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
searchFoods: function (query) { //TODO move to central component searchFoods: function (query) { //TODO move to central component
@@ -901,7 +901,7 @@
this.foods = response.data this.foods = response.data
this.foods_loading = false this.foods_loading = false
}).catch((err) => { }).catch((err) => {
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
addFoodType: function (tag, index) { //TODO move to central component addFoodType: function (tag, index) { //TODO move to central component
@@ -920,7 +920,7 @@
this.users = response.data this.users = response.data
this.users_loading = false this.users_loading = false
}).catch((err) => { }).catch((err) => {
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
searchSupermarket: function (query) { //TODO move to central component searchSupermarket: function (query) { //TODO move to central component
@@ -929,7 +929,7 @@
this.supermarkets = response.data this.supermarkets = response.data
this.supermarkets_loading = false this.supermarkets_loading = false
}).catch((err) => { }).catch((err) => {
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext("There was an error loading a resource!") + err.bodyText, 'danger')
}) })
}, },
}, },