Skip to content

Commit

Permalink
added second event to the edit week site in the frontend, second even…
Browse files Browse the repository at this point in the history
…t input opens when you input a first one
  • Loading branch information
IrisOlfermann committed Sep 24, 2024
1 parent aef8640 commit 92f5c7a
Showing 1 changed file with 14 additions and 53 deletions.
67 changes: 14 additions & 53 deletions src/Resources/src/components/menu/MenuDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
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 @@ -166,40 +168,18 @@ watch(selectedDishTwo, () => {
});
watch(selectedEventOne, () => {
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);
if (selectedEventOne.value !== null && selectedEventOne.value !== undefined) {
props.modelValue.event = selectedEventOne.value.id;
} else {
props.modelValue.event = null;
}
});
watch(selectedEventTwo, () => {
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);
if (selectedEventTwo.value !== null && selectedEventTwo.value !== undefined) {
props.modelValue.event = selectedEventTwo.value.id;
} else {
props.modelValue.event = null;
}
});
Expand All @@ -216,29 +196,10 @@ onMounted(() => {
.filter((slug) => slug !== null) as string[]
);
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);
}
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventOne.value = getEventById(props.modelValue.event);

Check failure on line 200 in src/Resources/src/components/menu/MenuDay.vue

View workflow job for this annotation

GitHub Actions / Run frontend unit- and functional-tests

tests/unit/menu/MenuDay.spec.ts > Test MenuDay > should render MenuDay

ReferenceError: getEventById is not defined ❯ src/components/menu/MenuDay.vue:200:3 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5600:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ Object.app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19 ❯ Proxy.mount node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:8415:18
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventTwo.value = getEventById(props.modelValue.event);
});
Expand Down

0 comments on commit 92f5c7a

Please sign in to comment.