Skip to content

Commit

Permalink
Merge pull request #562 from MORE-Platform/541-default-scheduler-star…
Browse files Browse the repository at this point in the history
…ts-at-200-and-ends-at-100-instead-of-0000-to-2359

#541, #555: Refactor imports and optimize date computations
  • Loading branch information
janoliver20 authored Dec 2, 2024
2 parents b6ccff3 + 400c6b3 commit 94e3ed6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
30 changes: 22 additions & 8 deletions src/components/shared/Scheduler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Prevention -- A research institute of the Ludwig Boltzmann Gesellschaft,
Oesterreichische Vereinigung zur Foerderung der wissenschaftlichen Forschung).
Licensed under the Elastic License 2.0. */
<script setup lang="ts">
import { inject, ref, Ref, watch } from 'vue';
import { computed, inject, ref, Ref, watch } from 'vue';
import Calendar from 'primevue/calendar';
import Button from 'primevue/button';
import Checkbox from 'primevue/checkbox';
Expand All @@ -22,6 +22,18 @@ Licensed under the Elastic License 2.0. */
const studyStore = useStudyStore();
const minDate = computed(() => {
const date = new Date(studyStore.study.plannedStart!);
date.setHours(0, 0, 0);
return date;
});
const maxDate = computed(() => {
const date = new Date(studyStore.study.plannedEnd!);
date.setHours(23, 59, 59);
return date;
});
const scheduler: any = dialogRef.value.data.scheduler;
const returnSchedule: Ref<Event> = ref({
type: scheduler.type ?? ScheduleType.Event,
Expand All @@ -33,9 +45,11 @@ Licensed under the Elastic License 2.0. */
const calendarStart: Ref<Date> = ref(
new Date(returnSchedule.value.dtstart as string),
);
calendarStart.value.setHours(0, 0, 0);
const calendarEnd: Ref<Date> = ref(
new Date(returnSchedule.value.dtend as string),
);
calendarEnd.value.setHours(23, 59, 59);
let calendarEndChangedWithStart: boolean = false;
watch(calendarStart, (newValue, oldValue) => {
Expand Down Expand Up @@ -293,8 +307,8 @@ Licensed under the Elastic License 2.0. */
v-model="calendarStart"
:date-format="dateFormat"
:placeholder="dateFormat"
:min-date="new Date(studyStore.study.plannedStart as string)"
:max-date="new Date(studyStore.study.plannedEnd as string)"
:min-date="minDate"
:max-date="maxDate"
:manual-input="false"
autocomplete="off"
class="start-date col-span-2 col-start-2 w-full"
Expand All @@ -303,8 +317,8 @@ Licensed under the Elastic License 2.0. */
<Calendar
v-if="!entireDayCheckbox"
v-model="calendarStart"
:min-date="new Date(studyStore.study.plannedStart as string)"
:max-date="new Date(studyStore.study.plannedEnd as string)"
:min-date="minDate"
:max-date="maxDate"
:manual-input="false"
placeholder="hh:mm"
class="p-calendar-timeonly start-date start-time col-span-1"
Expand All @@ -322,7 +336,7 @@ Licensed under the Elastic License 2.0. */
v-if="!singleDayEventCheckbox"
v-model="calendarEnd"
:min-date="calendarStart"
:max-date="new Date(studyStore.study.plannedEnd as string)"
:max-date="maxDate"
:manual-input="false"
:date-format="dateFormat"
:placeholder="dateFormat"
Expand All @@ -340,8 +354,8 @@ Licensed under the Elastic License 2.0. */
v-if="!entireDayCheckbox"
v-model="calendarEnd"
:manual-input="false"
:min-date="new Date(studyStore.study.plannedStart as string)"
:max-date="new Date(studyStore.study.plannedEnd as string)"
:min-date="minDate"
:max-date="maxDate"
placeholder="hh:mm"
class="p-calendar-timeonly start-date start-time col-span-1"
:class="{
Expand Down
8 changes: 4 additions & 4 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const defaultTheme = require('tailwindcss/defaultTheme');
import defaultTheme from 'tailwindcss/defaultTheme';

/** @type {import("@types/tailwindcss/tailwind-config").TailwindConfig } */
module.exports = {
Expand All @@ -11,8 +11,8 @@ module.exports = {
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
require('@tailwindcss/aspect-ratio'),
import('@tailwindcss/forms'),
import('@tailwindcss/typography'),
import('@tailwindcss/aspect-ratio'),
],
};

0 comments on commit 94e3ed6

Please sign in to comment.