mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-02-25 03:17:23 -08:00
85 lines
2.3 KiB
Vue
85 lines
2.3 KiB
Vue
<template>
|
|
<div class="d-flex justify-space-between align-center pt-2 pb-3">
|
|
<v-tooltip v-if="!isEditMode" small top color="secondary darken-1">
|
|
<template #activator="{ on, attrs }">
|
|
<RecipeScaleEditButton
|
|
v-model.number="scaleValue"
|
|
v-bind="attrs"
|
|
:recipe-yield="recipe.recipeYield"
|
|
:scaled-yield="scaledYield"
|
|
:basic-yield-num="basicYieldNum"
|
|
:edit-scale="!recipe.settings.disableAmount && !isEditMode"
|
|
v-on="on"
|
|
/>
|
|
</template>
|
|
<span> {{ $t("recipe.edit-scale") }} </span>
|
|
</v-tooltip>
|
|
<v-spacer></v-spacer>
|
|
|
|
<RecipeRating
|
|
v-if="landscape && $vuetify.breakpoint.smAndUp"
|
|
:key="recipe.slug"
|
|
v-model="recipe.rating"
|
|
:recipe-id="recipe.id"
|
|
:slug="recipe.slug"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { computed, defineComponent, ref } from "@nuxtjs/composition-api";
|
|
import RecipeScaleEditButton from "~/components/Domain/Recipe/RecipeScaleEditButton.vue";
|
|
import RecipeRating from "~/components/Domain/Recipe/RecipeRating.vue";
|
|
import { NoUndefinedField } from "~/lib/api/types/non-generated";
|
|
import { Recipe } from "~/lib/api/types/recipe";
|
|
import { usePageState } from "~/composables/recipe-page/shared-state";
|
|
import { useExtractRecipeYield, findMatch } from "~/composables/recipe-page/use-extract-recipe-yield";
|
|
|
|
export default defineComponent({
|
|
components: {
|
|
RecipeScaleEditButton,
|
|
RecipeRating,
|
|
},
|
|
props: {
|
|
recipe: {
|
|
type: Object as () => NoUndefinedField<Recipe>,
|
|
required: true,
|
|
},
|
|
landscape: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
scale: {
|
|
type: Number,
|
|
default: 1,
|
|
},
|
|
},
|
|
setup(props, { emit }) {
|
|
const { isEditMode } = usePageState(props.recipe.slug);
|
|
|
|
const scaleValue = computed<number>({
|
|
get() {
|
|
return props.scale;
|
|
},
|
|
set(val) {
|
|
emit("update:scale", val);
|
|
},
|
|
});
|
|
|
|
const scaledYield = computed(() => {
|
|
return useExtractRecipeYield(props.recipe.recipeYield, scaleValue.value);
|
|
});
|
|
|
|
const match = findMatch(props.recipe.recipeYield);
|
|
const basicYieldNum = ref<number |null>(match ? match[1] : null);
|
|
|
|
return {
|
|
scaleValue,
|
|
scaledYield,
|
|
basicYieldNum,
|
|
isEditMode,
|
|
};
|
|
},
|
|
});
|
|
</script>
|