From d78ef4d7e99893c6debb4d98a0638c82ca93460e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20Miku=C5=A1?= Date: Sun, 15 Dec 2024 13:58:49 +0100 Subject: [PATCH] Always pull search token from api --- src/components/Cocktail/CocktailForm.vue | 10 ++++++++-- src/components/Cocktail/CocktailImport.vue | 17 ++++++++++++++++- src/components/Cocktail/CocktailIndex.vue | 4 ++-- src/components/Cocktail/IngredientModal.vue | 4 +++- src/components/Cocktail/SubstituteModal.vue | 10 +++++++++- src/components/Ingredient/IngredientForm.vue | 18 +++++++++++++----- src/components/IngredientFinder.vue | 15 ++++++++++----- .../Search/FilterIngredientsModal.vue | 10 +++++++++- 8 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/components/Cocktail/CocktailForm.vue b/src/components/Cocktail/CocktailForm.vue index 4fd6a0bb..3222bd67 100644 --- a/src/components/Cocktail/CocktailForm.vue +++ b/src/components/Cocktail/CocktailForm.vue @@ -72,7 +72,7 @@ @@ -82,7 +82,7 @@

{{ $t('media') }}

@@ -171,6 +171,10 @@ export default { return { appState: appState, + bar: { + search_host: null, + search_token: null, + }, showDialog: false, showSubstituteDialog: false, cocktailIngredientForEdit: {}, @@ -210,6 +214,8 @@ export default { this.isLoading = true const cocktailId = this.$route.query.id || null + this.bar = (await BarAssistantClient.getBar(this.appState.bar.id)).data ?? {} + if (cocktailId) { await BarAssistantClient.getCocktail(cocktailId).then(resp => { resp.data.description = Utils.decodeHtml(resp.data.description) diff --git a/src/components/Cocktail/CocktailImport.vue b/src/components/Cocktail/CocktailImport.vue index 9d730217..9ead677c 100644 --- a/src/components/Cocktail/CocktailImport.vue +++ b/src/components/Cocktail/CocktailImport.vue @@ -13,6 +13,7 @@ import { useI18n } from 'vue-i18n' import type { components } from '@/api/api' import { useTitle } from '@/composables/title' +import AppState from '@/AppState' interface Ingredient { id: string, name: string, @@ -66,6 +67,7 @@ interface Draft1Schema { }[]; } type Cocktail = components["schemas"]["Cocktail"] +type Bar = components["schemas"]["Bar"] type Glass = components["schemas"]["Glass"] type FullIngredient = components["schemas"]["Ingredient"] type CocktailMethod = components["schemas"]["CocktailMethod"] @@ -99,6 +101,8 @@ const ingredientEdit = ref(null) const result = ref({} as LocalSchema) @@ -121,6 +125,8 @@ const cocktailTags = computed({ useTitle(t('cocktail.import')) +getBar(appState.bar.id) + function clearImport() { similarCocktails.value = [] source.value = null @@ -439,6 +445,15 @@ async function findSimilarCocktails(name: string): Promise { isLoadingSimilar.value = false similarCocktails.value = response?.data ?? [] } + +async function getBar(barId: number): Promise { + isLoading.value = true + const resp = await BarAssistantClient.getBar(barId) + if (resp) { + bar.value = resp.data + } + isLoading.value = false +} diff --git a/src/components/Cocktail/IngredientModal.vue b/src/components/Cocktail/IngredientModal.vue index a124ab8e..cfca14e6 100644 --- a/src/components/Cocktail/IngredientModal.vue +++ b/src/components/Cocktail/IngredientModal.vue @@ -20,6 +20,8 @@ interface FinderIngredient { const emit = defineEmits(['close', 'ingredient-changed']) const props = defineProps<{ cocktailIngredient: CocktailIngredient, + searchHost: string, + searchToken: string, }>() const originalCocktailingredient = JSON.parse(JSON.stringify(props.cocktailIngredient)) as CocktailIngredient @@ -59,7 +61,7 @@ function selectIngredient(item: FinderIngredient): void {

{{ t('ingredient.units-help') }}

- +
{{ t('ingredient.dialog.current') }}:

{{ localCocktailingredient.ingredient.name }}

diff --git a/src/components/Cocktail/SubstituteModal.vue b/src/components/Cocktail/SubstituteModal.vue index 45c0a1f9..24f4be7d 100644 --- a/src/components/Cocktail/SubstituteModal.vue +++ b/src/components/Cocktail/SubstituteModal.vue @@ -3,7 +3,7 @@
{{ $t('ingredient.dialog.select-substitutes') }}

{{ $t('ingredient.dialog.select-substitutes-for', {name: cocktailIngredient.ingredient.name}) }}

- +

{{ $t('substitutes') }}:

@@ -61,6 +61,14 @@ export default { AmountInput, }, props: { + searchHost: { + type: String, + required: true, + }, + searchToken: { + type: String, + required: true, + }, value: { type: Object, default() { diff --git a/src/components/Ingredient/IngredientForm.vue b/src/components/Ingredient/IngredientForm.vue index 1145208f..213e2699 100644 --- a/src/components/Ingredient/IngredientForm.vue +++ b/src/components/Ingredient/IngredientForm.vue @@ -52,8 +52,8 @@
-
- +
+
{{ ingredient.parent_ingredient.name }} · {{ $t('remove') }}
@@ -61,9 +61,9 @@
-
+
- +
    @@ -146,6 +146,7 @@ import SaltRimDialog from '../Dialog/SaltRimDialog.vue' import CategoryForm from '../Settings/CategoryForm.vue' import CloseButton from '../CloseButton.vue' import { useTitle } from '@/composables/title' +import AppState from '@/AppState.js' export default { components: { @@ -162,11 +163,16 @@ export default { }, data() { return { + appState: new AppState(), isLoading: false, isParent: false, isComplex: false, showCategoryDialog: false, ingredientCategoryId: null, + bar: { + search_host: null, + search_token: null, + }, ingredient: { id: null, color: '#000', @@ -199,11 +205,13 @@ export default { }, {}) } }, - created() { + async created() { useTitle(this.$t('ingredient.add')) const ingredientId = this.$route.query.id || null + this.bar = (await BarAssistantClient.getBar(this.appState.bar.id)).data ?? {} + if (ingredientId) { this.ingredient.id = ingredientId this.refreshIngredient() diff --git a/src/components/IngredientFinder.vue b/src/components/IngredientFinder.vue index 994dfa92..4ec5a320 100644 --- a/src/components/IngredientFinder.vue +++ b/src/components/IngredientFinder.vue @@ -32,18 +32,23 @@