mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 13:19:16 -05:00
fixed unit search on importer page
This commit is contained in:
@@ -908,28 +908,22 @@
|
|||||||
// })
|
// })
|
||||||
},
|
},
|
||||||
searchUnits: function (query) {
|
searchUnits: function (query) {
|
||||||
let apiFactory = new ApiApiFactory()
|
|
||||||
|
|
||||||
this.units_loading = true
|
this.units_loading = true
|
||||||
apiFactory
|
this.$http.get("{% url 'dal_unit' %}" + '?q=' + query).then((response) => {
|
||||||
.listUnits(query, 1, this.options_limit)
|
this.units = response.data.results;
|
||||||
.then((response) => {
|
if (this.recipe_data !== undefined) {
|
||||||
this.units = response.data.results
|
for (let x of Array.from(this.recipe_data.recipeIngredient)) {
|
||||||
|
if (x.unit !== null && x.unit.text !== '') {
|
||||||
if (this.recipe !== undefined) {
|
this.units = this.units.filter(item => item.text !== x.unit.text)
|
||||||
for (let s of this.recipe.steps) {
|
this.units.push(x.unit)
|
||||||
for (let i of s.ingredients) {
|
|
||||||
if (i.unit !== null && i.unit.id === undefined) {
|
|
||||||
this.units.push(i.unit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.units_loading = false
|
}
|
||||||
})
|
this.units_loading = false
|
||||||
.catch((err) => {
|
}).catch((err) => {
|
||||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_FETCH)
|
console.log(err)
|
||||||
})
|
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
|
||||||
|
})
|
||||||
},
|
},
|
||||||
searchIngredients: function (query) {
|
searchIngredients: function (query) {
|
||||||
this.ingredients_loading = true
|
this.ingredients_loading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user