diff options
| author | bobzel <zzzman@gmail.com> | 2025-06-02 18:58:18 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-06-02 18:58:18 -0400 |
| commit | 57e1862e58e89a505547d817123c04079854814f (patch) | |
| tree | bb964f7c03d8911f69c6823eac443d7159a12309 /src/client/views/nodes/calendarBox/CalendarBox.tsx | |
| parent | a7afce10c47724156510a8665e7e1841566082e8 (diff) | |
changed field names for tasks to start with task_. changed calendar date and range to start with _calendar
Diffstat (limited to 'src/client/views/nodes/calendarBox/CalendarBox.tsx')
| -rw-r--r-- | src/client/views/nodes/calendarBox/CalendarBox.tsx | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/client/views/nodes/calendarBox/CalendarBox.tsx b/src/client/views/nodes/calendarBox/CalendarBox.tsx index f21eec604..835d58337 100644 --- a/src/client/views/nodes/calendarBox/CalendarBox.tsx +++ b/src/client/views/nodes/calendarBox/CalendarBox.tsx @@ -46,6 +46,7 @@ export class CalendarBox extends CollectionSubView() { } componentDidMount(): void { + this.Document.$calendar = ''; // needed only to make the keyvalue view look nice. this._props.setContentViewBox?.(this); this._eventsDisposer = reaction( () => ({ events: this.calendarEvents }), @@ -73,8 +74,8 @@ export class CalendarBox extends CollectionSubView() { @computed get calendarEvents(): EventSourceInput | undefined { return this.childDocs.map(doc => { - const { start, end } = dateRangeStrToDates(StrCast(doc.date_range)); - const isCompleted = BoolCast(doc.$completed); // AARAV ADD + const { start, end } = dateRangeStrToDates(StrCast(doc.$task_dateRange)); + const isCompleted = BoolCast(doc.$task_completed); // AARAV ADD return { title: StrCast(doc.title), start, @@ -82,7 +83,7 @@ export class CalendarBox extends CollectionSubView() { groupId: doc[Id], startEditable: true, endEditable: true, - allDay: BoolCast(doc.$allDay), + allDay: BoolCast(doc.$task_allDay), classNames: ['mother', isCompleted ? 'completed-task' : ''], // will determine the style editable: true, // subject to change in the future backgroundColor: this.eventToColor(doc), @@ -96,10 +97,10 @@ export class CalendarBox extends CollectionSubView() { } @computed get dateRangeStrDates() { - return dateRangeStrToDates(StrCast(this.Document.date_range)); + return dateRangeStrToDates(StrCast(this.Document._calendar_dateRange)); } get dateSelect() { - return dateRangeStrToDates(StrCast(this.Document.date)); + return dateRangeStrToDates(StrCast(this.Document._calendar_date)); } // Choose a calendar view based on the date range @@ -124,7 +125,7 @@ export class CalendarBox extends CollectionSubView() { if (!super.onInternalDrop(e, de)) return false; de.complete.docDragData?.droppedDocuments.forEach(doc => { const today = new Date().toISOString(); - if (!doc.date_range) doc.$date_range = `${today}|${today}`; + if (!doc.$task_dateRange) doc.$task_dateRange = `${today}|${today}`; }); return true; }; @@ -136,7 +137,7 @@ export class CalendarBox extends CollectionSubView() { handleEventDrop = undoable((arg: EventDropArg | EventResizeDoneArg) => { const doc = DocServer.GetCachedRefField(arg.event._def.groupId ?? ''); - // doc && arg.event.start && (doc.date_range = arg.event.start?.toString() + '|' + (arg.event.end ?? arg.event.start).toString()); + // doc && arg.event.start && (doc.$task_dateRange = arg.event.start?.toString() + '|' + (arg.event.end ?? arg.event.start).toString()); if (!doc || !arg.event.start) return; // get the new start and end dates @@ -144,19 +145,19 @@ export class CalendarBox extends CollectionSubView() { const endDate = new Date(arg.event.end ?? arg.event.start); // update date range, time range, and all day status - doc.date_range = `${startDate.toISOString()}|${endDate.toISOString()}`; + doc.$task_dateRange = `${startDate.toISOString()}|${endDate.toISOString()}`; const allDayStatus = arg.event.allDay ?? false; - if (doc.$allDay !== allDayStatus) { - doc.$allDay = allDayStatus; + if (doc.$task_allDay !== allDayStatus) { + doc.$task_allDay = allDayStatus; } - if (doc.$allDay) { - delete doc.$startTime; - delete doc.$endTime; + if (doc.$task_allDay) { + delete doc.$task_startTime; + delete doc.$task_endTime; } else { - doc.$startTime = new DateField(startDate); - doc.$endTime = new DateField(endDate); + doc.$task_startTime = new DateField(startDate); + doc.task_endTime = new DateField(endDate); } }, 'change event date'); @@ -220,7 +221,7 @@ export class CalendarBox extends CollectionSubView() { displayEventEnd={false} plugins={[multiMonthPlugin, dayGridPlugin, timeGrid, interactionPlugin]} aspectRatio={this._props.PanelWidth() / this._props.PanelHeight()} - weekends={false} + weekends={true} events={this.calendarEvents} eventClick={this.handleEventClick} eventDrop={this.handleEventDrop} @@ -229,7 +230,7 @@ export class CalendarBox extends CollectionSubView() { select={(info: DateSelectArg) => { const start = dateRangeStrToDates(info.startStr).start.toISOString(); const end = info.allDay ? start : dateRangeStrToDates(info.endStr).start.toISOString(); - this.dataDoc.date = start + '|' + end; + this.Document._calendar_date = start + '|' + end; }} // eventContent={() => { // return null; @@ -238,9 +239,9 @@ export class CalendarBox extends CollectionSubView() { const doc = DocServer.GetCachedRefField(arg.event._def.groupId ?? ''); if (!doc) return; - if (doc.type === 'task') { + if (doc.type === DocumentType.TASK) { const checkButton = document.createElement('button'); - checkButton.innerText = doc.$completed ? '✅' : '⬜'; + checkButton.innerText = doc.$task_completed ? '✅' : '⬜'; checkButton.style.position = 'absolute'; checkButton.style.right = '5px'; checkButton.style.top = '50%'; @@ -255,7 +256,7 @@ export class CalendarBox extends CollectionSubView() { checkButton.onclick = ev => { ev.stopPropagation(); - doc.$completed = !doc.$completed; + doc.$task_completed = !doc.$task_completed; this._calendar?.refetchEvents(); }; |
