Skip to content

Commit

Permalink
fixed a bug that prevented participation limits to be set before savi…
Browse files Browse the repository at this point in the history
…ng a menu and fixed a bug that prevented a meal to be added to the menu after deleting the first meal of a day
  • Loading branch information
Felix Ruf committed Jul 12, 2024
1 parent 9c94546 commit add3080
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
18 changes: 15 additions & 3 deletions src/Resources/src/components/menu/MenuParticipationPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
:meal="meal"
class="max-w-[300px] px-2"
/>
<span v-if="mealList.length < 1">
{{ t('menu.noMeals') }}
</span>
</div>
</template>

Expand All @@ -24,6 +27,9 @@ import { Dictionary } from 'types/types';
import MealParticipationInput from './MealParticipationInput.vue';
import { computed } from 'vue';
import { XCircleIcon } from '@heroicons/vue/solid';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const props = defineProps<{
meals: Dictionary<MealDTO[]>;
Expand All @@ -34,9 +40,9 @@ const emit = defineEmits(['closePanel']);
const mealList = computed(() => {
const keys = Object.keys(props.meals);
removeCombinedMealKey(keys);
const returnMealDTOs = [];
const returnMealDTOs: MealDTO[] = [];
keys.forEach((key) => {
if (parseInt(key) > 0) {
if (props.meals[key].length > 0) {
returnMealDTOs.push(...props.meals[key]);
}
});
Expand All @@ -46,7 +52,13 @@ const mealList = computed(() => {
function removeCombinedMealKey(keys: string[]) {
let indexToRemove = -1;
keys.forEach((mealId) => {
if (parseInt(mealId) > 0 && props.meals[mealId][0].dishSlug === 'combined-dish') {
if (
parseInt(mealId) > 0 &&
props.meals[mealId] !== undefined &&
props.meals[mealId] !== null &&
props.meals[mealId].length > 0 &&
props.meals[mealId][0].dishSlug === 'combined-dish'
) {
indexToRemove = keys.indexOf(mealId);
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@
"notFound": "Keine Profile für diese Anfrage gefunden",
"shortQuery": "Min. 3 Buchstaben für Suche eingeben",
"search": "Teilnehmer filtern",
"guest": "Gast"
"guest": "Gast",
"noMeals": "Noch keine Gerichte ausgewählt"
},
"printList": {
"title": "Teilnahmen am ",
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@
"notFound": "No profiles found for this query",
"shortQuery": "Min. 3 Buchstaben für Suche eingeben",
"search": "Filter participant",
"guest": "Gast"
"guest": "Gast",
"noMeals": "No dishes selected yet"
},
"printList": {
"title": "Participations on ",
Expand Down
3 changes: 0 additions & 3 deletions src/Resources/src/stores/weeksStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ export function useWeeks() {
}
}

const mealDays = response.value.days;
console.log(JSON.stringify(mealDays));

return response.value.calendarWeek;
}

Expand Down
18 changes: 1 addition & 17 deletions src/Resources/src/views/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>
<MenuDay
v-for="(day, index) in menu.days"
:key="day.id"
:key="Object.keys(day.meals).join()"
v-model="menu.days[index]"
:lockDates="lockDates"
class="mt-4"
Expand Down Expand Up @@ -96,26 +96,10 @@ const menu = reactive<WeekDTO>({
const calendarWeek = ref(0);
// watch(
// () => menu.days,
// (prev, after) => {
// if (prev.length > 0) {
// const previous = JSON.stringify(Object.entries(prev[0].meals));
// console.log('Prev: \n' + previous);
// }
// if (after.length > 0) {
// const afterVal = JSON.stringify(Object.entries(after[0].meals));
// console.log('After: \n' + afterVal);
// }
// }
// )
onMounted(async () => {
const progress = useProgress().start();
parseWeekId.value = parseInt(props.week);
console.log(`Week is ${props.week} and create is ${props.create}`);
if (DishesState.dishes.length === 0) {
await fetchDishes();
}
Expand Down

0 comments on commit add3080

Please sign in to comment.