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