Skip to content

Commit 7a72a4f

Browse files
authored
Merge pull request #502 from AOEpeople/feature/#265015-mark-guests
Feature/#265015 mark guests
2 parents d03e3cf + a2fdcc9 commit 7a72a4f

31 files changed

+117
-57
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ node_modules
3737
###< friendsofphp/php-cs-fixer ###
3838

3939
/src/Resources/style/output.css
40-
/**/*.d.ts
4140
/src/Resources/style/output.css.map
4241
test_ci_cypress.sh
4342
tests/e2e/cypress/videos/

src/Mealz/MealBundle/Controller/ApiController.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,9 @@ public function listParticipantsByDate(DateTime $date): JsonResponse
200200
return new JsonResponse(['message' => 'Day not found'], 404);
201201
}
202202

203-
$list = [];
204-
$data = $this->participationSrv->getParticipationList($day);
203+
$participants = $this->participationSrv->getParticipationList($day);
205204

206-
foreach ($data as $participant) {
207-
$list[] = $participant->getProfile()->getFirstName() . ' ' . $participant->getProfile()->getName();
208-
}
209-
210-
$uniqueArray = array_unique($list);
211-
212-
return new JsonResponse(array_values($uniqueArray), 200);
205+
return new JsonResponse($participants, 200);
213206
}
214207

215208
private function addSlots(array &$slotArray, array $slots, Day $day, ?int $activeParticipations): void

src/Mealz/MealBundle/Controller/ParticipantController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ private function addParticipationInfo(array $response, ArrayCollection $particip
438438
/** @var Participant $participant */
439439
foreach ($participants as $participant) {
440440
$participationData = $this->participationHelper->getParticipationMealData($participant);
441-
$response[$day->getId()][$participant->getProfile()->getFullName()]['booked'][] = $participationData;
442-
$response[$day->getId()][$participant->getProfile()->getFullName()]['profile'] = $participant->getProfile()->getUsername();
441+
$response[$day->getId()][$this->participationHelper->getParticipantName($participant)]['booked'][] = $participationData;
442+
$response[$day->getId()][$this->participationHelper->getParticipantName($participant)]['profile'] = $participant->getProfile()->getUsername();
443443
}
444444

445445
return $response;

src/Mealz/MealBundle/Helper/ParticipationHelper.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public function getParticipationMealData(Participant $participant): array
115115
return $participationData;
116116
}
117117

