mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
Merge branch 'feature/vue3' of https://github.com/vabene1111/recipes into feature/vue3
This commit is contained in:
@@ -48,7 +48,7 @@ class FoodPropertyHelper:
|
|||||||
found_property = False
|
found_property = False
|
||||||
# if food has a value for the given property type (no matter if conversion is possible)
|
# if food has a value for the given property type (no matter if conversion is possible)
|
||||||
has_property_value = False
|
has_property_value = False
|
||||||
if i.food.properties_food_amount == 0 or i.food.properties_food_unit is None: # if food is configured incorrectly
|
if i.food.properties_food_amount == 0 or i.food.properties_food_unit is None and not (i.amount == 0 or i.no_amount): # if food is configured incorrectly
|
||||||
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': {'id': i.food.id, 'name': i.food.name}, 'value': None}
|
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': {'id': i.food.id, 'name': i.food.name}, 'value': None}
|
||||||
computed_properties[pt.id]['missing_value'] = True
|
computed_properties[pt.id]['missing_value'] = True
|
||||||
else:
|
else:
|
||||||
@@ -62,7 +62,7 @@ class FoodPropertyHelper:
|
|||||||
computed_properties[pt.id]['food_values'] = self.add_or_create(
|
computed_properties[pt.id]['food_values'] = self.add_or_create(
|
||||||
computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food)
|
computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food)
|
||||||
if not found_property:
|
if not found_property:
|
||||||
if i.amount == 0: # don't count ingredients without an amount as missing
|
if i.amount == 0 or i.no_amount: # don't count ingredients without an amount as missing
|
||||||
computed_properties[pt.id]['missing_value'] = computed_properties[pt.id]['missing_value'] or False # don't override if another food was already missing
|
computed_properties[pt.id]['missing_value'] = computed_properties[pt.id]['missing_value'] or False # don't override if another food was already missing
|
||||||
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': {'id': i.food.id, 'name': i.food.name}, 'value': 0}
|
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': {'id': i.food.id, 'name': i.food.name}, 'value': 0}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<v-list-item border v-for="fv in dialogProperty.foodValues" :key="`${dialogProperty.id}_${fv.id}`">
|
<v-list-item border v-for="fv in dialogProperty.foodValues" :key="`${dialogProperty.id}_${fv.id}`">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<v-progress-circular size="55" width="5" :model-value="(fv.value/dialogProperty.propertyAmountTotal)*100"
|
<v-progress-circular size="55" width="5" :model-value="(fv.value/dialogProperty.propertyAmountTotal)*100"
|
||||||
:color="colorScale((fv.value/dialogProperty.propertyAmountTotal)*100)" v-if="fv.value != null">
|
:color="colorScale((fv.value/dialogProperty.propertyAmountTotal)*100)" v-if="fv.value != null && dialogProperty.propertyAmountTotal > 0">
|
||||||
{{ Math.round((fv.value / dialogProperty.propertyAmountTotal) * 100) }}%
|
{{ Math.round((fv.value / dialogProperty.propertyAmountTotal) * 100) }}%
|
||||||
</v-progress-circular>
|
</v-progress-circular>
|
||||||
<v-progress-circular size="55" width="5" v-if="fv.value == null">?</v-progress-circular>
|
<v-progress-circular size="55" width="5" v-if="fv.value == null">?</v-progress-circular>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-text-field :label="$t('Shopping_input_placeholder')" density="compact" @keyup.enter="addIngredient()" v-model="ingredientInput" :loading="props.loading" hide-detail v-if="!useUserPreferenceStore().deviceSettings.shopping_input_autocomplete"s>
|
<v-text-field :label="$t('Shopping_input_placeholder')" density="compact" @keyup.enter="addIngredient()" v-model="ingredientInput" :loading="props.loading" hide-detail
|
||||||
|
v-if="!useUserPreferenceStore().deviceSettings.shopping_input_autocomplete" s>
|
||||||
<template #append>
|
<template #append>
|
||||||
<v-btn
|
<v-btn
|
||||||
density="comfortable"
|
density="comfortable"
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import {PropType, ref} from "vue";
|
import {PropType, ref} from "vue";
|
||||||
import {ApiApi, Food, IngredientString, MealPlan, ShoppingListEntry, ShoppingListRecipe} from "@/openapi";
|
import {ApiApi, Food, IngredientString, MealPlan, ShoppingListEntry, ShoppingListRecipe, Unit} from "@/openapi";
|
||||||
import {useShoppingStore} from "@/stores/ShoppingStore";
|
import {useShoppingStore} from "@/stores/ShoppingStore";
|
||||||
import {ErrorMessageType, MessageType, useMessageStore} from "@/stores/MessageStore";
|
import {ErrorMessageType, MessageType, useMessageStore} from "@/stores/MessageStore";
|
||||||
import Multiselect from "@vueform/multiselect";
|
import Multiselect from "@vueform/multiselect";
|
||||||
@@ -60,32 +61,36 @@ const loading = ref(false)
|
|||||||
/**
|
/**
|
||||||
* add new ingredient from ingredient text input
|
* add new ingredient from ingredient text input
|
||||||
*/
|
*/
|
||||||
function addIngredient() {
|
function addIngredient(amount: number, unit: Unit|null, food: Food|null) {
|
||||||
|
let sle = {
|
||||||
|
amount: Math.max(amount, 1),
|
||||||
|
unit: unit,
|
||||||
|
food: food,
|
||||||
|
} as ShoppingListEntry
|
||||||
|
|
||||||
|
console.log('adding SLR ? ', props.mealPlan)
|
||||||
|
if (props.mealPlan) {
|
||||||
|
console.log('yes')
|
||||||
|
sle.mealplanId = props.mealPlan.id
|
||||||
|
}
|
||||||
|
|
||||||
|
useShoppingStore().createObject(sle, true).finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
ingredientInput.value = ''
|
||||||
|
|
||||||
|
ingredientInputIcon.value = 'fa-solid fa-check'
|
||||||
|
setTimeout(() => {
|
||||||
|
ingredientInputIcon.value = 'fa-solid fa-plus'
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseIngredient() {
|
||||||
const api = new ApiApi()
|
const api = new ApiApi()
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
||||||
api.apiIngredientFromStringCreate({ingredientString: {text: ingredientInput.value} as IngredientString}).then(r => {
|
api.apiIngredientFromStringCreate({ingredientString: {text: ingredientInput.value} as IngredientString}).then(r => {
|
||||||
let sle = {
|
addIngredient(r.amount, r.unit, r.food)
|
||||||
amount: Math.max(r.amount, 1),
|
|
||||||
unit: r.unit,
|
|
||||||
food: r.food,
|
|
||||||
} as ShoppingListEntry
|
|
||||||
|
|
||||||
console.log('adding SLR ? ', props.mealPlan)
|
|
||||||
if (props.mealPlan) {
|
|
||||||
console.log('yes')
|
|
||||||
sle.mealplanId = props.mealPlan.id
|
|
||||||
}
|
|
||||||
|
|
||||||
useShoppingStore().createObject(sle, true).finally(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
ingredientInput.value = ''
|
|
||||||
|
|
||||||
ingredientInputIcon.value = 'fa-solid fa-check'
|
|
||||||
setTimeout(() => {
|
|
||||||
ingredientInputIcon.value = 'fa-solid fa-plus'
|
|
||||||
}, 1000)
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
useMessageStore().addError(ErrorMessageType.CREATE_ERROR, err)
|
useMessageStore().addError(ErrorMessageType.CREATE_ERROR, err)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -99,14 +104,14 @@ function createObject(object: any, select$: Multiselect) {
|
|||||||
ingredientModelInput.value = {} as Food
|
ingredientModelInput.value = {} as Food
|
||||||
select$.close()
|
select$.close()
|
||||||
select$.clearSearch()
|
select$.clearSearch()
|
||||||
addIngredient()
|
parseIngredient()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectObject(foodId: number, food: Food, select$: Multiselect) {
|
function selectObject(foodId: number, food: Food, select$: Multiselect) {
|
||||||
ingredientInput.value = food.name
|
//ingredientInput.value = food.name
|
||||||
ingredientModelInput.value = {} as Food
|
ingredientModelInput.value = {} as Food
|
||||||
addIngredient()
|
addIngredient(1, null, food)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +123,7 @@ function search(query: string) {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
let api = new ApiApi()
|
let api = new ApiApi()
|
||||||
|
|
||||||
return api.apiFoodList({query: query, page: 1, pageSize: 25}).then(r => {
|
return api.apiFoodList({query: query, page: 1, pageSize: 25}).then(r => {
|
||||||
return r.results
|
return r.results
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user