mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-28 08:44:36 -04:00
fix: Mealplans Disappearing/Can't be edited (#4379)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user