Files
mealie/frontend/app/components/Domain/Recipe/RecipeStepCooking.vue
T
jfmcarreira 8dad430650
Release Drafter / auto_label (push) Skipped
Release Drafter / draft_release (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
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
feat(recipe): add step quantities and appliance settings
2026-12-01 13:05:50 +00:00

115 lines
5.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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-select
:model-value="modelValue?.reverse"
:items="directionOptions"
:label="$t('recipe.step-direction')"
clearable
density="compact"
@update:model-value="update('reverse', $event)"
/>
<v-text-field :model-value="modelValue?.mode" :label="$t('recipe.step-mode')" clearable density="compact" @update:model-value="update('mode', $event || null)" />
<RecipeStepOperationDetails :model-value="modelValue" :ingredients="ingredients" @update:model-value="emit('update:modelValue', $event)" @link-ingredient="emit('linkIngredient', $event)" />
<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>
<div v-if="!edit && modelValue?.reviews?.length" class="text-body-2 mt-2">
<div v-for="(review, index) in modelValue.reviews" :key="index">
{{ $t(`recipe.review-category-${review.category}`) }} — {{ $t(`recipe.review-status-${review.status ?? 'unresolved'}`) }}:
{{ review.source }} {{ review.reason }} {{ review.resolution }}
</div>
</div>
</template>
<script setup lang="ts">
import type { RecipeIngredient, StepCooking } from "~/lib/api/types/recipe";
import RecipeStepOperationDetails from "./RecipeStepOperationDetails.vue";
const props = defineProps<{ modelValue?: StepCooking | null; edit?: boolean; ingredients?: RecipeIngredient[] }>();
const emit = defineEmits<{ "update:modelValue": [value: StepCooking | null]; "linkIngredient": [referenceId: string] }>();
const { t } = useI18n();
const directionOptions = computed(() => [
{ title: t("recipe.step-forward"), value: false },
{ title: t("recipe.step-reverse"), value: true },
]);
// 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.reverse === true ? t("recipe.step-reverse") : null,
cooking.mode,
cooking.actionType ? t(`recipe.action-${cooking.actionType}`) : null,
cooking.applianceInstance,
cooking.timerType ? t(`recipe.timer-${cooking.timerType}`) : null,
cooking.durationKind ? t(`recipe.setting-${cooking.durationKind}`) : null,
...(cooking.accessories ?? []).map(accessory => `${accessory.name}: ${t(`recipe.accessory-${accessory.state}`)}`),
cooking.durationRangeSeconds ? `${t("recipe.operation-duration-range")}: ${cooking.durationRangeSeconds.minimum ?? "?"}–${cooking.durationRangeSeconds.maximum ?? "?"} s` : null,
cooking.durationCondition,
cooking.speedRange ? `${t("recipe.operation-speed-range")}: ${cooking.speedRange.minimum ?? "?"}–${cooking.speedRange.maximum ?? "?"}` : null,
cooking.speedProgression?.length ? `${t("recipe.operation-speed-progression")}: ${cooking.speedProgression.join(" → ")}` : null,
...(cooking.modeParameters ?? []).map(parameter => `${parameter.name}: ${parameter.value ?? [parameter.minimum, parameter.maximum].filter(v => v != null).join("–")} ${parameter.unit ?? ""}`),
cooking.optional ? t("recipe.operation-is-optional") : null,
cooking.condition,
cooking.requiresConfirmation ? t("recipe.operation-confirmation") : null,
cooking.repetitions != null ? `${t("recipe.operation-repetitions")}: ${cooking.repetitions}` : null,
cooking.repetitionRange ? `${t("recipe.operation-repetition-range")}: ${cooking.repetitionRange.minimum ?? "?"}–${cooking.repetitionRange.maximum ?? "?"}` : null,
].filter(Boolean);
});
</script>