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;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user