2024-07-26 03:14:55 +02:00
|
|
|
import "./calendarPage.css";
|
|
|
|
|
|
2024-07-25 19:32:46 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
2024-07-26 07:07:07 +02:00
|
|
|
import CalendarModel from "../../Model/Files/calendarModel";
|
2024-07-25 19:32:46 +02:00
|
|
|
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
|
2024-07-26 03:14:55 +02:00
|
|
|
import { MonthGrid } from "../Components/monthGrid";
|
2024-07-26 06:20:16 +02:00
|
|
|
import { TaskSettingsModal } from "../Modals/taskSettingsModal";
|
2024-07-26 05:43:49 +02:00
|
|
|
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
2024-07-26 03:14:55 +02:00
|
|
|
import { translations } from "../translations";
|
2024-07-25 19:32:46 +02:00
|
|
|
|
|
|
|
|
export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
|
|
|
|
|
calendarPageViewModel.loadData();
|
|
|
|
|
|
2024-07-26 03:14:55 +02:00
|
|
|
const mainContent = React.createProxyState(
|
|
|
|
|
[calendarPageViewModel.monthGrid],
|
|
|
|
|
() => {
|
2024-07-26 07:07:07 +02:00
|
|
|
const monthGrid = calendarPageViewModel.monthGrid.value;
|
|
|
|
|
|
|
|
|
|
if (monthGrid == undefined) {
|
2024-07-26 03:14:55 +02:00
|
|
|
return <div></div>;
|
|
|
|
|
} else {
|
2024-07-26 07:07:07 +02:00
|
|
|
function drop(date: string) {
|
|
|
|
|
calendarPageViewModel.handleDrop(
|
|
|
|
|
monthGrid!.year.toString(),
|
|
|
|
|
monthGrid!.month.toString(),
|
|
|
|
|
date
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MonthGrid(monthGrid, calendarPageViewModel.selectedDate, drop);
|
2024-07-26 03:14:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-26 05:43:49 +02:00
|
|
|
const sidePaneContent = React.createProxyState(
|
|
|
|
|
[
|
|
|
|
|
calendarPageViewModel.selectedYear,
|
|
|
|
|
calendarPageViewModel.selectedMonth,
|
|
|
|
|
calendarPageViewModel.selectedDate,
|
|
|
|
|
],
|
|
|
|
|
() => {
|
2024-07-26 16:49:13 +02:00
|
|
|
const listState = calendarPageViewModel.getEventsForDate();
|
2024-07-26 05:43:49 +02:00
|
|
|
|
|
|
|
|
if (listState == undefined) {
|
|
|
|
|
return <div></div>;
|
2024-07-26 07:11:17 +02:00
|
|
|
} else if (listState.value.size == 0) {
|
|
|
|
|
return (
|
|
|
|
|
<div class="width-100 height-100 flex-column justify-center align-center">
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.chatPage.calendar.noEvents}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-07-26 05:43:49 +02:00
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2024-07-26 06:30:28 +02:00
|
|
|
class="flex-column gap slide-up"
|
2024-07-26 05:43:49 +02:00
|
|
|
children:append={[listState, TaskViewModelToEntry]}
|
|
|
|
|
></div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-26 06:20:16 +02:00
|
|
|
const taskSettingsModal = React.createProxyState(
|
|
|
|
|
[calendarPageViewModel.selectedTaskViewModel],
|
|
|
|
|
() => {
|
|
|
|
|
if (calendarPageViewModel.selectedTaskViewModel.value == undefined) {
|
|
|
|
|
return <div></div>;
|
|
|
|
|
} else {
|
|
|
|
|
return TaskSettingsModal(
|
|
|
|
|
calendarPageViewModel.selectedTaskViewModel.value
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-26 03:14:55 +02:00
|
|
|
return (
|
|
|
|
|
<div id="calendar-page">
|
2024-07-26 06:30:28 +02:00
|
|
|
<div class="pane-wrapper grid-pane-wrapper">
|
2024-07-26 03:14:55 +02:00
|
|
|
<div class="pane">
|
|
|
|
|
<div class="toolbar">
|
|
|
|
|
<span>
|
|
|
|
|
<button
|
|
|
|
|
class="ghost"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.calendar.todayButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={calendarPageViewModel.showToday}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">today</span>
|
|
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
<span>
|
|
|
|
|
<button
|
|
|
|
|
class="ghost"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.calendar.previousMonthButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={calendarPageViewModel.showPreviousMonth}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">arrow_back</span>
|
|
|
|
|
</button>
|
|
|
|
|
<span class="input-wrapper">
|
|
|
|
|
<input
|
|
|
|
|
class="year-input"
|
|
|
|
|
type="number"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.calendar.yearInputAudioLabel
|
|
|
|
|
}
|
|
|
|
|
placeholder={
|
|
|
|
|
translations.chatPage.calendar.yearInputPlaceholder
|
|
|
|
|
}
|
|
|
|
|
bind:value={calendarPageViewModel.selectedYear}
|
|
|
|
|
></input>
|
|
|
|
|
<input
|
|
|
|
|
class="month-input"
|
|
|
|
|
type="number"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.calendar.monthInputAudioLabel
|
|
|
|
|
}
|
|
|
|
|
placeholder={
|
|
|
|
|
translations.chatPage.calendar.monthInputPlaceholder
|
|
|
|
|
}
|
|
|
|
|
bind:value={calendarPageViewModel.selectedMonth}
|
|
|
|
|
></input>
|
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
class="ghost"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.calendar.nextMonthButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={calendarPageViewModel.showNextMonth}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
<span>
|
|
|
|
|
<button
|
|
|
|
|
class="ghost"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.task.createTaskButtonAudioLabel
|
|
|
|
|
}
|
2024-07-26 06:56:34 +02:00
|
|
|
on:click={calendarPageViewModel.createEvent}
|
2024-07-26 03:14:55 +02:00
|
|
|
>
|
|
|
|
|
<span class="icon">add</span>
|
|
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="content" children:set={mainContent}></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-26 05:43:49 +02:00
|
|
|
<div
|
|
|
|
|
class="pane-wrapper side background"
|
|
|
|
|
set:color={calendarPageViewModel.chatViewModel.displayedColor}
|
|
|
|
|
>
|
|
|
|
|
<div class="pane">
|
|
|
|
|
<div class="content" children:set={sidePaneContent}></div>
|
|
|
|
|
</div>
|
2024-07-26 05:32:07 +02:00
|
|
|
</div>
|
2024-07-26 06:20:16 +02:00
|
|
|
|
|
|
|
|
<div children:set={taskSettingsModal}></div>
|
2024-07-26 03:14:55 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
2024-07-25 19:32:46 +02:00
|
|
|
}
|