po poprawkach
This commit is contained in:
@@ -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>('accountService');
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -54,15 +60,72 @@ export default defineComponent({
|
||||
return sortedAndIndexedRegistrations.value[index].active ? activeCount + 1 : '';
|
||||
};
|
||||
|
||||
const hasAnyAuthorityValues: Ref<any> = ref({});
|
||||
const removeId: Ref<number> = ref(null);
|
||||
const removeEntity = ref<any>(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<IUser> = 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;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,34 +2,34 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<div v-if="event">
|
||||
<h2 class="jh-entity-heading" data-cy="eventDetailsHeading"><span>Event</span> {{ event.id }}</h2>
|
||||
<!-- <h2 class="jh-entity-heading" data-cy="eventDetailsHeading"><span>Event</span> {{ event.id }}</h2>-->
|
||||
<dl class="row jh-entity-details">
|
||||
<dt>
|
||||
<span>Name</span>
|
||||
<span>Nazwa</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ event.name }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>Date</span>
|
||||
<span>Data</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ event.date }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>Players Limit</span>
|
||||
<span>Limit graczy</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ event.playersLimit }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>Cost</span>
|
||||
<span>Koszt do podziału</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ event.cost }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>Comment</span>
|
||||
<span>Komentarz</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ event.comment }}</span>
|
||||
@@ -45,10 +45,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><span>#</span></th>
|
||||
<th scope="col"><span>Date Time</span></th>
|
||||
<th scope="col"><span>Player Name</span></th>
|
||||
<th scope="col"><span>Comment</span></th>
|
||||
<th scope="col"><span>Active</span></th>
|
||||
<th scope="col"><span>Czas zapisu</span></th>
|
||||
<th scope="col"><span>Gracz</span></th>
|
||||
<th scope="col"><span>Komentarz</span></th>
|
||||
<!-- <th scope="col"><span>Active</span></th>-->
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -59,9 +59,22 @@
|
||||
{{ getRegistrationIndex(index) }}
|
||||
</td>
|
||||
<td>{{ formatDateShort(registration.dateTime) || '' }}</td>
|
||||
<td>{{ registration.playerName }}</td>
|
||||
<td>
|
||||
{{ registration.playerName }}
|
||||
<b-button
|
||||
@click="prepareRemove(registration)"
|
||||
variant="danger"
|
||||
class="btn btn-sm"
|
||||
data-cy="entityDeleteButton"
|
||||
v-if="(registration.id && registration.user?.id == currentUserId) || hasAnyAuthority('ROLE_ADMIN')"
|
||||
v-b-modal.removeEntity
|
||||
>
|
||||
<font-awesome-icon icon="times"></font-awesome-icon>
|
||||
<span class="d-none d-md-inline">Delete</span>
|
||||
</b-button>
|
||||
</td>
|
||||
<td>{{ registration.comment }}</td>
|
||||
<td>{{ registration.active }}</td>
|
||||
<!-- <td>{{ registration.active }}</td>-->
|
||||
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
@@ -75,16 +88,16 @@
|
||||
<span class="d-none d-md-inline">View</span>
|
||||
</button>
|
||||
</router-link>
|
||||
<!-- <b-button-->
|
||||
<!-- @click="prepareRemove(registration)"-->
|
||||
<!-- variant="danger"-->
|
||||
<!-- class="btn btn-sm"-->
|
||||
<!-- data-cy="entityDeleteButton"-->
|
||||
<!-- v-b-modal.removeEntity-->
|
||||
<!-- >-->
|
||||
<!-- <font-awesome-icon icon="times"></font-awesome-icon>-->
|
||||
<!-- <span class="d-none d-md-inline">Delete</span>-->
|
||||
<!-- </b-button>-->
|
||||
<!-- <b-button-->
|
||||
<!-- @click="prepareRemove(registration)"-->
|
||||
<!-- variant="danger"-->
|
||||
<!-- class="btn btn-sm"-->
|
||||
<!-- data-cy="entityDeleteButton"-->
|
||||
<!-- v-b-modal.removeEntity-->
|
||||
<!-- >-->
|
||||
<!-- <font-awesome-icon icon="times"></font-awesome-icon>-->
|
||||
<!-- <span class="d-none d-md-inline">Delete</span>-->
|
||||
<!-- </b-button>-->
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2 id="page-heading" data-cy="EventHeading">
|
||||
<span id="event-heading">Events</span>
|
||||
<span id="event-heading">Wydarzenia</span>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-info mr-2" @click="handleSyncList" :disabled="isFetching">
|
||||
<font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon> <span>Refresh list</span>
|
||||
<font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon> <span>Odśwież listę</span>
|
||||
</button>
|
||||
<router-link :to="{ name: 'EventCreate' }" custom v-slot="{ navigate }" v-if="hasAnyAuthority('ROLE_ADMIN')">
|
||||
<button
|
||||
@@ -14,25 +14,25 @@
|
||||
class="btn btn-primary jh-create-entity create-event"
|
||||
>
|
||||
<font-awesome-icon icon="plus"></font-awesome-icon>
|
||||
<span>Create a new Event</span>
|
||||
<span>Utwórz nowe wydarzenie</span>
|
||||
</button>
|
||||
</router-link>
|
||||
</div>
|
||||
</h2>
|
||||
<br />
|
||||
<div class="alert alert-warning" v-if="!isFetching && events && events.length === 0">
|
||||
<span>No Events found</span>
|
||||
<span>Brak wydarzeń</span>
|
||||
</div>
|
||||
<div class="table-responsive" v-if="events && events.length > 0">
|
||||
<table class="table table-striped" aria-describedby="events">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="row"><span>ID</span></th>
|
||||
<th scope="row"><span>Name</span></th>
|
||||
<th scope="row"><span>Date</span></th>
|
||||
<th scope="row"><span>Players Limit</span></th>
|
||||
<th scope="row"><span>Cost</span></th>
|
||||
<th scope="row"><span>Comment</span></th>
|
||||
<th scope="row"><span>Nazwa</span></th>
|
||||
<th scope="row"><span>Data</span></th>
|
||||
<th scope="row"><span>Limit graczy</span></th>
|
||||
<th scope="row"><span>Koszt</span></th>
|
||||
<th scope="row"><span>Komentarz</span></th>
|
||||
<th scope="row"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
<dd>
|
||||
<span v-if="registration.dateTime">{{ formatDateLong(registration.dateTime) }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>Aktywna</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ registration.active }}</span>
|
||||
</dd>
|
||||
<!-- <dt>-->
|
||||
<!-- <span>Aktywna</span>-->
|
||||
<!-- </dt>-->
|
||||
<!-- <dd>-->
|
||||
<!-- <span>{{ registration.active }}</span>-->
|
||||
<!-- </dd>-->
|
||||
<dt>
|
||||
<span>Imię i Nazwisko gracza</span>
|
||||
</dt>
|
||||
@@ -52,7 +52,7 @@
|
||||
<button type="submit" @click.prevent="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
|
||||
<font-awesome-icon icon="arrow-left"></font-awesome-icon> <span>Back</span>
|
||||
</button>
|
||||
<router-link
|
||||
<!-- <router-link
|
||||
v-if="registration.id && registration.user?.id == currentUserId"
|
||||
:to="{ name: 'RegistrationEdit', params: { registrationId: registration.id } }"
|
||||
custom
|
||||
@@ -61,7 +61,7 @@
|
||||
<button @click="navigate" class="btn btn-primary">
|
||||
<font-awesome-icon icon="pencil-alt"></font-awesome-icon> <span>Edit</span>
|
||||
</button>
|
||||
</router-link>
|
||||
</router-link>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,20 +2,18 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<form name="editForm" novalidate @submit.prevent="save()">
|
||||
<h2 id="sasiedziApp.registration.home.createOrEditLabel" data-cy="RegistrationCreateUpdateHeading">
|
||||
Create or edit a Registration
|
||||
</h2>
|
||||
<h2 id="sasiedziApp.registration.home.createOrEditLabel" data-cy="RegistrationCreateUpdateHeading">Rejestracja na wydarzenie</h2>
|
||||
<div>
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="registration-event">Event</label>
|
||||
<label class="form-control-label" for="registration-event">Wydarzenie</label>
|
||||
<input type="text" class="form-control" id="registration-event" name="eventName" :value="eventName" disabled />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="registration-user">User</label>
|
||||
<label class="form-control-label" for="registration-user">Płacący</label>
|
||||
<input type="text" class="form-control" id="registration-user" name="userName" :value="currentUserFullName" disabled />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="registration-playerName">Player Name</label>
|
||||
<label class="form-control-label" for="registration-playerName">Grający</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
@@ -25,7 +23,7 @@
|
||||
v-model="v$.playerName.$model"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<label class="form-control-label" for="registration-dateTime">Reservation Time</label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
@@ -35,8 +33,8 @@
|
||||
:value="currentDateTime"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
</div>-->
|
||||
<!-- <div class="form-group">
|
||||
<label class="form-control-label" for="registration-active">Active</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -51,9 +49,9 @@
|
||||
<div v-if="v$.active.$anyDirty && v$.active.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.active.$errors" :key="error.$uid">{{ error.$message }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="form-group">
|
||||
<label class="form-control-label" for="registration-comment">Comment</label>
|
||||
<label class="form-control-label" for="registration-comment">Komentarz</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
name="comment"
|
||||
|
||||
Reference in New Issue
Block a user