From a55a8e26f6d1a65a0d7ec8a5fb65e88beb36966e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awek=20Zatorski?= Date: Thu, 7 Nov 2024 08:56:56 +0100 Subject: [PATCH] po poprawkach --- .../java/com/sasiedzi/event/domain/Event.java | 2 +- .../sasiedzi/event/domain/Registration.java | 2 +- .../webapp/app/core/jhi-navbar/jhi-navbar.vue | 4 +- .../entities/event/event-details.component.ts | 63 +++++++++++++++++++ .../app/entities/event/event-details.vue | 57 ++++++++++------- src/main/webapp/app/entities/event/event.vue | 18 +++--- .../registration/registration-details.vue | 16 ++--- .../registration/registration-update.vue | 20 +++--- 8 files changed, 128 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/sasiedzi/event/domain/Event.java b/src/main/java/com/sasiedzi/event/domain/Event.java index f93f04b..f166a7b 100644 --- a/src/main/java/com/sasiedzi/event/domain/Event.java +++ b/src/main/java/com/sasiedzi/event/domain/Event.java @@ -44,7 +44,7 @@ public class Event implements Serializable { private String comment; @OneToMany(fetch = FetchType.EAGER, mappedBy = "event") - @JsonIgnoreProperties(value = { "user", "event" }, allowSetters = true) + @JsonIgnoreProperties(value = { "event" }, allowSetters = true) private Set registrations = new HashSet<>(); // jhipster-needle-entity-add-field - JHipster will add fields here diff --git a/src/main/java/com/sasiedzi/event/domain/Registration.java b/src/main/java/com/sasiedzi/event/domain/Registration.java index 75c94a1..03b228c 100644 --- a/src/main/java/com/sasiedzi/event/domain/Registration.java +++ b/src/main/java/com/sasiedzi/event/domain/Registration.java @@ -37,7 +37,7 @@ public class Registration implements Serializable { @Column(name = "comment") private String comment; - @ManyToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.EAGER) private User user; @ManyToOne(fetch = FetchType.LAZY) 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 c941f0c..1108164 100644 --- a/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue +++ b/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue @@ -21,13 +21,13 @@ - Current Event + Aktualne wydarzenie - All Events + Wszystkie wydarzenia diff --git a/src/main/webapp/app/entities/event/event-details.component.ts b/src/main/webapp/app/entities/event/event-details.component.ts index aacf773..e194e73 100644 --- a/src/main/webapp/app/entities/event/event-details.component.ts +++ b/src/main/webapp/app/entities/event/event-details.component.ts @@ -7,6 +7,9 @@ import { type IEvent } from '@/shared/model/event.model'; import { useAlertService } from '@/shared/alert/alert.service'; import { useDateFormat } from '@/shared/composables'; import type { IRegistration } from '@/shared/model/registration.model'; +import RegistrationService from '@/entities/registration/registration.service'; +import UserService from '@/entities/user/user.service'; +import type AccountService from '@/account/account.service'; export default defineComponent({ compatConfig: { MODE: 3 }, @@ -17,6 +20,9 @@ export default defineComponent({ const { formatDateShort } = useDateFormat(); const dataUtils = useDataUtils(); + const registrationService = inject('registrationService', () => new RegistrationService()); + const accountService = inject('accountService'); + const route = useRoute(); const router = useRouter(); @@ -54,15 +60,72 @@ export default defineComponent({ return sortedAndIndexedRegistrations.value[index].active ? activeCount + 1 : ''; }; + const hasAnyAuthorityValues: Ref = ref({}); + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IRegistration) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeRegistration = async () => { + try { + await registrationService().delete(removeId.value); + var eventId = removeEntity.value.id; + const message = `A Registration is deleted with identifier ${removeId.value}`; + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + await retrieveEvent(event.value.id); + // console.log('asdfdsa' , event.value.id); + // 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(), + // ); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + const userService = inject('userService', () => new UserService()); + // const loggedUser: Ref = ref(new User()); + const currentUserId = ref(''); + userService() + .fetchAccountDetails() + .then(account => { + currentUserId.value = `${account.id}`; + }); + // console.log('asdfasdf', sortedAndIndexedRegistrations()) return { + currentUserId, alertService, + hasAnyAuthorityValues, + accountService, event, ...dataUtils, formatDateShort, previousState, sortedAndIndexedRegistrations, getRegistrationIndex, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeRegistration, }; }, + 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-details.vue b/src/main/webapp/app/entities/event/event-details.vue index 0b11d31..4b6f8c8 100644 --- a/src/main/webapp/app/entities/event/event-details.vue +++ b/src/main/webapp/app/entities/event/event-details.vue @@ -2,34 +2,34 @@
-

Event {{ event.id }}

+
- Name + Nazwa
{{ event.name }}
- Date + Data
{{ event.date }}
- Players Limit + Limit graczy
{{ event.playersLimit }}
- Cost + Koszt do podziału
{{ event.cost }}
- Comment + Komentarz
{{ event.comment }} @@ -45,10 +45,10 @@ # - Date Time - Player Name - Comment - Active + Czas zapisu + Gracz + Komentarz + @@ -59,9 +59,22 @@ {{ getRegistrationIndex(index) }} {{ formatDateShort(registration.dateTime) || '' }} - {{ registration.playerName }} + + {{ registration.playerName }} + + + Delete + + {{ registration.comment }} - {{ registration.active }} +
@@ -75,16 +88,16 @@ View - - - - - - - - - - + + + + + + + + + +
diff --git a/src/main/webapp/app/entities/event/event.vue b/src/main/webapp/app/entities/event/event.vue index 0a67fb7..cd03025 100644 --- a/src/main/webapp/app/entities/event/event.vue +++ b/src/main/webapp/app/entities/event/event.vue @@ -1,10 +1,10 @@