diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html index 1b6de7102..8404527d8 100644 --- a/cookbook/templates/url_import.html +++ b/cookbook/templates/url_import.html @@ -908,28 +908,22 @@ // }) }, searchUnits: function (query) { - let apiFactory = new ApiApiFactory() - this.units_loading = true - apiFactory - .listUnits(query, 1, this.options_limit) - .then((response) => { - this.units = response.data.results - - if (this.recipe !== undefined) { - for (let s of this.recipe.steps) { - for (let i of s.ingredients) { - if (i.unit !== null && i.unit.id === undefined) { - this.units.push(i.unit) - } - } + this.$http.get("{% url 'dal_unit' %}" + '?q=' + query).then((response) => { + this.units = response.data.results; + if (this.recipe_data !== undefined) { + for (let x of Array.from(this.recipe_data.recipeIngredient)) { + if (x.unit !== null && x.unit.text !== '') { + this.units = this.units.filter(item => item.text !== x.unit.text) + this.units.push(x.unit) } } - this.units_loading = false - }) - .catch((err) => { - StandardToasts.makeStandardToast(StandardToasts.FAIL_FETCH) - }) + } + this.units_loading = false + }).catch((err) => { + console.log(err) + this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') + }) }, searchIngredients: function (query) { this.ingredients_loading = true diff --git a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue index 669af365e..7a66b7c4b 100644 --- a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue +++ b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue @@ -1,6 +1,6 @@ - + @@ -8,15 +8,21 @@ - + - + - + - + @@ -26,15 +32,18 @@ - + - {{ $t("New_Recipe") }} + {{ $t("New_Recipe") }} - {{ $t("Import") }} + {{ $t("Import") }} - + - - + + - - + + - - + + - - + + - - + + - {{ $t("Search Settings") }} + {{ + $t("Search Settings") + }} - - + + - - + + - - + + - - + + - {{ $t("Close") }} + {{ $t("Close") }} + @@ -138,8 +182,12 @@ > - - {{ $t("or") }} + + {{ $t("or") }} {{ $t("and") }} @@ -178,8 +226,13 @@ > - - {{ $t("or") }} + + {{ + $t("or") + }} {{ $t("and") }} @@ -203,8 +256,13 @@ > - - {{ $t("or") }} + + {{ + $t("or") + }} {{ $t("and") }} @@ -227,7 +285,7 @@ style="flex-grow: 1; flex-shrink: 1; flex-basis: 0" /> - + @@ -241,7 +299,9 @@ - {{ $t("Page") }} {{ search.pagination_page }}/{{ Math.ceil(pagination_count / ui.page_size) }} + {{ $t("Page") }} {{ search.pagination_page }}/{{ + Math.ceil(pagination_count / ui.page_size) + }} {{ $t("Reset") }} @@ -249,18 +309,24 @@ - + - + - + - + @@ -271,7 +337,7 @@