fix: restore create-item button in recipe dropdowns (categories, tags, tools) (#7564)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Zdenek Stursa
2026-04-30 17:16:27 +02:00
committed by GitHub
parent 5b37eb012c
commit bc3ae3c6c0
2 changed files with 59 additions and 2 deletions

View File

@@ -88,7 +88,7 @@
</div>
</template>
<template #append-item>
<div class="px-2">
<div v-if="showCreateUnit" class="px-2">
<BaseButton
block
size="small"
@@ -147,7 +147,7 @@
</div>
</template>
<template #append-item>
<div class="px-2">
<div v-if="showCreateFood" class="px-2">
<BaseButton
block
size="small"
@@ -344,6 +344,11 @@ const foodData = useFoodData();
const foodAutocomplete = ref<HTMLInputElement>();
const { search: foodSearch, filtered: filteredFoods } = useSearch(foodStore.store);
const showCreateFood = computed(() =>
!!foodSearch.value
&& !filteredFoods.value.some((f: any) => (f.name ?? "").toLowerCase() === foodSearch.value.toLowerCase()),
);
async function createAssignFood() {
foodData.data.name = foodSearch.value;
model.value.food = await foodStore.actions.createOne(foodData.data) || undefined;
@@ -376,6 +381,11 @@ const unitsData = useUnitData();
const unitAutocomplete = ref<HTMLInputElement>();
const { search: unitSearch, filtered: filteredUnits } = useSearch(unitStore.store);
const showCreateUnit = computed(() =>
!!unitSearch.value
&& !filteredUnits.value.some((u: any) => (u.name ?? "").toLowerCase() === unitSearch.value.toLowerCase()),
);
async function createAssignUnit() {
unitsData.data.name = unitSearch.value;
model.value.unit = await unitStore.actions.createOne(unitsData.data) || undefined;