From 57e1862e58e89a505547d817123c04079854814f Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 2 Jun 2025 18:58:18 -0400 Subject: changed field names for tasks to start with task_. changed calendar date and range to start with _calendar --- src/client/documents/Documents.ts | 18 +- src/client/util/CalendarManager.tsx | 2 +- src/client/views/nodes/TaskBox.tsx | 197 ++++++++------------- src/client/views/nodes/calendarBox/CalendarBox.tsx | 41 ++--- .../views/nodes/formattedText/DailyJournal.tsx | 70 ++------ 5 files changed, 124 insertions(+), 204 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 0b6385466..4ad9c9bd8 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -11,7 +11,7 @@ import { List } from '../../fields/List'; import { RichTextField } from '../../fields/RichTextField'; import { SchemaHeaderField } from '../../fields/SchemaHeaderField'; import { ComputedField, ScriptField } from '../../fields/ScriptField'; -import { DocCast, ScriptCast, StrCast } from '../../fields/Types'; +import { ScriptCast, StrCast } from '../../fields/Types'; import { AudioField, CsvField, ImageField, PdfField, VideoField, WebField } from '../../fields/URLField'; import { SharingPermissions } from '../../fields/util'; import { PointData } from '../../pen-gestures/GestureTypes'; @@ -182,8 +182,6 @@ export class DocumentOptions { identifier?: STRt = new StrInfo('documentIcon displayed for each doc as "d[x]"', false); _rotation?: NUMt = new NumInfo('Amount of rotation on a document in degrees', false); - date_range?: STRt = new StrInfo('date range for calendar', false); - chat?: STRt = new StrInfo('fields related to chatBox', false); chat_history?: STRt = new StrInfo('chat history for chatbox', false); chat_thread_id?: STRt = new StrInfo('thread id for chatbox', false); @@ -525,10 +523,14 @@ export class DocumentOptions { ai_generatedDocs?: List; // list of documents generated by GAI engine // 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); + $task_dateRange?: STRt = new StrInfo('date range for calendar', false); + $task_startTime?: DateInfo | DateField = new DateInfo('start date and time', /*filterable*/ false); + $task_endTime?: DateInfo | DateField = new DateInfo('end date and time', /*filterable*/ false); + $task_allDay?: BoolInfo | boolean = new BoolInfo('whether task is all-day or not', /*filterable*/ false); + $task_completed?: BoolInfo | boolean = new BoolInfo('whether the task is completed', /*filterable*/ false); + + _calendar_date?: DateInfo | DateField = new DateInfo('current selected date of a calendar', /*filterable*/ false); + _calendar_dateRange?: STRt = new StrInfo('date range shown on a calendar', false); /** * JSON‐stringified slot configuration for ScrapbookBox @@ -978,6 +980,7 @@ export namespace Docs { ); } + // eslint-disable-next-line @typescript-eslint/no-unused-vars export function TaskDocument(text = '', options: DocumentOptions = {}, fieldKey = 'text') { return InstanceFromProto( Prototypes.get(DocumentType.TASK), @@ -1070,6 +1073,7 @@ export namespace Docs { _layout_nativeDimEditable: true, _layout_reflowHorizontal: true, _layout_reflowVertical: true, + calendar: '', ...options, _type_collection: CollectionViewType.Calendar, }); diff --git a/src/client/util/CalendarManager.tsx b/src/client/util/CalendarManager.tsx index b50e39c02..a8460ed4b 100644 --- a/src/client/util/CalendarManager.tsx +++ b/src/client/util/CalendarManager.tsx @@ -156,7 +156,7 @@ export class CalendarManager extends ObservableReactComponent { const subDocEmbedding = Doc.MakeEmbedding(targetDoc); // embedding console.log('subdoc embedding', subDocEmbedding); subDocEmbedding.embedContainer = calendar; // set embed container - subDocEmbedding.date_range = `${startDateStr}|${endDateStr}`; // set subDoc date range + subDocEmbedding.task_dateRange = `${startDateStr}|${endDateStr}`; // set subDoc date range Doc.AddDocToList(calendar, 'data', subDocEmbedding); // add embedded subDoc to calendar diff --git a/src/client/views/nodes/TaskBox.tsx b/src/client/views/nodes/TaskBox.tsx index ff1c70b90..9d59746f8 100644 --- a/src/client/views/nodes/TaskBox.tsx +++ b/src/client/views/nodes/TaskBox.tsx @@ -1,4 +1,4 @@ -import { action, observable, makeObservable, IReactionDisposer, reaction } from 'mobx'; +import { action, makeObservable, IReactionDisposer, reaction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { Docs } from '../../documents/Documents'; @@ -22,11 +22,10 @@ interface TaskBoxProps { */ @observer export class TaskBox extends React.Component { - /** - * Method to reuturn the - * @param fieldStr - * @returns + * Method to reuturn the + * @param fieldStr + * @returns */ public static LayoutString(fieldStr: string) { return FieldView.LayoutString(TaskBox, fieldStr); @@ -57,11 +56,11 @@ export class TaskBox extends React.Component { */ @action updateAllDay = (e: React.ChangeEvent) => { - this.props.Document.$allDay = e.target.checked; + this.props.Document.$task_allDay = e.target.checked; if (e.target.checked) { - delete this.props.Document.$startTime; - delete this.props.Document.$endTime; + delete this.props.Document.$task_startTime; + delete this.props.Document.$task_endTime; } this.setTaskDateRange(); @@ -75,16 +74,16 @@ export class TaskBox extends React.Component { updateStart = (e: React.ChangeEvent) => { const newStart = new Date(e.target.value); - this.props.Document.$startTime = new DateField(newStart); + this.props.Document.$task_startTime = new DateField(newStart); - const endDate = this.props.Document.$endTime instanceof DateField ? this.props.Document.$endTime.date : undefined; + const endDate = this.props.Document.$task_endTime instanceof DateField ? this.props.Document.$task_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.$task_endTime = new DateField(adjustedEnd); } this.setTaskDateRange(); @@ -98,16 +97,16 @@ export class TaskBox extends React.Component { updateEnd = (e: React.ChangeEvent) => { const newEnd = new Date(e.target.value); - this.props.Document.$endTime = new DateField(newEnd); + this.props.Document.$task_endTime = new DateField(newEnd); - const startDate = this.props.Document.$startTime instanceof DateField ? this.props.Document.$startTime.date : undefined; + const startDate = this.props.Document.$task_startTime instanceof DateField ? this.props.Document.$task_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.$task_startTime = new DateField(adjustedStart); } this.setTaskDateRange(); @@ -120,21 +119,21 @@ export class TaskBox extends React.Component { setTaskDateRange() { const doc = this.props.Document; - if (doc.$allDay) { - const range = typeof doc.date_range === 'string' ? doc.date_range.split('|') : []; + if (doc.$task_allDay) { + const range = typeof doc.$task_dateRange === 'string' ? doc.$task_dateRange.split('|') : []; const dateStr = range[0] ?? new Date().toISOString().split('T')[0]; // default to today - doc.date_range = `${dateStr}|${dateStr}`; - doc.$allDay = true; + doc.$task_dateRange = `${dateStr}|${dateStr}`; + doc.$task_allDay = true; } else { - const startField = doc.$startTime; - const endField = doc.$endTime; + const startField = doc.$task_startTime; + const endField = doc.$task_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.$task_dateRange = `${startDate.toISOString()}|${endDate.toISOString()}`; + doc.$task_allDay = false; } } } @@ -146,12 +145,12 @@ export class TaskBox extends React.Component { @action toggleComplete = (e: React.ChangeEvent) => { - this.props.Document.$completed = e.target.checked; + this.props.Document.$task_completed = e.target.checked; }; /** * Constructor for the task box - * @param props - props containing the document reference + * @param props - props containing the document reference */ constructor(props: TaskBoxProps) { @@ -193,134 +192,81 @@ export class TaskBox extends React.Component { } /** - * Method to render the task box + * Method to render the task box * @returns - HTML with taskbox components */ render() { - function toLocalDateTimeString(date: Date): string { const pad = (n: number) => n.toString().padStart(2, '0'); - return ( - date.getFullYear() + - '-' + - pad(date.getMonth() + 1) + - '-' + - pad(date.getDate()) + - 'T' + - pad(date.getHours()) + - ':' + - pad(date.getMinutes()) - ); + return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate()) + 'T' + pad(date.getHours()) + ':' + pad(date.getMinutes()); } - + const doc = this.props.Document; 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 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 allDay = !!doc.$task_allDay; + const isCompleted = !!this.props.Document.$task_completed; + const startTime = doc.$task_startTime instanceof DateField && doc.$task_startTime.date instanceof Date ? toLocalDateTimeString(doc.$task_startTime.date) : ''; + const endTime = doc.$task_endTime instanceof DateField && doc.$task_endTime.date instanceof Date ? toLocalDateTimeString(doc.$task_endTime.date) : ''; return (
- - -