mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-11-03 18:53:17 -05:00 
			
		
		
		
	* add vitest * initialize lib w/ tests * move to dev dep * run tests in CI * update file names * move api folder to lib * move api and api types to same folder * update generator outpath * rm husky * i guess i _did_ need those types * reorg types * extract validators into testable components * (WIP) start composable testing * fix import type * fix linter complaint * simplify icon type def * fix linter errors (maybe?) * rename client file for sorting
		
			
				
	
	
		
			70 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
<template>
 | 
						|
  <div>
 | 
						|
    <RecipeIngredients
 | 
						|
      :value="recipe.recipeIngredient"
 | 
						|
      :scale="scale"
 | 
						|
      :disable-amount="recipe.settings.disableAmount"
 | 
						|
    />
 | 
						|
    <div v-if="!isEditMode && recipe.tools && recipe.tools.length > 0">
 | 
						|
      <h2 class="mb-2 mt-4">Required Tools</h2>
 | 
						|
      <v-list-item v-for="(tool, index) in recipe.tools" :key="index" dense>
 | 
						|
        <v-checkbox
 | 
						|
          v-model="recipe.tools[index].onHand"
 | 
						|
          hide-details
 | 
						|
          class="pt-0 my-auto py-auto"
 | 
						|
          color="secondary"
 | 
						|
          @change="updateTool(index)"
 | 
						|
        >
 | 
						|
        </v-checkbox>
 | 
						|
        <v-list-item-content>
 | 
						|
          {{ tool.name }}
 | 
						|
        </v-list-item-content>
 | 
						|
      </v-list-item>
 | 
						|
    </div>
 | 
						|
  </div>
 | 
						|
</template>
 | 
						|
 | 
						|
<script lang="ts">
 | 
						|
import { defineComponent } from "@nuxtjs/composition-api";
 | 
						|
import { usePageState, usePageUser } from "~/composables/recipe-page/shared-state";
 | 
						|
import { useToolStore } from "~/composables/store";
 | 
						|
import { NoUndefinedField } from "~/lib/api/types/non-generated";
 | 
						|
import { Recipe } from "~/lib/api/types/recipe";
 | 
						|
import RecipeIngredients from "~/components/Domain/Recipe/RecipeIngredients.vue";
 | 
						|
 | 
						|
export default defineComponent({
 | 
						|
  components: {
 | 
						|
    RecipeIngredients,
 | 
						|
  },
 | 
						|
  props: {
 | 
						|
    recipe: {
 | 
						|
      type: Object as () => NoUndefinedField<Recipe>,
 | 
						|
      required: true,
 | 
						|
    },
 | 
						|
    scale: {
 | 
						|
      type: Number,
 | 
						|
      required: true,
 | 
						|
    },
 | 
						|
  },
 | 
						|
  setup(props) {
 | 
						|
    const toolStore = useToolStore();
 | 
						|
    const { user } = usePageUser();
 | 
						|
    const { isEditMode } = usePageState(props.recipe.slug);
 | 
						|
 | 
						|
    function updateTool(index: number) {
 | 
						|
      if (user.id) {
 | 
						|
        toolStore.actions.updateOne(props.recipe.tools[index]);
 | 
						|
      } else {
 | 
						|
        console.log("no user, skipping server update");
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
    return {
 | 
						|
      toolStore,
 | 
						|
      isEditMode,
 | 
						|
      updateTool,
 | 
						|
    };
 | 
						|
  },
 | 
						|
});
 | 
						|
</script>
 |