Skip to content

Commit 2a7d245

Browse files
committed
feat(bases): enhance metadata mapping and frontmatter updates
- Add comprehensive property mapping system with metadata mappings support - Implement bidirectional status mapping (symbol to metadata value) - Add direct frontmatter update capability for Bases entry tasks - Include default status mappings as fallback for common values - Deprecate calendar DayView and MonthView components - Improve property key resolution with custom metadata mappings - Add debug logging for status conversion troubleshooting
1 parent d385eb9 commit 2a7d245

File tree

3 files changed

+475
-68
lines changed

3 files changed

+475
-68
lines changed

src/components/features/calendar/views/day-view.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
/**
2+
* @deprecated This file is deprecated. Use @taskgenius/calendar's DayView instead.
3+
*/
14
import { App, Component, moment } from "obsidian";
2-
import { CalendarEvent } from '@/components/features/calendar/index';
5+
import { CalendarEvent } from "@/components/features/calendar/index";
36
import { renderCalendarEvent } from "../rendering/event-renderer";
47
import { CalendarViewComponent, CalendarViewOptions } from "./base-view";
58
import TaskProgressBarPlugin from "@/index";
69

10+
/**
11+
* @deprecated Use @taskgenius/calendar's DayView instead.
12+
*/
713
export class DayView extends CalendarViewComponent {
814
private currentDate: moment.Moment;
915
private app: App;
@@ -15,7 +21,7 @@ export class DayView extends CalendarViewComponent {
1521
containerEl: HTMLElement,
1622
currentDate: moment.Moment,
1723
events: CalendarEvent[],
18-
options: CalendarViewOptions = {}
24+
options: CalendarViewOptions = {},
1925
) {
2026
super(plugin, app, containerEl, events, options);
2127
this.app = app;
@@ -54,10 +60,10 @@ export class DayView extends CalendarViewComponent {
5460

5561
// 2. Render Timeline Section (Combined List)
5662
const timelineSection = this.containerEl.createDiv(
57-
"calendar-timeline-section" // Keep this class for general styling? Or rename?
63+
"calendar-timeline-section", // Keep this class for general styling? Or rename?
5864
);
5965
const timelineEventsContainer = timelineSection.createDiv(
60-
"calendar-timeline-events-container" // Renamed? maybe calendar-day-events-list
66+
"calendar-timeline-events-container", // Renamed? maybe calendar-day-events-list
6167
);
6268

6369
// 3. Render events in a simple list

src/components/features/calendar/views/month-view.ts

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/**
2+
* @deprecated This file is deprecated. Use @taskgenius/calendar's DayView instead.
3+
*/
14
import { App, Component, debounce, moment } from "obsidian";
2-
import { CalendarEvent } from '@/components/features/calendar/index';
5+
import { CalendarEvent } from "@/components/features/calendar/index";
36
import { renderCalendarEvent } from "../rendering/event-renderer"; // Import the new renderer
47
import {
58
CalendarSpecificConfig,
@@ -22,6 +25,7 @@ function parseDateString(dateStr: string): Date {
2225
}
2326

2427
/**
28+
* @deprecated This file is deprecated. Use @taskgenius/calendar's MonthView instead.
2529
* Renders the month view grid as a component.
2630
*/
2731
export class MonthView extends CalendarViewComponent {
@@ -39,7 +43,7 @@ export class MonthView extends CalendarViewComponent {
3943
currentDate: moment.Moment,
4044
events: CalendarEvent[],
4145
options: CalendarViewOptions, // Use the base options type
42-
overrideConfig?: Partial<CalendarSpecificConfig>
46+
overrideConfig?: Partial<CalendarSpecificConfig>,
4347
) {
4448
super(plugin, app, containerEl, events, options); // Call base constructor
4549
this.app = app; // Still store app if needed directly
@@ -51,10 +55,14 @@ export class MonthView extends CalendarViewComponent {
5155
render(): void {
5256
// Get view settings, prefer override values when provided
5357
const viewConfig = this.plugin.settings.viewConfiguration.find(
54-
(v) => v.id === this.currentViewId
58+
(v) => v.id === this.currentViewId,
5559
)?.specificConfig as CalendarSpecificConfig;
56-
const firstDayOfWeekSetting = this.overrideConfig?.firstDayOfWeek ?? viewConfig?.firstDayOfWeek;
57-
const hideWeekends = (this.overrideConfig?.hideWeekends ?? viewConfig?.hideWeekends) ?? false;
60+
const firstDayOfWeekSetting =
61+
this.overrideConfig?.firstDayOfWeek ?? viewConfig?.firstDayOfWeek;
62+
const hideWeekends =
63+
this.overrideConfig?.hideWeekends ??
64+
viewConfig?.hideWeekends ??
65+
false;
5866
// Default to Sunday (0) if the setting is undefined, following 0=Sun, 1=Mon, ..., 6=Sat
5967
const effectiveFirstDay =
6068
firstDayOfWeekSetting === undefined ? 0 : firstDayOfWeekSetting;
@@ -122,10 +130,10 @@ export class MonthView extends CalendarViewComponent {
122130
// Filter out weekends if hideWeekends is enabled
123131
const filteredWeekdays = hideWeekends
124132
? rotatedWeekdays.filter((_, index) => {
125-
// Calculate the actual day of week for this header position
126-
const dayOfWeek = (effectiveFirstDay + index) % 7;
127-
return dayOfWeek !== 0 && dayOfWeek !== 6; // Exclude Sunday (0) and Saturday (6)
128-
})
133+
// Calculate the actual day of week for this header position
134+
const dayOfWeek = (effectiveFirstDay + index) % 7;
135+
return dayOfWeek !== 0 && dayOfWeek !== 6; // Exclude Sunday (0) and Saturday (6)
136+
})
129137
: rotatedWeekdays;
130138

131139
filteredWeekdays.forEach((day) => {
@@ -139,7 +147,8 @@ export class MonthView extends CalendarViewComponent {
139147
let currentDayIter = gridStart.clone();
140148

141149
while (currentDayIter.isSameOrBefore(gridEnd, "day")) {
142-
const isWeekend = currentDayIter.day() === 0 || currentDayIter.day() === 6; // Sunday or Saturday
150+
const isWeekend =
151+
currentDayIter.day() === 0 || currentDayIter.day() === 6; // Sunday or Saturday
143152

144153
// Skip weekend days if hideWeekends is enabled
145154
if (hideWeekends && isWeekend) {
@@ -205,7 +214,7 @@ export class MonthView extends CalendarViewComponent {
205214
const targetCell = dayCells[dateStr];
206215
if (targetCell) {
207216
const eventsContainer = targetCell.querySelector(
208-
".calendar-events-container"
217+
".calendar-events-container",
209218
);
210219
if (eventsContainer) {
211220
// Render the event using the existing renderer
@@ -237,10 +246,10 @@ export class MonthView extends CalendarViewComponent {
237246

238247
if (badgeEvents.length > 0) {
239248
const headerEl = cell.querySelector(
240-
".calendar-day-header"
249+
".calendar-day-header",
241250
) as HTMLElement;
242251
const badgesContainer = headerEl.createDiv(
243-
"calendar-badges-container"
252+
"calendar-badges-container",
244253
);
245254
if (badgesContainer) {
246255
badgeEvents.forEach((badgeEvent) => {
@@ -262,10 +271,10 @@ export class MonthView extends CalendarViewComponent {
262271

263272
console.log(
264273
`Rendered Month View component from ${gridStart.format(
265-
"YYYY-MM-DD"
274+
"YYYY-MM-DD",
266275
)} to ${gridEnd.format(
267-
"YYYY-MM-DD"
268-
)} (First day: ${effectiveFirstDay})`
276+
"YYYY-MM-DD",
277+
)} (First day: ${effectiveFirstDay})`,
269278
);
270279

271280
this.registerDomEvent(gridContainer, "click", (ev) => {
@@ -345,7 +354,7 @@ export class MonthView extends CalendarViewComponent {
345354
// Initialize sortable for each day's events container
346355
Object.entries(dayCells).forEach(([dateStr, dayCell]) => {
347356
const eventsContainer = dayCell.querySelector(
348-
".calendar-events-container"
357+
".calendar-events-container",
349358
) as HTMLElement;
350359
if (eventsContainer) {
351360
const sortableInstance = Sortable.create(eventsContainer, {
@@ -367,7 +376,7 @@ export class MonthView extends CalendarViewComponent {
367376
*/
368377
private async handleDragEnd(
369378
event: Sortable.SortableEvent,
370-
originalDateStr: string
379+
originalDateStr: string,
371380
): Promise<void> {
372381
const eventEl = event.item;
373382
const eventId = eventEl.dataset.eventId;
@@ -376,7 +385,7 @@ export class MonthView extends CalendarViewComponent {
376385

377386
if (!eventId || !targetDateCell) {
378387
console.warn(
379-
"Could not determine event ID or target date for drag operation"
388+
"Could not determine event ID or target date for drag operation",
380389
);
381390
return;
382391
}
@@ -397,7 +406,7 @@ export class MonthView extends CalendarViewComponent {
397406
try {
398407
await this.updateTaskDate(calendarEvent, targetDateStr);
399408
console.log(
400-
`Task ${eventId} moved from ${originalDateStr} to ${targetDateStr}`
409+
`Task ${eventId} moved from ${originalDateStr} to ${targetDateStr}`,
401410
);
402411
} catch (error) {
403412
console.error("Failed to update task date:", error);
@@ -411,7 +420,7 @@ export class MonthView extends CalendarViewComponent {
411420
*/
412421
private async updateTaskDate(
413422
calendarEvent: CalendarEvent,
414-
targetDateStr: string
423+
targetDateStr: string,
415424
): Promise<void> {
416425
// Use optimized date parsing for better performance
417426
const targetDate = parseDateString(targetDateStr).getTime();
@@ -440,7 +449,7 @@ export class MonthView extends CalendarViewComponent {
440449
taskId: calendarEvent.id,
441450
updates: updatedTask,
442451
});
443-
452+
444453
if (!result.success) {
445454
throw new Error(`Failed to update task: ${result.error}`);
446455
}

0 commit comments

Comments
 (0)