[fix] set start date to midnight

This commit is contained in:
Ferdinand Thiessen 2021-11-21 12:36:17 +01:00
parent 8f8eef1784
commit 661685c57a
5 changed files with 24 additions and 6 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

@ -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

@ -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" />
@ -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

@ -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;
}
},
},
});