Files
CT/src/View/ChatPages/calendarPage.tsx
T

213 lines
8.4 KiB
TypeScript
Raw Normal View History

import * as React from "bloatless-react";
2026-04-18 11:55:01 +00:00
import "./calendarPage.css";
import { ViewController } from "../viewController";
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";
2026-04-10 18:17:16 +00:00
import { PlaceholderView } from "../Components/placeholderView";
2026-04-18 11:55:01 +00:00
import { MonthGrid } from "../Components/monthGrid";
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
import CoreViewModel from "../../ViewModel/Global/coreViewModel";
export function CalendarPage(
coreViewModel: CoreViewModel,
calendarPageViewModel: CalendarPageViewModel,
) {
2026-04-01 08:29:39 +00:00
calendarPageViewModel.loadData();
2026-04-01 08:29:39 +00:00
const mainContent = React.createProxyState(
[calendarPageViewModel.monthGrid],
() => {
const monthGrid = calendarPageViewModel.monthGrid.value;
2024-07-26 07:07:07 +02:00
2026-04-01 08:29:39 +00:00
if (monthGrid == undefined) {
return <div></div>;
} else {
function drop(date: string) {
calendarPageViewModel.handleDrop(
monthGrid!.year.toString(),
monthGrid!.month.toString(),
date,
);
}
2024-07-26 07:07:07 +02:00
2026-04-01 08:29:39 +00:00
return MonthGrid(
coreViewModel,
2026-04-01 08:29:39 +00:00
monthGrid,
calendarPageViewModel.selectedDate,
drop,
);
}
},
);
2024-07-26 03:14:55 +02:00
2026-04-01 08:29:39 +00:00
const sidePaneContentWrapper = React.createProxyState(
[
calendarPageViewModel.selectedYear,
calendarPageViewModel.selectedMonth,
calendarPageViewModel.selectedDate,
],
() => {
const listState = calendarPageViewModel.getEventsForDate();
2024-07-26 05:43:49 +02:00
2026-04-01 08:29:39 +00:00
if (listState == undefined) {
return <div></div>;
} else {
const sidePaneContent = React.createProxyState(
[listState],
() => {
if (listState.value.size == 0) {
2026-04-10 18:17:16 +00:00
return PlaceholderView(
coreViewModel.translations.chatPage.calendar
.noEvents,
2026-04-01 08:29:39 +00:00
);
} else {
return (
<div
class="flex-column gap slide-up padding-bottom"
children:append={[
listState,
TaskViewModelToEntry,
]}
></div>
);
}
},
);
2026-04-01 08:29:39 +00:00
return (
<div
class="width-100 height-100"
children:set={sidePaneContent}
></div>
);
}
},
);
2024-07-26 05:43:49 +02:00
2026-04-01 08:29:39 +00:00
const taskSettingsModal = React.createProxyState(
[calendarPageViewModel.selectedTaskViewModel],
() => {
if (
calendarPageViewModel.selectedTaskViewModel.value == undefined
) {
return <div></div>;
} else {
2026-04-15 12:47:10 +00:00
ViewController.setFocusWithDelay();
2026-04-01 08:53:50 +00:00
2026-04-01 08:29:39 +00:00
return TaskSettingsModal(
coreViewModel,
2026-04-01 08:29:39 +00:00
calendarPageViewModel.selectedTaskViewModel.value,
);
}
},
);
2024-07-26 06:20:16 +02:00
2026-04-01 08:29:39 +00:00
return (
<div id="calendar-page">
<div class="pane-wrapper grid-pane-wrapper">
<div class="pane">
<div class="toolbar">
<span>
<button
class="ghost"
aria-label={
coreViewModel.translations.chatPage.calendar
2026-04-01 08:29:39 +00:00
.todayButtonAudioLabel
}
on:click={calendarPageViewModel.showToday}
>
<span class="icon">today</span>
</button>
</span>
<span>
<button
class="ghost"
aria-label={
coreViewModel.translations.chatPage.calendar
2026-04-01 08:29:39 +00:00
.previousMonthButtonAudioLabel
}
on:click={
calendarPageViewModel.showPreviousMonth
}
>
<span class="icon">arrow_back</span>
</button>
<span class="input-wrapper">
<input
class="year-input"
type="number"
aria-label={
coreViewModel.translations.chatPage
.calendar.yearInputAudioLabel
2026-04-01 08:29:39 +00:00
}
placeholder={
coreViewModel.translations.chatPage
.calendar.yearInputPlaceholder
2026-04-01 08:29:39 +00:00
}
bind:value={
calendarPageViewModel.selectedYear
}
></input>
<input
class="month-input"
type="number"
aria-label={
coreViewModel.translations.chatPage
.calendar.monthInputAudioLabel
2026-04-01 08:29:39 +00:00
}
placeholder={
coreViewModel.translations.chatPage
.calendar.monthInputPlaceholder
2026-04-01 08:29:39 +00:00
}
bind:value={
calendarPageViewModel.selectedMonth
}
></input>
</span>
<button
class="ghost"
aria-label={
coreViewModel.translations.chatPage.calendar
2026-04-01 08:29:39 +00:00
.nextMonthButtonAudioLabel
}
on:click={calendarPageViewModel.showNextMonth}
>
<span class="icon">arrow_forward</span>
</button>
</span>
<span>
<button
class="ghost"
aria-label={
coreViewModel.translations.chatPage.task
2026-04-01 08:29:39 +00:00
.createTaskButtonAudioLabel
}
on:click={calendarPageViewModel.createEvent}
>
<span class="icon">add</span>
</button>
</span>
</div>
<div
class="content padding-0"
children:set={mainContent}
></div>
</div>
</div>
<div
class="pane-wrapper side background"
set:color={calendarPageViewModel.chatViewModel.displayedColor}
>
<div class="pane">
<div
class="content"
children:set={sidePaneContentWrapper}
></div>
</div>
</div>
2024-07-26 06:20:16 +02:00
2026-04-01 08:29:39 +00:00
<div children:set={taskSettingsModal}></div>
</div>
);
}