Compare commits

...

1 Commits

Author SHA1 Message Date
Ferdinand Thiessen 8b6fd67f1d [store] Rename to EventStore 2021-11-21 12:40:53 +01:00
8 changed files with 26 additions and 26 deletions

View File

@ -102,7 +102,7 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, PropType, ref, onBeforeMount } from 'vue'; import { computed, defineComponent, PropType, ref, onBeforeMount } from 'vue';
import { date, ModifyDateOptions } from 'quasar'; import { date, ModifyDateOptions } from 'quasar';
import { useScheduleStore } from '../../store'; import { useEventStore } from '../../store';
import { notEmpty } from '@flaschengeist/api'; import { notEmpty } from '@flaschengeist/api';
import { IsoDateInput } from '@flaschengeist/api/components'; import { IsoDateInput } from '@flaschengeist/api/components';
import EditJobSlot from './EditJobSlot.vue'; import EditJobSlot from './EditJobSlot.vue';
@ -127,7 +127,7 @@ export default defineComponent({
done: (val: boolean) => typeof val === 'boolean', done: (val: boolean) => typeof val === 'boolean',
}, },
setup(props, { emit }) { setup(props, { emit }) {
const store = useScheduleStore(); const store = useEventStore();
const startDate = computed(() => { const startDate = computed(() => {
const d = date.buildDate({milliseconds: 0, seconds: 0, minutes: 0, hours: 0}) const d = date.buildDate({milliseconds: 0, seconds: 0, minutes: 0, hours: 0})
if (!props.date || !date.isValid(props.date)) return d if (!props.date || !date.isValid(props.date)) return d

View File

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

View File

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

View File

@ -99,7 +99,7 @@
<script lang="ts"> <script lang="ts">
import { ComponentPublicInstance, computed, defineComponent, onBeforeMount, ref } from 'vue'; import { ComponentPublicInstance, computed, defineComponent, onBeforeMount, ref } from 'vue';
import { useScheduleStore } from '../../store'; import { useEventStore } from '../../store';
import EventSlot from './slots/EventSlot.vue'; import EventSlot from './slots/EventSlot.vue';
import { date, useQuasar } from 'quasar'; import { date, useQuasar } from 'quasar';
import { startOfWeek } from '@flaschengeist/api'; import { startOfWeek } from '@flaschengeist/api';
@ -111,7 +111,7 @@ export default defineComponent({
components: { EventSlot, EditEvent, QCalendarAgenda: <ComponentPublicInstance>QCalendarAgenda }, components: { EventSlot, EditEvent, QCalendarAgenda: <ComponentPublicInstance>QCalendarAgenda },
setup() { setup() {
const store = useScheduleStore(); const store = useEventStore();
const quasar = useQuasar(); const quasar = useQuasar();
const selectedDate = ref(date.formatDate(new Date(), 'YYYY-MM-DD')); const selectedDate = ref(date.formatDate(new Date(), 'YYYY-MM-DD'));

View File

@ -45,8 +45,8 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onBeforeMount, ref } from 'vue'; import { computed, defineComponent, onBeforeMount, ref } from 'vue';
import { useScheduleStore } from '../../store'; import { useEventStore } from '../../store';
import { date, scroll } from 'quasar'; import { date } from 'quasar';
import EditEvent from '../management/EditEvent.vue'; import EditEvent from '../management/EditEvent.vue';
import EventSlot from '../overview/slots/EventSlot.vue'; import EventSlot from '../overview/slots/EventSlot.vue';
@ -59,7 +59,7 @@ export default defineComponent({
[index: string]: FG.Event[]; [index: string]: FG.Event[];
} }
const store = useScheduleStore(); const store = useEventStore();
const editor = ref<FG.Event | undefined>(undefined); const editor = ref<FG.Event | undefined>(undefined);
const events = ref<FG.Event[]>([]); const events = ref<FG.Event[]>([]);

View File

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

View File

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

View File

@ -1,5 +1,4 @@
import { api, isAxiosError } from '@flaschengeist/api'; import { api, isAxiosError } from '@flaschengeist/api';
import { AxiosError } from 'axios';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
interface UserService { interface UserService {
@ -18,7 +17,7 @@ function fixEvent(event: FG.Event) {
event.jobs.forEach((job) => fixJob(job)); event.jobs.forEach((job) => fixJob(job));
} }
export const useScheduleStore = defineStore({ export const useEventStore = defineStore({
id: 'events', id: 'events',
state: () => ({ state: () => ({
@ -89,8 +88,7 @@ export const useScheduleStore = defineStore({
const idx = this.templates.findIndex((v) => v.id === id); const idx = this.templates.findIndex((v) => v.id === id);
if (idx !== -1) this.templates.splice(idx, 1); if (idx !== -1) this.templates.splice(idx, 1);
} catch (e) { } catch (e) {
const error = <AxiosError>e; if (isAxiosError(e, 404)) return false
if (error.response && error.response.status === 404) return false;
throw e; throw e;
} }
return true; return true;