Skip to content

Commit

Permalink
Merge branch 'mealie-next' into update-seeding
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameronwyatt authored Jan 13, 2025
2 parents 1d9b981 + d7f460b commit a7f8b64
Show file tree
Hide file tree
Showing 71 changed files with 1,758 additions and 536 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
exclude: ^tests/data/
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.6
rev: v0.9.0
hooks:
- id: ruff
- id: ruff-format
18 changes: 18 additions & 0 deletions docs/docs/documentation/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ Do the following for each recipe you want to intelligently handle ingredients.

Scaling up this recipe or adding it to a Shopping List will now smartly take care of ingredient amounts and duplicate combinations.

## How do I enable Nutritional Values?
Mealie can store Nutritional Information for Recipes. Please note that the values you enter are static for the recipe and no scaling is being done when changing Servings / Yield.

Do the following to enable Nutritional Values on individual Recipes, or to modify your Household Recipe Preferences

### Show Nutritional Values on a Single Recipe
1. Go to a recipe
2. Click the Edit button/icon
3. Click the Recipe Settings gear and select `Show Nutritional Values`
4. Scroll down to manually fill out the Nutritional Values
5. Save

### Show Nutritional Values by default
1. Click your username in the top left
2. Click the 'Household Settings' button
3. Under 'Household Recipe Preferences', click to select 'Show nutrition information'
4. Click 'Update'

## Is it safe to upgrade Mealie?

