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
73 lines
3.6 KiB
Vue
73 lines
3.6 KiB
Vue
<template>
|
|
<div @click.stop>
|
|
<v-select :model-value="kind" :items="allocationOptions" :label="$t('recipe.allocation-kind')" density="compact" @update:model-value="setKind" />
|
|
<v-number-input
|
|
v-if="kind === 'partial'"
|
|
:model-value="modelValue.quantity"
|
|
:label="$t('recipe.step-quantity')"
|
|
:min="0"
|
|
:precision="null"
|
|
density="compact"
|
|
clearable
|
|
@update:model-value="update('quantity', $event)"
|
|
/>
|
|
<v-select :model-value="modelValue.weighing ?? 'unspecified'" :items="weighingOptions" :label="$t('recipe.weighing-intent')" density="compact" @update:model-value="update('weighing', $event)" />
|
|
<v-text-field :model-value="modelValue.role" :label="$t('recipe.allocation-role')" clearable density="compact" @update:model-value="update('role', $event || null)" />
|
|
<v-text-field :model-value="modelValue.destination" :label="$t('recipe.allocation-destination')" clearable density="compact" @update:model-value="update('destination', $event || null)" />
|
|
<v-number-input
|
|
:model-value="modelValue.quantityMinimum"
|
|
:label="$t('recipe.allocation-minimum')"
|
|
:min="0"
|
|
:precision="null"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('quantityMinimum', $event)"
|
|
/>
|
|
<v-number-input
|
|
:model-value="modelValue.quantityMaximum"
|
|
:label="$t('recipe.allocation-maximum')"
|
|
:min="0"
|
|
:precision="null"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('quantityMaximum', $event)"
|
|
/>
|
|
<v-number-input
|
|
:model-value="modelValue.containerCount"
|
|
:label="$t('recipe.allocation-containers')"
|
|
:min="1"
|
|
:precision="0"
|
|
clearable
|
|
density="compact"
|
|
@update:model-value="update('containerCount', $event)"
|
|
/>
|
|
<v-checkbox :model-value="modelValue.approximate ?? false" :label="$t('recipe.allocation-approximate')" density="compact" @update:model-value="update('approximate', $event)" />
|
|
<v-text-field :model-value="modelValue.sourceText" :label="$t('recipe.allocation-source')" clearable density="compact" @update:model-value="update('sourceText', $event || null)" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from "vue";
|
|
import { useI18n } from "vue-i18n";
|
|
import type { IngredientReferences } from "~/lib/api/types/recipe";
|
|
|
|
const props = defineProps<{ modelValue: IngredientReferences }>();
|
|
const emit = defineEmits<{ "update:modelValue": [value: IngredientReferences] }>();
|
|
const { t } = useI18n();
|
|
const kind = computed(() => props.modelValue.quantityKind ?? (props.modelValue.quantity == null ? "full" : "partial"));
|
|
const kinds = ["full", "partial", "remaining", "unknown", "prepared", "asNeeded", "referenceOnly"] as const;
|
|
const allocationOptions = computed(() => kinds.map(value => ({ title: t(`recipe.allocation-${value}`), value })));
|
|
const weighingOptions = computed(() => ["unspecified", "manual", ...(kind.value === "full" || kind.value === "partial" ? ["weigh"] : [])].map(value => ({ title: t(`recipe.weighing-${value}`), value })));
|
|
function update<K extends keyof IngredientReferences>(key: K, value: IngredientReferences[K]) {
|
|
emit("update:modelValue", { ...props.modelValue, [key]: value });
|
|
}
|
|
function setKind(value: NonNullable<IngredientReferences["quantityKind"]>) {
|
|
emit("update:modelValue", {
|
|
...props.modelValue,
|
|
quantityKind: value,
|
|
quantity: value === "full" ? null : value === "partial" ? (kind.value === "partial" ? props.modelValue.quantity : null) : 0,
|
|
weighing: value === "full" || value === "partial" ? props.modelValue.weighing : "unspecified",
|
|
});
|
|
}
|
|
</script>
|