add new event and attendance table with automatic now timestamp
All checks were successful
Build Quasar SPA and Go Backend for memberApp / build-spa (push) Successful in 2m34s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, .exe, windows) (push) Successful in 5m39s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, , linux) (push) Successful in 5m46s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm, 6, , linux) (push) Successful in 5m32s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm64, , linux) (push) Successful in 5m35s
All checks were successful
Build Quasar SPA and Go Backend for memberApp / build-spa (push) Successful in 2m34s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, .exe, windows) (push) Successful in 5m39s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, , linux) (push) Successful in 5m46s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm, 6, , linux) (push) Successful in 5m32s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm64, , linux) (push) Successful in 5m35s
This commit is contained in:
93
src/components/EventEditAllDialog.vue
Normal file
93
src/components/EventEditAllDialog.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<DialogFrame
|
||||
ref="dialog"
|
||||
:header-title="newEvent ? $t('addNewEvent') : 'Edit ' + localEvent.name"
|
||||
:height="250"
|
||||
:width="500"
|
||||
>
|
||||
<q-form ref="form">
|
||||
<div class="row justify-center q-gutter-md">
|
||||
<q-input
|
||||
class="q-ml-md col-5 required"
|
||||
:label="$t('eventName')"
|
||||
filled
|
||||
:rules="[(val) => !!val || $t('eventNameIsRequired')]"
|
||||
v-model="localEvent.name"
|
||||
autofocus
|
||||
@keyup.enter="save"
|
||||
></q-input>
|
||||
</div>
|
||||
</q-form>
|
||||
<div class="row justify-center">
|
||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||
</div>
|
||||
</DialogFrame>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||
import { ref } from 'vue';
|
||||
import { appApi } from 'src/boot/axios';
|
||||
import type { Event } from 'src/vueLib/models/event';
|
||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||
|
||||
const { NotifyResponse } = useNotify();
|
||||
const dialog = ref();
|
||||
const form = ref();
|
||||
const newEvent = ref(false);
|
||||
const localEvent = ref<Event>({
|
||||
id: 0,
|
||||
name: '',
|
||||
attendees: [],
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update']);
|
||||
|
||||
function open(Event: Event | null) {
|
||||
if (Event === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Event !== null) {
|
||||
localEvent.value = Event;
|
||||
newEvent.value = false;
|
||||
} else {
|
||||
localEvent.value = {
|
||||
id: 0,
|
||||
name: '',
|
||||
attendees: [],
|
||||
};
|
||||
newEvent.value = true;
|
||||
}
|
||||
|
||||
dialog.value?.open();
|
||||
}
|
||||
|
||||
async function save() {
|
||||
const valid = await form.value.validate();
|
||||
|
||||
if (!valid) return;
|
||||
|
||||
let query = 'events/edit?id=' + localEvent.value.id;
|
||||
if (newEvent.value) {
|
||||
query = 'events/add?name=' + localEvent.value.name;
|
||||
}
|
||||
|
||||
appApi
|
||||
.post(query, JSON.stringify(localEvent.value))
|
||||
.then(() => {
|
||||
emit('update');
|
||||
dialog.value.close();
|
||||
})
|
||||
.catch((err) => NotifyResponse(err, 'error'));
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.required .q-field__label::after {
|
||||
content: ' *';
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user