fix event not working issue close #1
This commit is contained in:
@@ -4,7 +4,7 @@ go 1.24.5
|
||||
|
||||
require (
|
||||
gitea.tecamino.com/paadi/access-handler v1.0.12
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.12
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.14
|
||||
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1
|
||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
||||
github.com/gin-contrib/cors v1.7.6
|
||||
|
||||
@@ -2,8 +2,8 @@ gitea.tecamino.com/paadi/access-handler v1.0.12 h1:lSmW0YrBJJvCqCg0ukTJHlFUNwd7q
|
||||
gitea.tecamino.com/paadi/access-handler v1.0.12/go.mod h1:w71lpnuu5MgAWG3oiI9vsY2dWi4njF/iPrM/xV/dbBQ=
|
||||
gitea.tecamino.com/paadi/dbHandler v1.0.4 h1:ctnaec0GDdtw3gRQdUISVDYLJ9x+vt50VW41OemfhD4=
|
||||
gitea.tecamino.com/paadi/dbHandler v1.0.4/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.12 h1:chUTNlRpbB0dMcZtXpi114mrWO8G7jrTSkDYIvWzVzQ=
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.12/go.mod h1:iLm7nunVRzqJK8CV4PJVuWIhgPlQjNIaeOkmtfK5fMg=
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.14 h1:HO8YmVv9BmOguLMiubFABlQEnR3J+Qy46RwQQTXuWRs=
|
||||
gitea.tecamino.com/paadi/memberDB v1.0.14/go.mod h1:iLm7nunVRzqJK8CV4PJVuWIhgPlQjNIaeOkmtfK5fMg=
|
||||
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1 h1:vAq7mwUxlxJuLzCQSDMrZCwo8ky5usWi9Qz+UP+WnkI=
|
||||
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1/go.mod h1:+tmf1rjPaKEoNeUcr1vdtoFIFweNG3aUGevDAl3NMBk=
|
||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
<div class="row justify-center">
|
||||
<q-select
|
||||
autofocus
|
||||
class="q-ml-md col-6"
|
||||
:label="$t('event')"
|
||||
filled
|
||||
:options="events"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="selected"
|
||||
@keyup.enter="save"
|
||||
@keyup.enter="addAttendees"
|
||||
map-options
|
||||
emit-value
|
||||
></q-select>
|
||||
</div>
|
||||
<div class="row justify-center">
|
||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||
<q-btn class="q-ma-md" color="primary" no-caps @click="addAttendees">{{ localTitle }}</q-btn>
|
||||
</div>
|
||||
</DialogFrame>
|
||||
<EditAllDialog ref="newEventRef" v-on:update="(val) => resolveNewEvent(val)"></EditAllDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -29,13 +29,15 @@ import { useNotify } from 'src/vueLib/general/useNotify';
|
||||
import { i18n } from 'src/boot/lang';
|
||||
import type { Event, Events } from 'src/vueLib/models/event';
|
||||
import type { Members } from 'src/vueLib/models/member';
|
||||
import EditAllDialog from 'src/components/EventEditAllDialog.vue';
|
||||
import { useAttendeesTable } from 'src/vueLib/tables/attendees/AttendeesTable';
|
||||
import { useEventTable } from 'src/vueLib/tables/events/EventsTable';
|
||||
|
||||
const dialog = ref();
|
||||
const newEventRef = ref();
|
||||
const localTitle = ref('');
|
||||
const events = ref<Events>([{ id: -1, name: i18n.global.t('add'), attendees: [] }]);
|
||||
const selected = ref<Event>({ id: -1, name: i18n.global.t('add'), attendees: [] });
|
||||
const events = ref<Events>([{ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] }]);
|
||||
const selected = ref<Event>({ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] });
|
||||
const localMembers = ref<Members>([]);
|
||||
const { updateAttendees } = useAttendeesTable();
|
||||
const { updateEvents } = useEventTable();
|
||||
@@ -57,7 +59,7 @@ function open(title: string, members: Members) {
|
||||
localTitle.value = title;
|
||||
localMembers.value = members;
|
||||
|
||||
events.value = [{ id: -1, name: i18n.global.t('add'), attendees: [] }];
|
||||
events.value = [{ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] }];
|
||||
appApi
|
||||
.get('events')
|
||||
.then((resp) => {
|
||||
@@ -69,23 +71,44 @@ function open(title: string, members: Members) {
|
||||
dialog.value?.open();
|
||||
}
|
||||
|
||||
async function save() {
|
||||
await appApi
|
||||
.post(props.endpoint, {
|
||||
id: selected.value,
|
||||
async function addAttendees() {
|
||||
const payload = {
|
||||
id: Number(selected.value),
|
||||
attendees: localMembers.value,
|
||||
})
|
||||
};
|
||||
if (selected.value.id == -1) {
|
||||
const event = await addNewEvent();
|
||||
NotifyResponse(i18n.global.t('eventAdded') + ': ' + event.name);
|
||||
payload.id = event.id;
|
||||
}
|
||||
|
||||
console.log(56, payload);
|
||||
await appApi
|
||||
.post(props.endpoint, payload)
|
||||
.then(() => {
|
||||
emit('update-event', localMembers.value);
|
||||
NotifyResponse(i18n.global.t('eventAdded'));
|
||||
if (localMembers.value.length > 1) {
|
||||
NotifyResponse(i18n.global.t('attendeesAdded'));
|
||||
} else {
|
||||
NotifyResponse(i18n.global.t('attendeeAdded'));
|
||||
}
|
||||
dialog.value.close();
|
||||
})
|
||||
.catch((err) => {
|
||||
NotifyResponse(err, 'error');
|
||||
});
|
||||
|
||||
await updateAttendees();
|
||||
updateEvents();
|
||||
}
|
||||
|
||||
let resolveNewEvent!: (value: Event) => void;
|
||||
function addNewEvent(): Promise<Event> {
|
||||
newEventRef.value?.open(null);
|
||||
return new Promise((resolve) => {
|
||||
resolveNewEvent = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
@@ -50,7 +50,7 @@ function open(Event: Event | null) {
|
||||
|
||||
if (Event !== null) {
|
||||
localEvent.value = { ...Event };
|
||||
newEvent.value = false;
|
||||
newEvent.value = Event.id === 0;
|
||||
} else {
|
||||
localEvent.value = {
|
||||
id: 0,
|
||||
@@ -77,8 +77,8 @@ async function save() {
|
||||
|
||||
appApi
|
||||
.post(query, payload)
|
||||
.then(() => {
|
||||
emit('update');
|
||||
.then((resp) => {
|
||||
emit('update', resp.data.data);
|
||||
dialog.value.close();
|
||||
})
|
||||
.catch((err) => NotifyResponse(err, 'error'));
|
||||
|
||||
Reference in New Issue
Block a user