Skip to content

Commit

Permalink
fixed rebase error oops
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisOlfermann committed Aug 26, 2024
1 parent adfe199 commit 07782c0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/Mealz/MealBundle/Controller/MealAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ private function handleDay(array $day): void
throw new Exception('106: too many meals requested');
}

if (false === $this->dayService->checkMealsUpdatable($dayEntity, $mealCollection)) {
throw new Exception('108: Meals must not have participations when being updated');
}

$this->dayService->removeUnusedMeals($dayEntity, $mealCollection);

// parentMeal is an array of either one meal without variations or 1-2 variations
Expand Down Expand Up @@ -363,4 +359,4 @@ private function modifyMeal(array $meal, Dish $dishEntity, Day $dayEntity): void

throw new Exception('108: meal has participations for id: ' . $meal['mealId']);
}
}
}
68 changes: 53 additions & 15 deletions src/Resources/src/components/menu/MenuDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
v-model="selectedEventOne"
class="col-start-2 row-span-1 row-start-3 border-b border-t-[3px] px-2 py-[12px] md:px-4"
/>

<EventInput
v-if="selectedEventOne"
v-model="selectedEventTwo"
class="col-start-2 row-span-1 row-start-4 px-2 py-[12px] md:px-4"
/>
Expand Down Expand Up @@ -168,18 +166,40 @@ watch(selectedDishTwo, () => {
});
watch(selectedEventOne, () => {
if (selectedEventOne.value !== null && selectedEventOne.value !== undefined) {
props.modelValue.event = selectedEventOne.value.id;
} else {
props.modelValue.event = null;
try {
const firstKey = Object.keys(props.modelValue.events)[0] ?? selectedEventOne.value?.id;
if (selectedEventOne.value) {
selectedDishes.value.events[firstKey] = {
eventId: selectedEventOne.value.id,
eventSlug: selectedEventOne.value.slug,
eventTitle: selectedEventOne.value.title,
isPublic: selectedEventOne.value.public
};
} else if (firstKey) {
selectedDishes.value.events[firstKey].eventId = null;
}
} catch (error) {
console.error('Fehler: ', error);
}
});
watch(selectedEventTwo, () => {
if (selectedEventTwo.value !== null && selectedEventTwo.value !== undefined) {
props.modelValue.event = selectedEventTwo.value.id;
} else {
props.modelValue.event = null;
try {
const secondKey = Object.keys(props.modelValue.events)[1] ?? selectedEventTwo.value?.id;
if (selectedEventTwo.value) {
selectedDishes.value.events[secondKey] = {
eventId: selectedEventTwo.value.id,
eventSlug: selectedEventTwo.value.slug,
eventTitle: selectedEventTwo.value.title,
isPublic: selectedEventTwo.value.public
};
} else if (secondKey) {
selectedDishes.value.events[secondKey].eventId = null;
}
} catch (error) {
console.error('Fehler: ', error);
}
});
Expand All @@ -196,12 +216,30 @@ onMounted(() => {
.filter((slug) => slug !== null) as string[]
);
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventOne.value = getEventById(props.modelValue.event);
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventTwo.value = getEventById(props.modelValue.event);
});
try {
const firstKey = Object.keys(props.modelValue.events)[0];
const secondKey = Object.keys(props.modelValue.events)[1];
if (props.modelValue.events[firstKey]) {
selectedEventOne.value = {
id: props.modelValue.events[firstKey].eventId as number,
slug: props.modelValue.events[firstKey].eventSlug as string,
title: props.modelValue.events[firstKey].eventTitle as string,
public: props.modelValue.events[firstKey].isPublic as boolean
};
}
if (props.modelValue.events[secondKey]) {
selectedEventTwo.value = {
id: props.modelValue.events[secondKey].eventId as number,
slug: props.modelValue.events[secondKey].eventSlug as string,
title: props.modelValue.events[secondKey].eventTitle as string,
public: props.modelValue.events[secondKey].isPublic as boolean
};
}
} catch (error) {
console.error('Fehler beim Laden der Events: ', error);
}
});
/**
* Extract the slugs from the selected dishes. Returns the slugs of variations if there are selected variations.
Expand Down

0 comments on commit 07782c0

Please sign in to comment.