Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#541, #555: Refactor imports and optimize date computations #562

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'),
],
};