mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 16:24:31 -04:00
fix: Can't Edit Timeline Events (#6160)
This commit is contained in:
@@ -80,7 +80,7 @@
|
|||||||
:recipe="recipes.get(event.recipeId)"
|
:recipe="recipes.get(event.recipeId)"
|
||||||
:show-recipe-cards="showRecipeCards"
|
:show-recipe-cards="showRecipeCards"
|
||||||
:width="$vuetify.display.smAndDown ? '100%' : undefined"
|
:width="$vuetify.display.smAndDown ? '100%' : undefined"
|
||||||
@update="updateTimelineEvent(index)"
|
@update="updateTimelineEvent(index, $event)"
|
||||||
@delete="deleteTimelineEvent(index)"
|
@delete="deleteTimelineEvent(index)"
|
||||||
/>
|
/>
|
||||||
</v-timeline>
|
</v-timeline>
|
||||||
@@ -186,20 +186,17 @@ function toggleEventTypeOption(option: TimelineEventType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Timeline Actions
|
// Timeline Actions
|
||||||
async function updateTimelineEvent(index: number) {
|
async function updateTimelineEvent(index: number, event: RecipeTimelineEventUpdate) {
|
||||||
const event = timelineEvents.value[index];
|
const eventId = timelineEvents.value[index].id;
|
||||||
const payload: RecipeTimelineEventUpdate = {
|
const { response } = await api.recipes.updateTimelineEvent(eventId, event);
|
||||||
subject: event.subject,
|
|
||||||
eventMessage: event.eventMessage,
|
|
||||||
image: event.image,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { response } = await api.recipes.updateTimelineEvent(event.id, payload);
|
|
||||||
if (response?.status !== 200) {
|
if (response?.status !== 200) {
|
||||||
alert.error(i18n.t("events.something-went-wrong") as string);
|
alert.error(i18n.t("events.something-went-wrong") as string);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the local event data to reflect the changes in the UI
|
||||||
|
timelineEvents.value[index] = response.data;
|
||||||
|
|
||||||
alert.success(i18n.t("events.event-updated") as string);
|
alert.success(i18n.t("events.event-updated") as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
edit: true,
|
edit: true,
|
||||||
delete: true,
|
delete: true,
|
||||||
}"
|
}"
|
||||||
@update="$emit('update')"
|
@update="$emit('update', $event)"
|
||||||
@delete="$emit('delete')"
|
@delete="$emit('delete')"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -96,7 +96,7 @@ import RecipeCardMobile from "./RecipeCardMobile.vue";
|
|||||||
import RecipeTimelineContextMenu from "./RecipeTimelineContextMenu.vue";
|
import RecipeTimelineContextMenu from "./RecipeTimelineContextMenu.vue";
|
||||||
import { useStaticRoutes } from "~/composables/api";
|
import { useStaticRoutes } from "~/composables/api";
|
||||||
import { useTimelineEventTypes } from "~/composables/recipes/use-recipe-timeline-events";
|
import { useTimelineEventTypes } from "~/composables/recipes/use-recipe-timeline-events";
|
||||||
import type { Recipe, RecipeTimelineEventOut } from "~/lib/api/types/recipe";
|
import type { Recipe, RecipeTimelineEventOut, RecipeTimelineEventUpdate } from "~/lib/api/types/recipe";
|
||||||
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
||||||
import SafeMarkdown from "~/components/global/SafeMarkdown.vue";
|
import SafeMarkdown from "~/components/global/SafeMarkdown.vue";
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
selected: [];
|
selected: [];
|
||||||
update: [];
|
update: [event: RecipeTimelineEventUpdate];
|
||||||
delete: [];
|
delete: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user