Compare commits

...

2 Commits

Author SHA1 Message Date
Ferdinand Thiessen 4d3654f08a [store] Rename to EventStore 2021-11-21 12:39:02 +01:00
Ferdinand Thiessen 661685c57a [fix] set start date to midnight 2021-11-21 12:36:17 +01:00
9 changed files with 45 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
node_modules/
yarn-error.log
# No need, this is done by user

View File

@ -102,7 +102,7 @@
<script lang="ts">
import { computed, defineComponent, PropType, ref, onBeforeMount } from 'vue';
import { date, ModifyDateOptions } from 'quasar';
import { useScheduleStore } from '../../store';
import { useEventStore } from '../../store';
import { notEmpty } from '@flaschengeist/api';
import { IsoDateInput } from '@flaschengeist/api/components';
import EditJobSlot from './EditJobSlot.vue';
@ -127,7 +127,7 @@ export default defineComponent({
done: (val: boolean) => typeof val === 'boolean',
},
setup(props, { emit }) {
const store = useScheduleStore();
const store = useEventStore();
const startDate = computed(() => {
const d = date.buildDate({milliseconds: 0, seconds: 0, minutes: 0, hours: 0})
if (!props.date || !date.isValid(props.date)) return d
@ -180,9 +180,15 @@ export default defineComponent({
}
async function save(template = false) {
if (!event.value.is_template && template) event.value.id = NaN;
event.value.is_template = template;
try {
if (!isNaN(event.value.id)) {
//fix
}
await store.addEvent(event.value);
if (props.modelValue === undefined && recurrent.value && !event.value.is_template) {
let count = 0;
const options: ModifyDateOptions = {};

View File

@ -53,7 +53,7 @@
import { defineComponent, computed, onBeforeMount, PropType } from 'vue';
import { IsoDateInput } from '@flaschengeist/api/components';
import { notEmpty } from '@flaschengeist/api';
import { useScheduleStore } from '../../store';
import { useEventStore } from '../../store';
export default defineComponent({
name: 'JobSlot',
@ -73,7 +73,7 @@ export default defineComponent({
'update:modelValue': (job: FG.Job) => !!job,
},
setup(props, { emit }) {
const store = useScheduleStore();
const store = useEventStore();
onBeforeMount(() => store.getJobTypes());

View File

@ -50,8 +50,8 @@
<script lang="ts">
import { isAxiosError } from '@flaschengeist/api';
import { defineComponent, ref, computed, PropType, onBeforeMount } from 'vue';
import { useScheduleStore } from '../../store';
import { Notify, QInput } from 'quasar';
import { useEventStore } from '../../store';
import { useQuasar, QInput } from 'quasar';
export default defineComponent({
name: 'ManageTypes',
@ -61,7 +61,9 @@ export default defineComponent({
title: {type: String, required: true}
},
setup(props) {
const store = useScheduleStore();
const store = useEventStore();
const quasar = useQuasar();
const dialogOpen = ref(false);
const emptyType = { id: -1, name: '' };
const actualType = ref(emptyType);
@ -105,12 +107,12 @@ export default defineComponent({
})
.catch((e) => {
if (isAxiosError(e, 409))
Notify.create({
quasar.notify({
type: 'negative',
message: 'Der Name wird bereits verwendet',
});
else
Notify.create({
quasar.notify({
type: 'negative',
message: 'Unbekannter Fehler beim speichern.',
});

View File

@ -8,7 +8,7 @@
<q-card>
<div class="column">
<div class="col" align="right" style="position: sticky; top: 0; z-index: 999">
<q-btn round color="negative" icon="close" dense rounded @click="editDone(false)" />
<q-btn round color="negative" icon="mdi-close" dense rounded @click="editDone(false)" />
</div>
<div class="col" style="margin: 0; padding: 0; margin-top: -2.4em">
<edit-event v-model="editor" @done="editDone" />
@ -99,7 +99,7 @@
<script lang="ts">
import { ComponentPublicInstance, computed, defineComponent, onBeforeMount, ref } from 'vue';
import { useScheduleStore } from '../../store';
import { useEventStore } from '../../store';
import EventSlot from './slots/EventSlot.vue';
import { date, useQuasar } from 'quasar';
import { startOfWeek } from '@flaschengeist/api';
@ -111,7 +111,7 @@ export default defineComponent({
components: { EventSlot, EditEvent, QCalendarAgenda: <ComponentPublicInstance>QCalendarAgenda },
setup() {
const store = useScheduleStore();
const store = useEventStore();
const quasar = useQuasar();
const selectedDate = ref(date.formatDate(new Date(), 'YYYY-MM-DD'));
@ -158,7 +158,7 @@ export default defineComponent({
}
async function loadAgendas() {
const selected = date.adjustDate(new Date(selectedDate.value), {milliseconds: 0, seconds: 0, minutes: 0, hours: 0});
const selected = date.adjustDate(selectedDate.value, {milliseconds: 0, seconds: 0, minutes: 0, hours: 0});
const start = calendarRealView.value === 'day' ? selected : startOfWeek(selected);
const end = date.addToDate(start, { days: calendarDays.value });

View File

@ -51,6 +51,7 @@
import { defineComponent, computed, PropType } from 'vue';
import { hasPermission } from '@flaschengeist/api';
import { PERMISSIONS } from '../../../permissions';
import { date } from 'quasar';
import JobSlot from './JobSlot.vue';
export default defineComponent({
@ -72,8 +73,10 @@ export default defineComponent({
const canEdit = computed(
() =>
hasPermission(PERMISSIONS.EDIT) &&
(props.modelValue?.end || props.modelValue.start) > new Date()
(props.modelValue?.end || props.modelValue.start) >=
date.buildDate({ hours: 0, minutes: 0, seconds: 0, milliseconds: 0 })
);
const event = computed({
get: () => props.modelValue,
set: (v) => emit('update:modelValue', v),

View File

@ -36,9 +36,9 @@
<script lang="ts">
import { defineComponent, onBeforeMount, computed, PropType } from 'vue';
import { Notify } from 'quasar';
import { useQuasar } from 'quasar';
import { asHour, useMainStore, useUserStore } from '@flaschengeist/api';
import { useScheduleStore } from '../../../store';
import { useEventStore } from '../../../store';
export default defineComponent({
name: 'JobSlot',
@ -54,10 +54,10 @@ export default defineComponent({
},
emits: { 'update:modelValue': (v: FG.Job) => !!v },
setup(props, { emit }) {
const store = useScheduleStore();
const store = useEventStore();
const mainStore = useMainStore();
const userStore = useUserStore();
const availableUsers = null;
const quasar = useQuasar();
onBeforeMount(async () => userStore.getUsers());
@ -90,7 +90,7 @@ export default defineComponent({
emit('update:modelValue', job);
} catch (error) {
console.warn(error);
Notify.create({
quasar.notify({
group: false,
type: 'negative',
message: 'Fehler beim Eintragen als Dienst',
@ -113,7 +113,7 @@ export default defineComponent({
emit('update:modelValue', job);
} catch (error) {
console.warn(error);
Notify.create({
quasar.notify({
group: false,
type: 'negative',
message: 'Fehler beim Austragen als Dienst',

View File

@ -7,14 +7,14 @@
<script lang="ts">
import { onBeforeMount, defineComponent, ref } from 'vue';
import EditEvent from '../components/management/EditEvent.vue';
import { useScheduleStore } from '../store';
import { useEventStore } from '../store';
import { useRoute } from 'vue-router';
export default defineComponent({
components: { EditEvent },
setup() {
const route = useRoute();
const store = useScheduleStore();
const store = useEventStore();
const event = ref<FG.Event | undefined>(undefined);
onBeforeMount(async () => {
if ('id' in route.params && typeof route.params.id === 'string')

View File

@ -151,9 +151,17 @@ export const useScheduleStore = defineStore({
},
async addEvent(event: FG.Event) {
if (isNaN(event.id)) {
const { data } = await api.post<FG.Event>('/events', event);
if (data.is_template) this.templates.push(data);
return data;
} else {
if (typeof event.type === 'object') event.type = event.type.id;
const { data } = await api.put<FG.Event>(`/events/${event.id}`, Object.assign(event, {jobs: undefined}));
if (data.is_template) this.templates.push(data);
return data;
}
},
},
});