118+
public function getParticipantName(Participant $participant): string
119+
{
120+
$fullname = $participant->getProfile()->getFullName();
121+
if (true === $participant->getProfile()->isGuest()) {
122+
$fullname .= ' (Guest)';
123+
}
124+
125+
return $fullname;
126+
}
127+
118128
protected function compareNameOfParticipants(Participant $participant1, Participant $participant2): int
119129
{
120130
$result = strcasecmp($participant1->getProfile()->getName(), $participant2->getProfile()->getName());
@@ -144,7 +154,7 @@ private function getParticipationbySlot(Participant $participant, ?Slot $slot, b
144154
$combinedDishes = $this->getCombinedDishesFromMeal($meal, $participant);
145155

146156
if (true === $meal->isParticipant($participant) && (null === $slot || $slot->isDisabled() || $slot->isDeleted())) {
147-
$slots[''][$participant->getProfile()->getFullName()] = $this->getParticipationData(
157+
$slots[''][$this->getParticipantName($participant)] = $this->getParticipationData(
148158
$meal,
149159
$profile,
150160
$participant,
@@ -154,7 +164,7 @@ private function getParticipationbySlot(Participant $participant, ?Slot $slot, b
154164
}
155165

156166
if (true === $meal->isParticipant($participant)) {
157-
$slots[$slot->getTitle()][$participant->getProfile()->getFullName()] = $this->getParticipationData(
167+
$slots[$slot->getTitle()][$this->getParticipantName($participant)] = $this->getParticipationData(
158168
$meal,
159169
$profile,
160170
$participant,

src/Mealz/MealBundle/Service/ParticipationService.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,23 @@ public function getCountByMeal(Meal $meal, bool $withoutCombined = false): int
248248

249249
public function getParticipationList(Day $day): array
250250
{
251-
return $this->participantRepo->getParticipantsByDay($day->getDateTime(), ['load_meal' => false]);
251+
$participants = $this->participantRepo->getParticipantsByDay($day->getDateTime(), ['load_meal' => false]);
252+
253+
$profiles = array_map(
254+
fn ($participant) => $participant->getProfile(),
255+
$participants
256+
);
257+
258+
$profileData = array_map(
259+
fn ($profile) => [
260+
'user' => $profile->getUsername(),
261+
'fullName' => $profile->getFullName(),
262+
'roles' => $profile->getRoles(),
263+
],
264+
array_unique($profiles)
265+
);
266+
267+
return $profileData;
252268
}
253269

254270
/**

src/Resources/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

src/Resources/src/api/getParticipationsByDay.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import useApi from '@/api/api';
2+
import type { IProfile } from '@/stores/profilesStore';
3+
import type { Dictionary } from '@/types/types';
24
import { onMounted, readonly, ref } from 'vue';
35

46
/**
@@ -7,7 +9,7 @@ import { onMounted, readonly, ref } from 'vue';
79
* @returns list of participants
810
*/
911
export function useParticipationsListData(date: string) {
10-
const listDataState = ref<string[]>([]);
12+
const listDataState = ref<IProfile[]>([]);
1113
const loaded = ref(false);
1214
const useParticipationsError = ref(false);
1315

@@ -20,16 +22,21 @@ export function useParticipationsListData(date: string) {
2022
return;
2123
}
2224

23-
const { error, response: listData, request } = useApi<string[]>('GET', `/api/participations/day/${date}`);
25+
const {
26+
error,
27+
response: listData,
28+
request
29+
} = useApi<Dictionary<IProfile>>('GET', `/api/participations/day/${date}`);
2430
useParticipationsError.value = error.value;
2531

2632
if (loaded.value === false) {
2733
await request();
2834
loaded.value = true;
2935

30-
listDataState.value = listData.value as string[];
36+
listDataState.value = Object.values(listData.value ?? {});
3137
}
3238
}
39+
3340
return {
3441
useParticipationsError,
3542
listData: readonly(listDataState),

src/Resources/src/components/dashboard/MealData.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{{ title }}
1212
<VeggiIcon
1313
v-if="meal.diet && meal.diet !== Diet.MEAT"
14+
class="aspect-square"
1415
:diet="meal.diet"
1516
:class="meal.diet === Diet.VEGAN ? 'h-[17px]' : 'ml-[2px] h-[14px]'"
1617
/>

src/Resources/src/components/dashboard/VariationsData.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
{{ locale.substring(0, 2) === 'en' ? variation.title.en : variation.title.de }}
1919
<VeggiIcon
2020
v-if="variation.diet && variation.diet !== Diet.MEAT"
21+
class="aspect-square"
2122
:diet="variation.diet"
2223
:class="variation.diet === Diet.VEGAN ? 'h-[17px]' : 'ml-[2px] h-[14px]'"
2324
/>

src/Resources/src/components/dishes/DishTableRow.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</span>
1313
<VeggiIcon
1414
:diet="dish.diet"
15-
class="h-6"
15+
class="aspect-square h-6"
1616
/>
1717
</td>
1818
<td
@@ -49,7 +49,7 @@
4949
</span>
5050
<VeggiIcon
5151
:diet="variation.diet"
52-
class="h-6"
52+
class="aspect-square h-6"
5353
/>
5454
</td>
5555
<td

src/Resources/src/components/eventParticipation/EventPopup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const isLoading = ref(false);
7777
watch(showParticipations, async () => {
7878
if (showParticipations.value === true) {
7979
isLoading.value = true;
80-
participations.value = (await getParticipantsForEvent(props.date)) as string[];
80+
participations.value = ((await getParticipantsForEvent(props.date)) as string[]).sort();
8181
isLoading.value = false;
8282
}
8383
});

src/Resources/src/components/guest/GuestMeal.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{{ title }}
99
<VeggiIcon
1010
v-if="meal.diet && meal.diet !== Diet.MEAT"
11+
class="aspect-square"
1112
:diet="meal.diet"
1213
:class="meal.diet === Diet.VEGAN ? 'h-[17px]' : 'ml-[2px] h-[14px]'"
1314
/>

src/Resources/src/components/guest/GuestVariation.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
{{ locale.substring(0, 2) === 'en' ? variation.title.en : variation.title.de }}
1919
<VeggiIcon
2020
v-if="variation.diet && variation.diet !== Diet.MEAT"
21+
class="aspect-square"
2122
:diet="variation.diet ?? Diet.MEAT"
2223
:class="variation.diet && variation.diet === Diet.VEGAN ? 'h-[17px]' : 'ml-[2px] h-[14px]'"
2324
/>

src/Resources/src/components/menuParticipants/AddParticipantsSearchBar.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const props = defineProps<{
9292
weekId: number;
9393
}>();
9494
95-
const { ProfilesState, fetchAbsentingProfiles } = useProfiles(props.weekId);
95+
const { ProfilesState, fetchAbsentingProfiles, getDisplayName } = useProfiles(props.weekId);
9696
const { t } = useI18n();
9797
const slot = useSlots();
9898
@@ -130,13 +130,6 @@ const filteredProfiles = computed(() => {
130130
});
131131
});
132132
133-
function getDisplayName(profile: IProfile) {
134-
if (profile.roles.includes('ROLE_GUEST')) {
135-
return `(${t('menu.guest')}) ${profile.fullName}`;
136-
}
137-
return profile.fullName;
138-
}
139-
140133
function handleClick() {
141134
openProp.value = true;
142135
useDetectClickOutside(combobox, () => (openProp.value = false));

src/Resources/src/components/menuParticipants/MenuTable.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import MenuTableBody from '@/components/menuParticipants/MenuTableBody.vue';
2020
import MenuTableHead from './MenuTableHead.vue';
2121
import { useProgress } from '@marcoschulte/vue3-progress';
2222
import LoadingSpinner from '../misc/LoadingSpinner.vue';
23-
import process from 'node:process';
2423
2524
const props = defineProps<{
2625
weekId: number;
@@ -49,7 +48,7 @@ onMounted(async () => {
4948
});
5049
5150
// expose functions for testing
52-
if (process?.env?.NODE_ENV === 'TEST') {
51+
if (import.meta.env.VITE_ENV === 'TEST') {
5352
defineExpose({ loaded });
5453
}
5554
</script>

src/Resources/src/components/menuParticipants/MenuTableBody.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { useI18n } from 'vue-i18n';
3232
import MenuTableRow from './MenuTableRow.vue';
3333
import MenuTableDataRows from '@/components/menuParticipants/MenuTableDataRows.vue';
3434
import { computed } from 'vue';
35+
import getDisplayName from '@/services/useConvertDisplayName';
3536
3637
const props = defineProps<{
3738
weekId: number;
@@ -43,7 +44,12 @@ const { t } = useI18n();
4344
const participants = computed(() => getParticipants());
4445
4546
const filteredParticipants = computed(() => {
46-
if (getFilter() === '') return participants.value;
47-
return participants.value.filter((participant) => participant.toLowerCase().includes(getFilter().toLowerCase()));
47+
if (getFilter() === '') {
48+
return participants.value.map((participant) => getDisplayName(participant, t));
49+
}
50+
51+
return participants.value
52+
.filter((participant) => participant.toLowerCase().includes(getFilter().toLowerCase()))
53+
.map((participant) => getDisplayName(participant, t));
4854
});
4955
</script>

src/Resources/src/components/misc/VeggiIcon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="group relative my-auto grid aspect-square content-center">
2+
<div class="group relative my-auto grid content-center">
33
<img
44
v-if="diet === Diet.VEGETARIAN"
55
class="object-cover"

src/Resources/src/components/participations/ParticipantsListByDay.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,24 @@
2525
:key="index"
2626
>
2727
<tr :class="[0 ? 'border-gray-300' : 'border-gray-200', 'border-b']">
28-
<td class="leading- h-6 whitespace-nowrap py-1 text-[12px] font-light text-primary">
29-
<div v-if="participant === 'noParticipants'">
30-
{{ t('flashMessage.success.participations.no') }}
31-
</div>
32-
<div v-else>
33-
{{ participant }}
28+
<td class="h-6 whitespace-nowrap py-1 text-[12px] font-light text-primary">
29+
<div>
30+
{{ getDisplayName(participant) }}
3431
</div>
3532
</td>
3633
</tr>
3734
</template>
3835
</tbody>
3936
</table>
37+
<div v-if="filteredParticipants.length < 1">
38+
{{ t('flashMessage.success.participations.no') }}
39+
</div>
4040
</div>
4141
</template>
4242

4343
<script setup lang="ts">
4444
import { filterParticipantsList } from '@/services/filterParticipantsList';
45+
import { useProfiles } from '@/stores/profilesStore';
4546
import { DialogTitle } from '@headlessui/vue';
4647
import { useProgress } from '@marcoschulte/vue3-progress';
4748
import { ref, watch } from 'vue';
@@ -57,6 +58,7 @@ const props = defineProps<{
5758
}>();
5859
5960
const { filteredParticipants, setFilter } = filterParticipantsList(props.date);
61+
const { getDisplayName } = useProfiles(0);
6062
const { t } = useI18n();
6163
6264
const filterInput = ref('');

src/Resources/src/components/participations/ParticipantsTableBody.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { type IBookedData, getShowParticipations } from '@/api/getShowParticipat
2121
import ParticipantsTableSlot from './ParticipantsTableSlot.vue';
2222
import { computed, onMounted, onUnmounted, ref } from 'vue';
2323
import { type Dictionary } from '@/types/types';
24-
import process from 'node:process';
2524
2625
const { participationsState, getMealsWithVariations, loadedState } = getShowParticipations();
2726
@@ -116,7 +115,7 @@ function convertToIBookedData(participant: Dictionary<IBookedData>): Dictionary<
116115
}
117116
118117
// expose functions for testing
119-
if (process?.env?.NODE_ENV === 'TEST') {
118+
if (import.meta.env.VITE_ENV === 'TEST') {
120119
defineExpose({ scrollAmount, setScrollDirection, scrollDirectionDown, mealsWithVariations });
121120
}
122121
</script>

src/Resources/src/components/participations/ParticipantsTableRow.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
>
77
<div class="flex w-full flex-row">
88
<span>
9-
{{ participantName }}
9+
{{ getDisplayName(participantName, t) }}
1010
</span>
1111
<svg
1212
v-if="isOfferingMeal"
@@ -41,6 +41,10 @@
4141
import type { IBookedData, IMealWithVariations } from '@/api/getShowParticipations';
4242
import ParticipantsTableData from './ParticipantsTableData.vue';
4343
import { computed } from 'vue';
44+
import getDisplayName from '@/services/useConvertDisplayName';
45+
import { useI18n } from 'vue-i18n';
46+
47+
const { t } = useI18n();
4448
4549
const props = defineProps<{
4650
participantName: string;

src/Resources/src/components/participations/ParticipationsTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ onUpdated(() => {
4343
}
4444
});
4545
46-
if (process?.env?.NODE_ENV === 'TEST') {
46+
if (import.meta.env.VITE_ENV === 'TEST') {
4747
defineExpose({ tableHeight });
4848
}
4949
</script>

src/Resources/src/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
"notFound": "No profiles found for this query",
287287
"shortQuery": "Min. 3 Buchstaben für Suche eingeben",
288288
"search": "Filter participant",
289-
"guest": "Gast",
289+
"guest": "Guest",
290290
"noMeals": "No dishes selected yet"
291291
},
292292
"printList": {

src/Resources/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const i18n = createI18n({
2727
// fill stores with data
2828
Promise.all([userDataStore.fillStore(), environmentStore.fillStore()]).then(() => {
2929
const MainApp = createApp(App);
30-
MainApp.config.performance = process.env.NODE_ENV !== 'production'; // enable Vue Devtools
30+
MainApp.config.performance = import.meta.env.VITE_ENV !== 'production'; // enable Vue Devtools
3131
MainApp.use(i18n);
3232
MainApp.use(router);
3333
MainApp.use(VueScreen);

0 commit comments

Comments
 (0)