Victor Wiebe 5791ee5ec2 Phase 0: rename plugin to GTD Calendar; fix week view grouping bug
- New manifest id com.victorwiebe.joplin.plugin.gtd-calendar (coexists with upstream)
- Version reset to 0.1.0
- Fix Calendar/index.ts importing MonthGrouping as WeekGrouping (upstream bug:
  week view silently grouped by month)
2026-06-12 17:47:50 -04:00

52 lines
1.4 KiB
TypeScript

import { GroupTypes } from "../types";
import Events from "./Events/";
import DayGrouping from "./Group/Day/DayGrouping";
import MonthGrouping from "./Group/Month/MonthGrouping";
import WeekGrouping from "./Group/Week/WeekGrouping";
import DayRenderer from "./Group/Day/Renderer";
import MonthRenderer from "./Group/Month/Renderer";
import WeekRenderer from "./Group/Week/Renderer";
export default class Calendar {
public readonly jsonContent: object;
public readonly groupType: GroupTypes;
public readonly events: Events;
constructor(json: object) {
this.jsonContent = json;
this.groupType = this.getGroupType(json);
this.events = new Events(json["events"]);
}
private getGroupType(json: object): GroupTypes {
if (!json["group"]) {
return GroupTypes.Day;
}
const groupType = json["group"].charAt(0).toUpperCase();
if (!Object.values(GroupTypes).includes(groupType)) {
return GroupTypes.Day;
}
return groupType;
}
render(): HTMLDivElement {
switch (this.groupType) {
case GroupTypes.Day:
return new DayRenderer(
new DayGrouping(this.events.sortedEvents)
).render();
case GroupTypes.Week:
return new WeekRenderer(
new WeekGrouping(this.events.sortedEvents)
).render();
case GroupTypes.Month:
return new MonthRenderer(
new MonthGrouping(this.events.sortedEvents)
).render();
}
}
}