Skip to content

Commit

Permalink
Merge pull request #432 from AOEpeople/bugfix/fixing-several-bugs
Browse files Browse the repository at this point in the history
Bugfix/fixing several bugs
  • Loading branch information
MalibusParty authored Feb 29, 2024
2 parents 1a39014 + 1618062 commit a356e1d
Show file tree
Hide file tree
Showing 44 changed files with 181 additions and 92 deletions.
1 change: 1 addition & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ security:
- { path: ^/api/print/participations, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/dashboard, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/guest-invitation, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/guest/meal/participation, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/environmentals, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/user, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/event/invitation/\S*, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
Expand Down
12 changes: 12 additions & 0 deletions src/Mealz/MealBundle/Controller/DishController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Mealz\MealBundle\Controller;

use App\Mealz\MealBundle\Entity\Dish;
use App\Mealz\MealBundle\Entity\DishCollection;
use App\Mealz\MealBundle\Repository\CategoryRepository;
use App\Mealz\MealBundle\Repository\CategoryRepositoryInterface;
use App\Mealz\MealBundle\Repository\DishRepository;
Expand Down Expand Up @@ -60,6 +61,17 @@ public function getDishes(): JsonResponse
$dishes[] = $combiDish[0];
}

/** @var Dish $dish */
foreach ($dishes as $dish) {
if (count($dish->getVariations()) > 0) {
$variations = array_values(array_filter(
$dish->getVariations()->toArray(),
fn ($variation) => $variation->isEnabled()
));
$dish->setVariations(new DishCollection($variations));
}
}

return new JsonResponse($dishes, 200);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Mealz/MealBundle/Controller/MealAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ public function count(): JsonResponse

