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 Aug 26, 2024
1 parent 0507e2c commit adfe199
Showing 1 changed file with 16 additions and 54 deletions.
70 changes: 16 additions & 54 deletions src/Resources/src/components/menu/MenuDay.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div
class="day-shadow group grid grid-cols-[24px_minmax(0,1fr)_58px] grid-rows-4 rounded-lg border-0 border-none bg-white text-center align-middle sm:grid-cols-[24px_minmax(0,1fr)_72px]"
class="day-shadow group grid grid-cols-[24px_minmax(0,1fr)_58px] grid-rows-4 rounded-lg border-0 border-none bg-white text-center align-middle sm:grid-cols-[24px_minmax(0,1fr)_72px]"
>
<div
class="col-start-1 row-span-4 row-start-1 grid w-[24px] grid-rows-[24px_minmax(0,1fr)_24px] justify-center rounded-l-lg bg-primary-2 py-1"
Expand Down 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,31 +196,13 @@ 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);
});
/**
* Extract the slugs from the selected dishes. Returns the slugs of variations if there are selected variations.
* Otherwise the slug of the parent dish is returned.
Expand Down

0 comments on commit adfe199

Please sign in to comment.