diff --git a/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue b/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue index eab4e2f..30cd715 100644 --- a/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue +++ b/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue @@ -21,19 +21,25 @@ - Home + Current Event - - - - - + + + + All Events + + + + + + + + + + + + new EventService()); const alertService = inject('alertService', () => useAlertService(), true); - + const { formatDateShort } = useDateFormat(); const dataUtils = useDataUtils(); const route = useRoute(); @@ -20,27 +22,47 @@ export default defineComponent({ const previousState = () => router.go(-1); const event: Ref = ref({}); + const sortedAndIndexedRegistrations: Ref = ref([]); - const retrieveEvent = async eventId => { + const retrieveEvent = async (eventId: string) => { try { const res = await eventService().find(eventId); event.value = res; + // sortedAndIndexedRegistrations.value = res.registrations; + sortedAndIndexedRegistrations.value = res.registrations.sort( + (a, b) => new Date(a.dateTime).getTime() - new Date(b.dateTime).getTime(), + ); } catch (error) { alertService.showHttpError(error.response); } }; if (route.params?.eventId) { - retrieveEvent(route.params.eventId); + retrieveEvent(route.params.eventId as string); } + // const sortedAndIndexedRegistrations = () => { + // console.log('asdfasdfasdf', event.value.registrations) + // console.log('asdfasdfasdf', event.value) + // return [...(event.value.registrations || [])].sort((a, b) => + // new Date(a.dateTime).getTime() - new Date(b.dateTime).getTime() + // ); + // }; + + const getRegistrationIndex = (index: number) => { + const activeCount = sortedAndIndexedRegistrations.value.slice(0, index).filter(r => r.active).length; + return sortedAndIndexedRegistrations.value[index].active ? activeCount + 1 : ''; + }; + + // console.log('asdfasdf', sortedAndIndexedRegistrations()) return { alertService, event, - ...dataUtils, - + formatDateShort, previousState, + sortedAndIndexedRegistrations, + getRegistrationIndex, }; }, }); diff --git a/src/main/webapp/app/entities/event/event-details.vue b/src/main/webapp/app/entities/event/event-details.vue index e361043..0b11d31 100644 --- a/src/main/webapp/app/entities/event/event-details.vue +++ b/src/main/webapp/app/entities/event/event-details.vue @@ -35,29 +35,93 @@ {{ event.comment }} - -

Rejestracje

-
    -
  • - {{ registration.playerName }} - -
  • -
- +
+ + + + + + + + + + + + + + + + + + - - - - + + + +
#Date TimePlayer NameCommentActive
+ + {{ getRegistrationIndex(index) }} + {{ formatDateShort(registration.dateTime) || '' }}{{ registration.playerName }}{{ registration.comment }}{{ registration.active }} +
+ + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + diff --git a/src/main/webapp/app/entities/event/event.component.ts b/src/main/webapp/app/entities/event/event.component.ts index c850b0e..7966c71 100644 --- a/src/main/webapp/app/entities/event/event.component.ts +++ b/src/main/webapp/app/entities/event/event.component.ts @@ -1,9 +1,11 @@ -import { type Ref, defineComponent, inject, onMounted, ref } from 'vue'; +import { type Ref, defineComponent, inject, onMounted, ref, computed } from 'vue'; import EventService from './event.service'; import { type IEvent } from '@/shared/model/event.model'; import useDataUtils from '@/shared/data/data-utils.service'; import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import type AccountService from '@/account/account.service'; export default defineComponent({ compatConfig: { MODE: 3 }, @@ -12,8 +14,11 @@ export default defineComponent({ const dataUtils = useDataUtils(); const eventService = inject('eventService', () => new EventService()); const alertService = inject('alertService', () => useAlertService(), true); - + const accountService = inject('accountService'); const events: Ref = ref([]); + const authenticated = computed(() => store.authenticated); + const hasAnyAuthorityValues: Ref = ref({}); + const dateFormat = useDateFormat(); const isFetching = ref(false); @@ -67,12 +72,26 @@ export default defineComponent({ isFetching, retrieveEvents, clear, + accountService, + hasAnyAuthorityValues, + authenticated, removeId, removeEntity, prepareRemove, closeDialog, removeEvent, ...dataUtils, + ...dateFormat, }; }, + methods: { + hasAnyAuthority(authorities: any): boolean { + this.accountService.hasAnyAuthorityAndCheckAuth(authorities).then(value => { + if (this.hasAnyAuthorityValues[authorities] !== value) { + this.hasAnyAuthorityValues = { ...this.hasAnyAuthorityValues, [authorities]: value }; + } + }); + return this.hasAnyAuthorityValues[authorities] ?? false; + }, + }, }); diff --git a/src/main/webapp/app/entities/event/event.vue b/src/main/webapp/app/entities/event/event.vue index a2d71a1..0a67fb7 100644 --- a/src/main/webapp/app/entities/event/event.vue +++ b/src/main/webapp/app/entities/event/event.vue @@ -6,7 +6,7 @@ - + - +