1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-04 04:55:21 +02:00

fix: Mealplans Disappearing/Can't be edited (#4379)

This commit is contained in:
Michael Genson 2024-10-17 03:45:50 -05:00 committed by GitHub
parent c40d2d0486
commit 79b36024a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -220,7 +220,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed, reactive, ref, watch, onMounted } from "@nuxtjs/composition-api"; import { defineComponent, computed, reactive, ref, watch, onMounted, useContext } from "@nuxtjs/composition-api";
import { format } from "date-fns"; import { format } from "date-fns";
import { SortableEvent } from "sortablejs"; import { SortableEvent } from "sortablejs";
import draggable from "vuedraggable"; import draggable from "vuedraggable";
@ -249,6 +249,7 @@ export default defineComponent({
}, },
setup(props) { setup(props) {
const api = useUserApi(); const api = useUserApi();
const { $auth } = useContext();
const { household } = useHouseholdSelf(); const { household } = useHouseholdSelf();
const state = ref({ const state = ref({
@ -309,6 +310,7 @@ export default defineComponent({
existing: false, existing: false,
id: 0, id: 0,
groupId: "", groupId: "",
userId: $auth.user?.id || "",
}); });
function openDialog(date: Date) { function openDialog(date: Date) {
@ -317,17 +319,18 @@ export default defineComponent({
} }
function editMeal(mealplan: UpdatePlanEntry) { function editMeal(mealplan: UpdatePlanEntry) {
const { date, title, text, entryType, recipeId, id, groupId } = mealplan; const { date, title, text, entryType, recipeId, id, groupId, userId } = mealplan;
if (!entryType) return; if (!entryType) return;
newMeal.date = date; newMeal.date = date;
newMeal.title = title || ""; newMeal.title = title || "";
newMeal.text = text || ""; newMeal.text = text || "";
newMeal.recipeId = recipeId; newMeal.recipeId = recipeId || undefined;
newMeal.entryType = entryType; newMeal.entryType = entryType;
newMeal.existing = true; newMeal.existing = true;
newMeal.id = id; newMeal.id = id;
newMeal.groupId = groupId; newMeal.groupId = groupId;
newMeal.userId = userId || $auth.user?.id || "";
state.value.dialog = true; state.value.dialog = true;
dialog.note = !recipeId; dialog.note = !recipeId;

View file

@ -47,12 +47,12 @@ class CreatePlanEntry(MealieModel):
class UpdatePlanEntry(CreatePlanEntry): class UpdatePlanEntry(CreatePlanEntry):
id: int id: int
group_id: UUID group_id: UUID
user_id: UUID | None = None user_id: UUID
class SavePlanEntry(CreatePlanEntry): class SavePlanEntry(CreatePlanEntry):
group_id: UUID group_id: UUID
user_id: UUID | None = None user_id: UUID
model_config = ConfigDict(from_attributes=True) model_config = ConfigDict(from_attributes=True)