Files
mealie/frontend/app/components/Domain/Recipe/RecipeStepCooking.vue
T
jfmcarreira 05cfb98ceb
Release Drafter / auto_label (push) Skipped
Backend Lint and Test / tests (sqlite) (push) Canceled after 0s
Backend Lint and Test / tests (postgres) (push) Canceled after 0s
Docker Nightly Production / Backend Server Tests (push) Canceled after 0s
Frontend Lint and Test / lint (push) Canceled after 0s
Docker Nightly Production / Frontend Tests (push) Canceled after 0s
Build Package / Build frontend and wheel (push) Canceled after 0s
Docker Nightly Production / Build Package (push) Canceled after 0s
Docker Nightly Production / Build E2E Image Cache (push) Canceled after 0s
Docker Nightly Production / Build Tagged Release (push) Canceled after 0s
Docker Nightly Production / Notify Discord (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
Release Drafter / draft_release (push) Canceled after 0s
feat(recipe): add step quantities and appliance settings
2026-11-30 14:44:17 +00:00

79 lines
2.9 KiB
Vue

<template>
<div v-if="edit" class="mt-3" @click.stop>
<div class="text-subtitle-2">
{{ $t("recipe.step-cooking") }}
</div>
<v-text-field :model-value="modelValue?.appliance" :label="$t('recipe.step-appliance')" clearable density="compact" @update:model-value="update('appliance', $event || null)" />
<v-number-input
:model-value="inputTemperature"
:label="$t('recipe.step-temperature')"
:precision="0"
:step="1"
:hint="fractionalTemperature ? $t('recipe.step-temperature-saved', { temperature: modelValue?.temperatureCelsius }) : undefined"
persistent-hint
hide-details="auto"
density="compact"
control-variant="hidden"
clearable
@update:model-value="updateTemperature"
/>
<v-text-field
:model-value="modelValue?.speed"
:label="$t('recipe.step-speed')"
clearable
density="compact"
@change="updateSpeed(($event.target as HTMLInputElement).value)"
@click:clear="updateSpeed(null)"
/>
<v-text-field :model-value="modelValue?.mode" :label="$t('recipe.step-mode')" clearable density="compact" @update:model-value="update('mode', $event || null)" />
<v-btn v-if="modelValue" variant="text" size="small" @click="emit('update:modelValue', null)">
{{ $t("recipe.step-cooking-clear") }}
</v-btn>
</div>
<div v-else-if="modelValue && parts.length" class="text-body-2 mt-2">
{{ parts.join(" · ") }}
</div>
</template>
<script setup lang="ts">
import type { StepCooking } from "~/lib/api/types/recipe";
const props = defineProps<{ modelValue?: StepCooking | null; edit?: boolean }>();
const emit = defineEmits<{ "update:modelValue": [value: StepCooking | null] }>();
const { t } = useI18n();
// Keep imported fractional temperatures until the user changes the displayed value.
const inputTemperature = computed(() => props.modelValue?.temperatureCelsius == null
? null
: Math.round(props.modelValue.temperatureCelsius));
const fractionalTemperature = computed(() => props.modelValue?.temperatureCelsius != null
&& !Number.isInteger(props.modelValue.temperatureCelsius));
function updateTemperature(value: number | null) {
if (value !== inputTemperature.value) {
update("temperatureCelsius", value);
}
}
function update<K extends keyof StepCooking>(key: K, value: StepCooking[K]) {
emit("update:modelValue", { ...props.modelValue, [key]: value });
}
function updateSpeed(value: string | null) {
const text = String(value ?? "").trim();
const numeric = Number(text);
update("speed", !text ? null : Number.isFinite(numeric) ? numeric : text);
}
const parts = computed(() => {
const cooking = props.modelValue;
if (!cooking) return [];
return [
cooking.appliance,
cooking.temperatureCelsius != null ? `${cooking.temperatureCelsius} °C` : null,
cooking.speed != null ? t("recipe.step-speed-value", { speed: cooking.speed }) : null,
cooking.mode,
].filter(Boolean);
});
</script>