private function setParticipationLimit(Meal $mealEntity, $meal): void
{
if (true === isset($meal['participationLimit']) && 0 < $meal['participationLimit']) {
if (
true === isset($meal['participationLimit']) &&
0 < $meal['participationLimit'] &&
count($mealEntity->getParticipants()) < $meal['participationLimit']
) {
$mealEntity->setParticipationLimit($meal['participationLimit']);
} else {
$mealEntity->setParticipationLimit(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<vue3-progress-bar />
</div>
<DebtPopup />
<Content class="relative z-[2] grow-[1]" />
<Content class="relative z-[2] grow-[1] pb-12" />
<Footer
v-if="!showParticipations"
class="relative z-[1] mt-auto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const props = withDefaults(
}
);
const emit = defineEmits(['closePanel']);
const titleDeInput = ref(props.titleDe);
const titleEnInput = ref(props.titleEn);
const required = ref(false);
Expand All @@ -66,5 +68,6 @@ async function onSubmit() {
};
await createCategory(category);
}
emit('closePanel');
}
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="grid grid-rows-2 items-center xl:my-[42px] xl:grid-cols-2">
<div class="grid grid-rows-2 items-center xl:my-[42px] xl:grid-cols-2 xl:grid-rows-1">
<h2 class="text-center xl:justify-self-start">
{{ t('category.header') }}
</h2>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/src/components/costs/CashPaymentPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ const props = defineProps<{
username: string;
}>();
const emit = defineEmits(['closePanel']);
async function onSubmit() {
const parsedAmount = parseFloat(amount.value);
if (parsedAmount > 0) {
await sendCashPayment(props.username, parsedAmount);
}
emit('closePanel');
}
</script>
6 changes: 4 additions & 2 deletions src/Resources/src/components/costs/CostsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<Table
:labels="columnNames"
:header-text-position="'lfr'"
:add-styles="'first:sticky first:left-0 first:bg-[#f4f7f9] last:pl-4'"
:overflow-table="true"
>
<LazyTableRow
v-for="[username, costs] in filteredUsers"
:key="username"
:min-height="40"
class="max-h-[62px] border-b-2 border-gray-200 text-right text-[12px] xl:text-[18px]"
>
<td class="py-2 text-left">
<td class="sticky left-0 bg-[#f4f7f9] py-2 text-left">
{{ `${costs.name}, ${costs.firstName}` }}
</td>
<td>
Expand All @@ -24,7 +26,7 @@
<td>
{{ new Intl.NumberFormat(locale, { style: 'currency', currency: 'EUR' }).format(costs.costs['total']) }}
</td>
<td>
<td class="min-w-[100px] pl-2">
<CostsTableActions
:username="username"
:balance="costs.costs['total']"
Expand Down
8 changes: 7 additions & 1 deletion src/Resources/src/components/costs/CostsTableActions.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<template>
<div class="ml-auto grid h-full w-fit grid-cols-3 justify-end gap-2">
<ActionButton
class="min-w-[32px]"
:action="Action.HIDE"
:btn-text="''"
@click="hideUser(username)"
/>
<Popover :translate-x-min="'-50%'">
<Popover
:overflow-hidden="false"
:translate-x-min="'-5%'"
:popup-styles="'right-0'"
>
<template #button="{ open }">
<ActionButton
:action="Action.CREATE"
Expand All @@ -21,6 +26,7 @@
</Popover>
<ActionButton
v-if="balance > 0"
class="min-w-[32px]"
:action="Action.BALANCE"
:btn-text="''"
@click="settlementOpen = true"
Expand Down
6 changes: 5 additions & 1 deletion src/Resources/src/components/dashboard/MealCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ const checkboxCSS = computed(() => {
async function handle() {
// Meal is not locked
if (mealOrVariation.value.isLocked === false && isLocked(String(props.dayID)) === false) {
if (
(mealOrVariation.value.isLocked === false || mealOrVariation.value.mealState === 'tradeable') &&
isLocked(String(props.dayID)) === false
) {
addLock(String(props.dayID));
// User is participating
if (isParticipating.value) {
Expand All @@ -138,6 +141,7 @@ async function handle() {
}
removeLock(String(props.dayID));
} else if (isLocked(String(props.dayID)) === false) {
console.log(`Attemting accept offer: mealstate: ${mealOrVariation.value.mealState}`);
addLock(String(props.dayID));
if (mealOrVariation.value.mealState === 'offerable') {
addLock(String(props.dayID));
Expand Down
18 changes: 11 additions & 7 deletions src/Resources/src/components/dishes/DishActions.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="flex flex-row content-center items-center justify-end justify-items-end sm:gap-4">
<Popover
:breakpoint-width="564"
:translate-x-min="'-60%'"
:translate-x-max="'-50%'"
:popup-styles="'right-0'"
:translate-x-min="'-5%'"
:translate-x-max="'-5%'"
>
<template #button="{ open }">
<ActionButton
Expand All @@ -13,13 +13,16 @@
/>
</template>
<template #panel="{ close }">
<DishVariationCreationPanel :parent-slug="dish.slug" />
<DishVariationCreationPanel
:parent-slug="dish.slug"
@close-panel="close()"
/>
</template>
</Popover>
<Popover
:breakpoint-width="564"
:translate-x-min="'-75%'"
:translate-x-max="'-80%'"
:popup-styles="'right-0'"
:translate-x-min="'-5%'"
:translate-x-max="'-5%'"
>
<template #button="{ open }">
<ActionButton
Expand All @@ -38,6 +41,7 @@
:dish-id="dish.id"
:category-id="dish.categoryId"
:one-size-serving="dish.oneServingSize"
@close-panel="close()"
/>
</template>
</Popover>
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/src/components/dishes/DishTableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
>
<td
colspan="1"
class="w-[50%] py-2"
class="sticky left-0 w-[50%] bg-[#f4f7f9] py-2"
>
<span class="text-[12px] xl:text-[18px]">
{{ locale === 'en' ? dish.titleEn : dish.titleDe }}
Expand Down Expand Up @@ -38,7 +38,7 @@
>
<td
colspan="1"
class="w-[50%] py-2 pl-4"
class="sticky left-0 w-[50%] bg-[#f4f7f9] py-2 pl-4"
>
<span class="text-[12px] xl:text-[18px]">
{{ locale === 'en' ? variation.titleEn : variation.titleDe }}
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/src/components/dishes/DishVariationActions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<div class="flex flex-row content-center items-center justify-end justify-items-end sm:gap-4">
<Popover>
<Popover
:popup-styles="'right-0'"
:translate-x-min="'-5%'"
:translate-x-max="'-5%'"
>
<template #button="{ open }">
<ActionButton
:action="Action.EDIT"
Expand All @@ -15,6 +19,7 @@
:title-en="variation.titleEn"
:slug="variation.slug"
:edit="true"
@close-panel="close()"
/>
</template>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const props = withDefaults(
}
);
const emit = defineEmits(['closePanel']);
const titleDeInput = ref(props.titleDe);
const titleEnInput = ref(props.titleEn);
const required = ref(false);
Expand All @@ -57,8 +59,10 @@ async function onSubmit() {
return;
} else if (props.edit === true && typeof props.slug === 'string') {
await updateDishVariation(props.slug, createDishVariationDtoObject());
emit('closePanel');
} else if (props.edit === false) {
await createDishVariation(createDishVariationDtoObject(), props.parentSlug);
emit('closePanel');
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/src/components/dishes/DishesCreationPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const props = withDefaults(
}
);
const emit = defineEmits(['closePanel']);
onMounted(async () => {
await fetchCategories();
});
Expand All @@ -113,6 +115,7 @@ async function onSubmit() {
} else {
await createDish(createDishDtoObject());
}
emit('closePanel');
}
function createDishDtoObject() {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/components/dishes/DishesHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/>
</template>
<template #panel="{ close }">
<DishesCreationPanel />
<DishesCreationPanel @close-panel="close()" />
</template>
</Popover>
<DishesSearchBar class="row-span-1 row-start-3 md:col-start-1 md:row-start-2 md:justify-self-start" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const props = withDefaults(
);
const showParticipations = ref(false);
const participations = ref([]);
const participations = ref<string[]>([]);
const isLoading = ref(false);
watch(showParticipations, async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/src/components/events/EventCreationPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const props = withDefaults(
}
);
const emit = defineEmits(['closePanel']);
const eventTitle = ref(props.title);
const isEventPublic = ref(props.isPublic);
Expand All @@ -68,8 +70,10 @@ async function onSubmit() {
required.value = true;
if (eventTitle.value !== '' && props.edit === false) {
await createEvent(eventTitle.value, isEventPublic.value);
emit('closePanel');
} else if (eventTitle.value !== '' && props.slug !== '') {
await updateEvent(props.slug, eventTitle.value, isEventPublic.value);
emit('closePanel');
}
}
</script>
7 changes: 2 additions & 5 deletions src/Resources/src/components/events/EventsActions.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<template>
<div class="flex flex-row content-center items-center justify-end justify-items-end sm:gap-4">
<Popover
:breakpoint-width="564"
:translate-x-min="'-60%'"
:translate-x-max="'-50%'"
>
<Popover :translate-x-min="'-71%'">
<template #button="{ open }">
<ActionButton
:action="Action.EDIT"
Expand All @@ -18,6 +14,7 @@
:is-public="event.public"
:edit="true"
:slug="event.slug"
@close-panel="close()"
/>
</template>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/components/events/EventsHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/>
</template>
<template #panel="{ close }">
<EventCreationPanel />
<EventCreationPanel @close-panel="close()" />
</template>
</Popover>
<InputLabel
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/src/components/finance/FinanceHeader.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
v-if="showControls === true"
class="mb-4 flex items-center gap-5 align-middle"
class="mb-8 flex items-center gap-5 align-middle"
>
<VueDatePicker
v-model="date"
Expand All @@ -13,9 +13,9 @@
/>
</div>
<div class="grid grid-rows-1 items-center xl:my-[24px] xl:grid-cols-2">
<h1 class="m-0 text-center xl:justify-self-start">
<h2 class="m-0 text-center max-[420px]:text-[24px] xl:justify-self-start">
{{ dateRange }}
</h1>
</h2>
<a
v-if="showControls === true"
class="cursor-pointer justify-self-end text-primary hover:text-secondary"
Expand Down
Loading

0 comments on commit a356e1d

Please sign in to comment.