Yes. If you are using the v1 branches (including beta), you can upgrade to the latest version of Mealie without performing a site Export/Restore. This process was required in previous versions of Mealie, however we've automated the database migration process to make it easier to upgrade. Note that if you were using the v0.5.x version, you CANNOT upgrade to the latest version automatically. You must follow the migration instructions in the documentation.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/overrides/api.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ export default defineComponent({
shoppingListShowAllToggled: false,
});
const userHousehold = computed(() => {
return $auth.user?.householdSlug || "";
});
const shoppingListChoices = computed(() => {
return props.shoppingLists.filter((list) => preferences.value.viewAllLists || list.userId === $auth.user?.id);
});
Expand Down Expand Up @@ -248,8 +252,9 @@ export default defineComponent({
}
const shoppingListIngredients: ShoppingListIngredient[] = recipe.recipeIngredient.map((ing) => {
const householdsWithFood = (ing.food?.householdsWithIngredientFood || []);
return {
checked: !ing.food?.onHand,
checked: !householdsWithFood.includes(userHousehold.value),
ingredient: ing,
disableAmount: recipe.settings?.disableAmount || false,
}
Expand All @@ -276,7 +281,8 @@ export default defineComponent({
}
// Store the on-hand ingredients for later
if (ing.ingredient.food?.onHand) {
const householdsWithFood = (ing.ingredient.food?.householdsWithIngredientFood || []);
if (householdsWithFood.includes(userHousehold.value)) {
onHandIngs.push(ing);
return sections;
}
Expand Down
35 changes: 25 additions & 10 deletions frontend/components/Domain/Recipe/RecipeLastMade.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
<v-icon left>
{{ $globals.icons.calendar }}
</v-icon>
{{ $t('recipe.last-made-date', { date: value ? new Date(value).toLocaleDateString($i18n.locale) : $t("general.never") } ) }}
<div v-if="lastMadeReady">
{{ $t('recipe.last-made-date', { date: lastMade ? new Date(lastMade).toLocaleDateString($i18n.locale) : $t("general.never") } ) }}
</div>
<div v-else>
<AppLoader tiny />
</div>
</v-chip>
</div>
<div class="d-flex justify-center flex-wrap mt-1">
Expand All @@ -110,7 +115,7 @@
</template>

<script lang="ts">
import { computed, defineComponent, reactive, ref, toRefs, useContext } from "@nuxtjs/composition-api";
import { computed, defineComponent, onMounted, reactive, ref, toRefs, useContext } from "@nuxtjs/composition-api";
import { whenever } from "@vueuse/core";
import { VForm } from "~/types/vuetify";
import { useUserApi } from "~/composables/api";
Expand All @@ -119,10 +124,6 @@ import { Recipe, RecipeTimelineEventIn } from "~/lib/api/types/recipe";
export default defineComponent({
props: {
value: {
type: String,
default: null,
},
recipe: {
type: Object as () => Recipe,
required: true,
Expand All @@ -146,6 +147,20 @@ export default defineComponent({
const newTimelineEventImagePreviewUrl = ref<string>();
const newTimelineEventTimestamp = ref<string>();
const lastMade = ref(props.recipe.lastMade);
const lastMadeReady = ref(false);
onMounted(async () => {
if (!$auth.user?.householdSlug) {
lastMade.value = props.recipe.lastMade;
} else {
const { data } = await userApi.households.getCurrentUserHouseholdRecipe(props.recipe.slug || "");
lastMade.value = data?.lastMade;
}
lastMadeReady.value = true;
});
whenever(
() => madeThisDialog.value,
() => {
Expand Down Expand Up @@ -195,11 +210,9 @@ export default defineComponent({
const newEvent = eventResponse.data;
// we also update the recipe's last made value
if (!props.value || newTimelineEvent.value.timestamp > props.value) {
if (!lastMade.value || newTimelineEvent.value.timestamp > lastMade.value) {
lastMade.value = newTimelineEvent.value.timestamp;
await userApi.recipes.updateLastMade(props.recipe.slug, newTimelineEvent.value.timestamp);
// update recipe in parent so the user can see it
context.emit("input", newTimelineEvent.value.timestamp);
}
// update the image, if provided
Expand Down Expand Up @@ -234,6 +247,8 @@ export default defineComponent({
newTimelineEventImage,
newTimelineEventImagePreviewUrl,
newTimelineEventTimestamp,
lastMade,
lastMadeReady,
createTimelineEvent,
clearImage,
uploadImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<v-col cols="12" class="d-flex flex-wrap justify-center">
<RecipeLastMade
v-if="isOwnGroup"
:value="recipe.lastMade"
:recipe="recipe"
:class="true ? undefined : 'force-bottom'"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h2 class="mb-2 mt-4">{{ $t('tool.required-tools') }}</h2>
<v-list-item v-for="(tool, index) in recipe.tools" :key="index" dense>
<v-checkbox
v-model="recipe.tools[index].onHand"
v-model="recipeTools[index].onHand"
hide-details
class="pt-0 my-auto py-auto"
color="secondary"
Expand All @@ -26,14 +26,18 @@
</template>

<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import { computed, defineComponent } from "@nuxtjs/composition-api";
import { useLoggedInState } from "~/composables/use-logged-in-state";
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 { Recipe, RecipeTool } from "~/lib/api/types/recipe";
import RecipeIngredients from "~/components/Domain/Recipe/RecipeIngredients.vue";
interface RecipeToolWithOnHand extends RecipeTool {
onHand: boolean;
}
export default defineComponent({
components: {
RecipeIngredients,
Expand All @@ -59,16 +63,39 @@ export default defineComponent({
const { user } = usePageUser();
const { isEditMode } = usePageState(props.recipe.slug);
const recipeTools = computed(() => {
if (!(user.householdSlug && toolStore)) {
return props.recipe.tools.map((tool) => ({ ...tool, onHand: false }) as RecipeToolWithOnHand);
} else {
return props.recipe.tools.map((tool) => {
const onHand = tool.householdsWithTool?.includes(user.householdSlug) || false;
return { ...tool, onHand } as RecipeToolWithOnHand;
});
}
})
function updateTool(index: number) {
if (user.id && toolStore) {
toolStore.actions.updateOne(props.recipe.tools[index]);
if (user.id && user.householdSlug && toolStore) {
const tool = recipeTools.value[index];
if (tool.onHand && !tool.householdsWithTool?.includes(user.householdSlug)) {
if (!tool.householdsWithTool) {
tool.householdsWithTool = [user.householdSlug];
} else {
tool.householdsWithTool.push(user.householdSlug);
}
} else if (!tool.onHand && tool.householdsWithTool?.includes(user.householdSlug)) {
tool.householdsWithTool = tool.householdsWithTool.filter((household) => household !== user.householdSlug);
}
toolStore.actions.updateOne(tool);
} else {
console.log("no user, skipping server update");
}
}
return {
toolStore,
recipeTools,
isEditMode,
updateTool,
};
Expand Down
15 changes: 13 additions & 2 deletions frontend/components/global/AppLoader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
</v-icon>
<div v-if="large" class="text-small">
<slot>
{{ small ? "" : waitingText }}
{{ (small || tiny) ? "" : waitingText }}
</slot>
</div>
</div>
</v-progress-circular>
<div v-if="!large" class="text-small">
<slot>
{{ small ? "" : waitingTextCalculated }}
{{ (small || tiny) ? "" : waitingTextCalculated }}
</slot>
</div>
</div>
Expand All @@ -31,6 +31,10 @@ export default defineComponent({
type: Boolean,
default: true,
},
tiny: {
type: Boolean,
default: false,
},
small: {
type: Boolean,
default: false,
Expand All @@ -50,6 +54,13 @@ export default defineComponent({
},
setup(props) {
const size = computed(() => {
if (props.tiny) {
return {
width: 2,
icon: 0,
size: 25,
};
}
if (props.small) {
return {
width: 2,
Expand Down
1 change: 0 additions & 1 deletion frontend/composables/recipes/use-recipe-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const useTools = function (eager = true) {
id: "",
name: "",
slug: "",
onHand: false,
});

const api = useUserApi();
Expand Down
1 change: 0 additions & 1 deletion frontend/composables/store/use-food-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const useFoodData = function () {
name: "",
description: "",
labelId: undefined,
onHand: false,
});
}

Expand Down
7 changes: 6 additions & 1 deletion frontend/composables/store/use-tool-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import { useData, useReadOnlyStore, useStore } from "../partials/use-store-facto
import { RecipeTool } from "~/lib/api/types/recipe";
import { usePublicExploreApi, useUserApi } from "~/composables/api";

interface RecipeToolWithOnHand extends RecipeTool {
onHand: boolean;
}

const store: Ref<RecipeTool[]> = ref([]);
const loading = ref(false);
const publicLoading = ref(false);

export const useToolData = function () {
return useData<RecipeTool>({
return useData<RecipeToolWithOnHand>({
id: "",
name: "",
slug: "",
onHand: false,
householdsWithTool: [],
});
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/api/types/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface RecipeTool {
id: string;
name: string;
slug: string;
onHand?: boolean;
householdsWithTool?: string[];
[k: string]: unknown;
}
export interface CustomPageImport {
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/api/types/cookbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface RecipeTool {
id: string;
name: string;
slug: string;
onHand?: boolean;
householdsWithTool?: string[];
[k: string]: unknown;
}
export interface SaveCookBook {
Expand Down
29 changes: 24 additions & 5 deletions frontend/lib/api/types/household.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,27 @@ export interface ReadWebhook {
householdId: string;
id: string;
}
export interface HouseholdRecipeBase {
lastMade?: string | null;
}
export interface HouseholdRecipeCreate {
lastMade?: string | null;
householdId: string;
recipeId: string;
}
export interface HouseholdRecipeOut {
lastMade?: string | null;
householdId: string;
recipeId: string;
id: string;
}
export interface HouseholdRecipeSummary {
lastMade?: string | null;
recipeId: string;
}
export interface HouseholdRecipeUpdate {
lastMade?: string | null;
}
export interface HouseholdSave {
groupId: string;
name: string;
Expand Down Expand Up @@ -297,7 +318,6 @@ export interface IngredientUnit {
extras?: {
[k: string]: unknown;
} | null;
onHand?: boolean;
fraction?: boolean;
abbreviation?: string;
pluralAbbreviation?: string | null;
Expand All @@ -318,7 +338,6 @@ export interface CreateIngredientUnit {
extras?: {
[k: string]: unknown;
} | null;
onHand?: boolean;
fraction?: boolean;
abbreviation?: string;
pluralAbbreviation?: string | null;
Expand All @@ -338,9 +357,9 @@ export interface IngredientFood {
extras?: {
[k: string]: unknown;
} | null;
onHand?: boolean;
labelId?: string | null;
aliases?: IngredientFoodAlias[];
householdsWithIngredientFood?: string[];
label?: MultiPurposeLabelSummary | null;
createdAt?: string | null;
updatedAt?: string | null;
Expand All @@ -363,9 +382,9 @@ export interface CreateIngredientFood {
extras?: {
[k: string]: unknown;
} | null;
onHand?: boolean;
labelId?: string | null;
aliases?: CreateIngredientFoodAlias[];
householdsWithIngredientFood?: string[];
[k: string]: unknown;
}
export interface CreateIngredientFoodAlias {
Expand Down Expand Up @@ -592,7 +611,7 @@ export interface RecipeTool {
id: string;
name: string;
slug: string;
onHand?: boolean;
householdsWithTool?: string[];
[k: string]: unknown;
}
export interface ShoppingListRemoveRecipeParams {
Expand Down
Loading

0 comments on commit a7f8b64

Please sign in to comment.