diff options
-rw-r--r-- | src/client/documents/Documents.ts | 16 | ||||
-rw-r--r-- | src/client/views/Main.tsx | 4 | ||||
-rw-r--r-- | src/client/views/nodes/TaskBox.scss (renamed from src/client/views/nodes/TaskManagerTask.scss) | 0 | ||||
-rw-r--r-- | src/client/views/nodes/TaskBox.tsx (renamed from src/client/views/nodes/TaskManagerTask.tsx) | 57 | ||||
-rw-r--r-- | src/client/views/nodes/calendarBox/CalendarBox.tsx | 22 |
5 files changed, 46 insertions, 53 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 217967c52..a11f56143 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -526,16 +526,12 @@ export class DocumentOptions { ai_firefly_seed?: number; ai_firefly_prompt?: string; - // AARAV ADD DOC OPTIONS -- TASK MANAGER - - /** Task start date/time picker (metadata and default) */ - startTime?: DateInfo | DateField = new DateInfo('start date and time', /*filterable*/ false); - /** Task end date/time picker (metadata and default) */ - endTime?: DateInfo | DateField = new DateInfo('end date and time', /*filterable*/ false); - /** Treat this as an all-day task (metadata and default) */ - allDay?: BoolInfo | boolean = new BoolInfo('all-day task', /*filterable*/ false); - /** Whether the task is completed */ - completed?: BoolInfo | boolean = new BoolInfo('whether the task is completed', /*filterable*/ false); + // TASK MANAGER + $startTime?: DateInfo | DateField = new DateInfo('start date and time', /*filterable*/ false); + $endTime?: DateInfo | DateField = new DateInfo('end date and time', /*filterable*/ false); + $allDay?: BoolInfo | boolean = new BoolInfo('whether task is all-day or not', /*filterable*/ false); + $completed?: BoolInfo | boolean = new BoolInfo('whether the task is completed', /*filterable*/ false); + /** * JSON‐stringified slot configuration for ScrapbookBox */ diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index ecbef3497..17ed63b05 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -65,7 +65,7 @@ import { PresBox, PresSlideBox } from './nodes/trails'; import { FaceRecognitionHandler } from './search/FaceRecognitionHandler'; import { SearchBox } from './search/SearchBox'; import { StickerPalette } from './smartdraw/StickerPalette'; -import { TaskManagerTask } from './nodes/TaskManagerTask'; +import { TaskBox } from './nodes/TaskBox'; import { ScrapbookBox } from './nodes/scrapbook/ScrapbookBox'; dotenv.config(); @@ -121,7 +121,7 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0, message: 'cache' }; StickerPalette: StickerPalette, FormattedTextBox, DailyJournal, // AARAV - TaskManagerTask, // AARAV + TaskBox, // AARAV ImageBox, FontIconBox, LabelBox, diff --git a/src/client/views/nodes/TaskManagerTask.scss b/src/client/views/nodes/TaskBox.scss index 0fcc2f955..0fcc2f955 100644 --- a/src/client/views/nodes/TaskManagerTask.scss +++ b/src/client/views/nodes/TaskBox.scss diff --git a/src/client/views/nodes/TaskManagerTask.tsx b/src/client/views/nodes/TaskBox.tsx index 913c46bfb..dca01817f 100644 --- a/src/client/views/nodes/TaskManagerTask.tsx +++ b/src/client/views/nodes/TaskBox.tsx @@ -7,16 +7,16 @@ import { FieldView } from './FieldView'; import { DateField } from '../../../fields/DateField'; import { Doc } from '../../../fields/Doc'; -import './TaskManagerTask.scss'; +import './TaskBox.scss'; -interface TaskManagerProps { +interface TaskBoxProps { Document: Doc; } @observer -export class TaskManagerTask extends React.Component<TaskManagerProps> { +export class TaskBox extends React.Component<TaskBoxProps> { public static LayoutString(fieldStr: string) { - return FieldView.LayoutString(TaskManagerTask, fieldStr); + return FieldView.LayoutString(TaskBox, fieldStr); } @action @@ -31,11 +31,11 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { @action updateAllDay = (e: React.ChangeEvent<HTMLInputElement>) => { - this.props.Document.allDay = e.target.checked; + this.props.Document.$allDay = e.target.checked; if (e.target.checked) { - delete this.props.Document.startTime; - delete this.props.Document.endTime; + delete this.props.Document.$startTime; + delete this.props.Document.$endTime; } this.setTaskDateRange(); @@ -45,16 +45,16 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { updateStart = (e: React.ChangeEvent<HTMLInputElement>) => { const newStart = new Date(e.target.value); - this.props.Document.startTime = new DateField(newStart); + this.props.Document.$startTime = new DateField(newStart); - const endDate = this.props.Document.endTime instanceof DateField ? this.props.Document.endTime.date : undefined; + const endDate = this.props.Document.$endTime instanceof DateField ? this.props.Document.$endTime.date : undefined; if (endDate && newStart > endDate) { // Alert user alert('Start time cannot be after end time. End time has been adjusted.'); // Fix end time const adjustedEnd = new Date(newStart.getTime() + 60 * 60 * 1000); - this.props.Document.endTime = new DateField(adjustedEnd); + this.props.Document.$endTime = new DateField(adjustedEnd); } this.setTaskDateRange(); @@ -66,16 +66,16 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { updateEnd = (e: React.ChangeEvent<HTMLInputElement>) => { const newEnd = new Date(e.target.value); - this.props.Document.endTime = new DateField(newEnd); + this.props.Document.$endTime = new DateField(newEnd); - const startDate = this.props.Document.startTime instanceof DateField ? this.props.Document.startTime.date : undefined; + const startDate = this.props.Document.$startTime instanceof DateField ? this.props.Document.$startTime.date : undefined; if (startDate && newEnd < startDate) { // Alert user alert('End time cannot be before start time. Start time has been adjusted.'); // Fix start time const adjustedStart = new Date(newEnd.getTime() - 60 * 60 * 1000); - this.props.Document.startTime = new DateField(adjustedStart); + this.props.Document.$startTime = new DateField(adjustedStart); } this.setTaskDateRange(); @@ -88,34 +88,31 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { setTaskDateRange() { const doc = this.props.Document; - if (doc.allDay) { + if (doc.$allDay) { const range = typeof doc.date_range === 'string' ? doc.date_range.split('|') : []; const dateStr = range[0] ?? new Date().toISOString().split('T')[0]; // default to today doc.date_range = `${dateStr}|${dateStr}`; - doc.allDay = true; + doc.$allDay = true; } else { - const startField = doc.startTime; - const endField = doc.endTime; + const startField = doc.$startTime; + const endField = doc.$endTime; const startDate = startField instanceof DateField ? startField.date : null; const endDate = endField instanceof DateField ? endField.date : null; if (startDate && endDate && !isNaN(startDate.getTime()) && !isNaN(endDate.getTime())) { doc.date_range = `${startDate.toISOString()}|${endDate.toISOString()}`; - doc.allDay = false; + doc.$allDay = false; } } } - - - @action toggleComplete = (e: React.ChangeEvent<HTMLInputElement>) => { - this.props.Document.completed = e.target.checked; + this.props.Document.$completed = e.target.checked; }; - constructor(props: TaskManagerProps) { + constructor(props: TaskBoxProps) { super(props); makeObservable(this); } @@ -174,15 +171,15 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { const taskDesc = typeof doc.text === 'string' ? doc.text : ''; const taskTitle = typeof doc.title === 'string' ? doc.title : ''; - const allDay = !!doc.allDay; - const isCompleted = !!this.props.Document.completed; + const allDay = !!doc.$allDay; + const isCompleted = !!this.props.Document.$completed; - const startTime = doc.startTime instanceof DateField && doc.startTime.date instanceof Date - ? toLocalDateTimeString(doc.startTime.date) + const startTime = doc.$startTime instanceof DateField && doc.$startTime.date instanceof Date + ? toLocalDateTimeString(doc.$startTime.date) : ''; - const endTime = doc.endTime instanceof DateField && doc.endTime.date instanceof Date - ? toLocalDateTimeString(doc.endTime.date) + const endTime = doc.$endTime instanceof DateField && doc.$endTime.date instanceof Date + ? toLocalDateTimeString(doc.$endTime.date) : ''; @@ -283,7 +280,7 @@ export class TaskManagerTask extends React.Component<TaskManagerProps> { } Docs.Prototypes.TemplateMap.set(DocumentType.TASK, { - layout: { view: TaskManagerTask, dataField: 'text' }, + layout: { view: TaskBox, dataField: 'text' }, options: { acl: '', _height: 35, diff --git a/src/client/views/nodes/calendarBox/CalendarBox.tsx b/src/client/views/nodes/calendarBox/CalendarBox.tsx index ce58ac9fa..bebd86ac2 100644 --- a/src/client/views/nodes/calendarBox/CalendarBox.tsx +++ b/src/client/views/nodes/calendarBox/CalendarBox.tsx @@ -68,7 +68,7 @@ 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 isCompleted = BoolCast(doc.$completed); // AARAV ADD return { title: StrCast(doc.title), start, @@ -76,7 +76,7 @@ export class CalendarBox extends CollectionSubView() { groupId: doc[Id], startEditable: true, endEditable: true, - allDay: BoolCast(doc.allDay), + allDay: BoolCast(doc.$allDay), classNames: ['mother', isCompleted ? 'completed-task' : ''], // will determine the style editable: true, // subject to change in the future backgroundColor: this.eventToColor(doc), @@ -143,16 +143,16 @@ export class CalendarBox extends CollectionSubView() { doc.date_range = `${startDate.toISOString()}|${endDate.toISOString()}`; const allDayStatus = arg.event.allDay ?? false; - if (doc.allDay !== allDayStatus) { - doc.allDay = allDayStatus; + if (doc.$allDay !== allDayStatus) { + doc.$allDay = allDayStatus; } - if (doc.allDay) { - delete doc.startTime; - delete doc.endTime; + if (doc.$allDay) { + delete doc.$startTime; + delete doc.$endTime; } else { - doc.startTime = new DateField(startDate); - doc.endTime = new DateField(endDate); + doc.$startTime = new DateField(startDate); + doc.$endTime = new DateField(endDate); } }; @@ -206,7 +206,7 @@ export class CalendarBox extends CollectionSubView() { if (doc.type === 'task') { const checkButton = document.createElement('button'); - checkButton.innerText = doc.completed ? '✅' : '⬜'; + checkButton.innerText = doc.$completed ? '✅' : '⬜'; checkButton.style.position = 'absolute'; checkButton.style.right = '5px'; checkButton.style.top = '50%'; @@ -221,7 +221,7 @@ export class CalendarBox extends CollectionSubView() { checkButton.onclick = ev => { ev.stopPropagation(); - doc.completed = !doc.completed; + doc.$completed = !doc.$completed; this._calendar?.refetchEvents(); }; |