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
289 lines
14 KiB
Vue
289 lines
14 KiB
Vue
<template>
|
|
<div class="mt-2">
|
|
<v-select
|
|
:model-value="modelValue?.actionType"
|
|
:items="actionTypes"
|
|
:label="$t('recipe.operation-type')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('actionType', $event)"
|
|
/>
|
|
<v-select
|
|
:model-value="modelValue?.timerType"
|
|
:items="timerTypes"
|
|
:label="$t('recipe.operation-timer-type')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('timerType', $event)"
|
|
/>
|
|
<v-select
|
|
:model-value="modelValue?.durationKind"
|
|
:items="durationKinds"
|
|
:label="$t('recipe.operation-duration-kind')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('durationKind', $event)"
|
|
/>
|
|
<v-select
|
|
:model-value="modelValue?.speedKind"
|
|
:items="speedKinds"
|
|
:label="$t('recipe.operation-speed-kind')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('speedKind', $event)"
|
|
/>
|
|
<v-text-field :model-value="modelValue?.applianceInstance" :label="$t('recipe.operation-instance')" clearable density="compact" @update:model-value="update('applianceInstance', $event || null)" />
|
|
|
|
<div v-for="range in ranges" :key="range.key" class="d-flex ga-2">
|
|
<v-number-input
|
|
:model-value="modelValue?.[range.key]?.minimum"
|
|
:label="$t(range.minimum)"
|
|
:precision="range.key === 'repetitionRange' ? 0 : null"
|
|
density="compact"
|
|
clearable
|
|
@update:model-value="setRange(range.key, 'minimum', $event)"
|
|
/>
|
|
<v-number-input
|
|
:model-value="modelValue?.[range.key]?.maximum"
|
|
:label="$t(range.maximum)"
|
|
:precision="range.key === 'repetitionRange' ? 0 : null"
|
|
density="compact"
|
|
clearable
|
|
@update:model-value="setRange(range.key, 'maximum', $event)"
|
|
/>
|
|
</div>
|
|
<v-text-field :model-value="modelValue?.durationCondition" :label="$t('recipe.operation-duration-condition')" clearable density="compact" @update:model-value="update('durationCondition', $event || null)" />
|
|
<v-text-field
|
|
:model-value="(modelValue?.speedProgression ?? []).join(', ')"
|
|
:label="$t('recipe.operation-speed-progression')"
|
|
:error-messages="progressionError ? [$t('recipe.operation-invalid-progression')] : []"
|
|
clearable
|
|
density="compact"
|
|
@change="setProgression(($event.target as HTMLInputElement).value)"
|
|
@click:clear="setProgression('')"
|
|
/>
|
|
<v-select
|
|
:model-value="modelValue?.optional"
|
|
:items="optionalOptions"
|
|
:label="$t('recipe.operation-optional')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('optional', $event)"
|
|
/>
|
|
<v-text-field :model-value="modelValue?.condition" :label="$t('recipe.operation-condition')" clearable density="compact" @update:model-value="update('condition', $event || null)" />
|
|
<v-checkbox :model-value="modelValue?.requiresConfirmation ?? false" :label="$t('recipe.operation-confirmation')" density="compact" @update:model-value="update('requiresConfirmation', $event)" />
|
|
<v-combobox
|
|
:model-value="modelValue?.dependsOnStepIds ?? []"
|
|
:label="$t('recipe.operation-dependencies')"
|
|
multiple
|
|
chips
|
|
density="compact"
|
|
@update:model-value="update('dependsOnStepIds', $event)"
|
|
/>
|
|
<v-number-input
|
|
:model-value="modelValue?.repetitions"
|
|
:label="$t('recipe.operation-repetitions')"
|
|
:min="1"
|
|
:precision="0"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('repetitions', $event)"
|
|
/>
|
|
|
|
<div class="text-subtitle-2">
|
|
{{ $t("recipe.operation-accessories") }}
|
|
</div>
|
|
<div v-for="(accessory, index) in modelValue?.accessories ?? []" :key="index" class="d-flex ga-2">
|
|
<v-text-field :model-value="accessory.name" :label="$t('recipe.operation-name')" density="compact" @update:model-value="setAccessory(index, 'name', $event)" />
|
|
<v-select :model-value="accessory.state" :items="accessoryStates" :label="$t('recipe.operation-state')" density="compact" @update:model-value="setAccessory(index, 'state', $event)" />
|
|
<v-btn variant="text" @click="removeAccessory(index)">
|
|
{{ $t("general.delete") }}
|
|
</v-btn>
|
|
</div>
|
|
<v-btn size="small" variant="text" @click="addAccessory">
|
|
{{ $t("recipe.operation-add-accessory") }}
|
|
</v-btn>
|
|
|
|
<div class="text-subtitle-2 mt-2">
|
|
{{ $t("recipe.operation-parameters") }}
|
|
</div>
|
|
<div v-for="(parameter, index) in modelValue?.modeParameters ?? []" :key="index">
|
|
<v-text-field :model-value="parameter.name" :label="$t('recipe.operation-name')" density="compact" @update:model-value="setParameter(index, 'name', $event)" />
|
|
<v-select
|
|
:model-value="parameter.kind ?? 'text'"
|
|
:items="parameterKinds"
|
|
:label="$t('recipe.operation-parameter-kind')"
|
|
:hint="$t('recipe.operation-parameter-kind-hint')"
|
|
persistent-hint
|
|
density="compact"
|
|
@update:model-value="setParameterKind(index, $event)"
|
|
/>
|
|
<v-number-input
|
|
v-if="parameter.kind === 'number'"
|
|
:model-value="typeof parameter.value === 'number' ? parameter.value : null"
|
|
:label="$t('recipe.operation-parameter-value')"
|
|
:precision="null"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="setParameter(index, 'value', $event)"
|
|
/>
|
|
<v-select
|
|
v-else-if="parameter.kind === 'boolean'"
|
|
:model-value="parameter.value"
|
|
:items="optionalOptions"
|
|
:label="$t('recipe.operation-parameter-value')"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="setParameter(index, 'value', $event)"
|
|
/>
|
|
<v-text-field v-else-if="parameter.kind !== 'range'" :model-value="parameter.value == null ? '' : String(parameter.value)" :label="$t('recipe.operation-parameter-value')" density="compact" @change="setParameter(index, 'value', ($event.target as HTMLInputElement).value)" />
|
|
<v-text-field :model-value="parameter.unit" :label="$t('recipe.operation-parameter-unit')" clearable density="compact" @update:model-value="setParameter(index, 'unit', $event || null)" />
|
|
<div v-if="parameter.kind === 'range'" class="d-flex ga-2">
|
|
<v-number-input
|
|
:model-value="parameter.minimum"
|
|
:label="$t('recipe.operation-parameter-minimum')"
|
|
:precision="null"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="setParameter(index, 'minimum', $event)"
|
|
/>
|
|
<v-number-input
|
|
:model-value="parameter.maximum"
|
|
:label="$t('recipe.operation-parameter-maximum')"
|
|
:precision="null"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="setParameter(index, 'maximum', $event)"
|
|
/>
|
|
</div>
|
|
<v-btn size="small" variant="text" @click="removeParameter(index)">
|
|
{{ $t("general.delete") }}
|
|
</v-btn>
|
|
</div>
|
|
<v-btn size="small" variant="text" @click="addParameter">
|
|
{{ $t("recipe.operation-add-parameter") }}
|
|
</v-btn>
|
|
|
|
<div class="text-subtitle-2 mt-2">
|
|
{{ $t("recipe.operation-reviews") }}
|
|
</div>
|
|
<div v-for="(review, index) in modelValue?.reviews ?? []" :key="index" class="mb-3">
|
|
<v-select :model-value="review.category" :items="reviewCategories" :label="$t('recipe.operation-review-category')" density="compact" @update:model-value="setReview(index, 'category', $event)" />
|
|
<v-text-field :model-value="review.source" :readonly="!!review.history?.length" :label="$t('recipe.operation-review-source')" density="compact" @update:model-value="setReview(index, 'source', $event)" />
|
|
<v-text-field :model-value="review.reason" :readonly="!!review.history?.length" :label="$t('recipe.operation-review-reason')" density="compact" @update:model-value="setReview(index, 'reason', $event)" />
|
|
<v-select
|
|
v-if="review.category === 'ingredient'"
|
|
:model-value="review.candidateIngredientIds ?? []"
|
|
:items="ingredientOptions"
|
|
:label="$t('recipe.operation-review-candidates')"
|
|
multiple
|
|
chips
|
|
:readonly="!!review.history?.length"
|
|
density="compact"
|
|
@update:model-value="setReview(index, 'candidateIngredientIds', $event)"
|
|
/>
|
|
<v-select
|
|
v-if="review.category === 'ingredient'"
|
|
:items="ingredientOptions.filter(item => review.candidateIngredientIds?.includes(item.value))"
|
|
:label="$t('recipe.operation-review-link')"
|
|
density="compact"
|
|
@update:model-value="emit('linkIngredient', $event)"
|
|
/>
|
|
<v-text-field :model-value="review.resolution" :label="$t('recipe.operation-review-resolution')" clearable density="compact" @update:model-value="setReview(index, 'resolution', $event || null)" />
|
|
<v-select :model-value="review.status ?? 'unresolved'" :items="reviewStatuses" :label="$t('recipe.operation-review-status')" density="compact" @update:model-value="setReview(index, 'status', $event)" />
|
|
<details v-if="review.history?.length">
|
|
<summary>{{ $t("recipe.operation-review-history") }}</summary>
|
|
<div v-for="(event, eventIndex) in review.history" :key="eventIndex">
|
|
{{ event.at }} — {{ $t(`recipe.review-status-${event.status}`) }} — {{ event.resolution }}
|
|
<pre class="review-history">{{ event.content }}</pre>
|
|
</div>
|
|
</details>
|
|
<v-btn v-if="!review.history?.length" size="small" variant="text" @click="removeReview(index)">
|
|
{{ $t("general.delete") }}
|
|
</v-btn>
|
|
</div>
|
|
<v-btn size="small" variant="text" @click="addReview">
|
|
{{ $t("recipe.operation-add-review") }}
|
|
</v-btn>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import type { RecipeIngredient, StepAccessory, StepCooking, StepParameter, StepRange, StepReview } from "~/lib/api/types/recipe";
|
|
|
|
const props = defineProps<{ modelValue?: StepCooking | null; ingredients?: RecipeIngredient[] }>();
|
|
const emit = defineEmits<{ "update:modelValue": [value: StepCooking]; "linkIngredient": [referenceId: string] }>();
|
|
const { t } = useI18n();
|
|
const progressionError = ref(false);
|
|
const options = (prefix: string, values: string[]) => values.map(value => ({ title: t(`recipe.${prefix}-${value}`), value }));
|
|
const actionTypes = computed(() => options("action", ["manual", "machine", "oven", "waiting", "weighing"]));
|
|
const timerTypes = computed(() => options("timer", ["machine", "manual", "oven", "resting"]));
|
|
const durationKinds = computed(() => options("setting", ["fixed", "range", "userSelected", "condition"]));
|
|
const speedKinds = computed(() => options("setting", ["fixed", "range", "progression"]));
|
|
const parameterKinds = computed(() => options("parameter-kind", ["text", "number", "boolean", "range"]));
|
|
const accessoryStates = computed(() => options("accessory", ["installed", "removed", "unknown", "conditional", "open", "closed"]));
|
|
const optionalOptions = computed(() => [{ title: t("general.yes"), value: true }, { title: t("general.no"), value: false }]);
|
|
const reviewCategories = computed(() => options("review-category", ["ingredient", "operation", "schema", "unsupported"]));
|
|
const reviewStatuses = computed(() => options("review-status", ["unresolved", "resolved"]));
|
|
const ingredientOptions = computed(() => (props.ingredients ?? []).filter(i => i.referenceId).map(i => ({ title: i.display || i.note || i.referenceId!, value: i.referenceId! })));
|
|
const ranges = [
|
|
{ key: "durationRangeSeconds", minimum: "recipe.operation-duration-minimum", maximum: "recipe.operation-duration-maximum" },
|
|
{ key: "speedRange", minimum: "recipe.operation-speed-minimum", maximum: "recipe.operation-speed-maximum" },
|
|
{ key: "repetitionRange", minimum: "recipe.operation-repeat-minimum", maximum: "recipe.operation-repeat-maximum" },
|
|
] as const;
|
|
|
|
function update<K extends keyof StepCooking>(key: K, value: StepCooking[K]) {
|
|
emit("update:modelValue", { ...props.modelValue, [key]: value });
|
|
}
|
|
function setRange(key: "durationRangeSeconds" | "speedRange" | "repetitionRange", bound: keyof StepRange, value: number | null) {
|
|
const range = { ...props.modelValue?.[key], [bound]: value };
|
|
update(key, range.minimum == null && range.maximum == null ? null : range);
|
|
}
|
|
function setProgression(text: string) {
|
|
const values = text.trim() ? text.split(",").map(value => value.trim()) : [];
|
|
progressionError.value = values.some(value => !value || !Number.isFinite(Number(value)));
|
|
if (!progressionError.value) update("speedProgression", values.map(Number));
|
|
}
|
|
function setAccessory<K extends keyof StepAccessory>(index: number, key: K, value: StepAccessory[K]) {
|
|
const items = [...(props.modelValue?.accessories ?? [])];
|
|
const existing = items[index];
|
|
if (!existing) return;
|
|
items[index] = { ...existing, [key]: value };
|
|
update("accessories", items);
|
|
}
|
|
function addAccessory() { update("accessories", [...(props.modelValue?.accessories ?? []), { name: "", state: "unknown" }]); }
|
|
function removeAccessory(index: number) { update("accessories", (props.modelValue?.accessories ?? []).filter((_, i) => i !== index)); }
|
|
function setParameter<K extends keyof StepParameter>(index: number, key: K, value: StepParameter[K]) {
|
|
const items = [...(props.modelValue?.modeParameters ?? [])];
|
|
const existing = items[index];
|
|
if (!existing) return;
|
|
items[index] = { ...existing, [key]: value };
|
|
update("modeParameters", items);
|
|
}
|
|
function setParameterKind(index: number, kind: NonNullable<StepParameter["kind"]>) {
|
|
const items = [...(props.modelValue?.modeParameters ?? [])];
|
|
const existing = items[index];
|
|
if (!existing || (existing.kind ?? "text") === kind) return;
|
|
items[index] = { ...existing, kind, value: null, minimum: null, maximum: null };
|
|
update("modeParameters", items);
|
|
}
|
|
function addParameter() { update("modeParameters", [...(props.modelValue?.modeParameters ?? []), { name: "" }]); }
|
|
function removeParameter(index: number) { update("modeParameters", (props.modelValue?.modeParameters ?? []).filter((_, i) => i !== index)); }
|
|
function setReview<K extends keyof StepReview>(index: number, key: K, value: StepReview[K]) {
|
|
const items = [...(props.modelValue?.reviews ?? [])];
|
|
const existing = items[index];
|
|
if (!existing) return;
|
|
items[index] = { ...existing, [key]: value };
|
|
update("reviews", items);
|
|
}
|
|
function addReview() { update("reviews", [...(props.modelValue?.reviews ?? []), { category: "operation", status: "unresolved" }]); }
|
|
function removeReview(index: number) { update("reviews", (props.modelValue?.reviews ?? []).filter((_, i) => i !== index)); }
|
|
</script>
|
|
|
|
<style scoped>
|
|
.review-history {
|
|
white-space: pre-wrap;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
</style>
|