diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/DocumentTypes.ts | 3 | ||||
-rw-r--r-- | src/client/documents/Documents.ts | 70 | ||||
-rw-r--r-- | src/client/util/CurrentUserUtils.ts | 2 | ||||
-rw-r--r-- | src/client/views/Main.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/TaskManagerTask.tsx | 96 |
5 files changed, 132 insertions, 41 deletions
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts index 5c6559836..83faf6ed1 100644 --- a/src/client/documents/DocumentTypes.ts +++ b/src/client/documents/DocumentTypes.ts @@ -44,7 +44,8 @@ export enum DocumentType { SCRIPTDB = 'scriptdb', // database of scripts GROUPDB = 'groupdb', // database of groups - JOURNAL = 'journal', // AARAV ADD + JOURNAL = 'journal', // AARAV ADD JOURNAL + TASK = 'task', // AARAV ADD TASK } export enum CollectionViewType { // general collections diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index bf9cc5bd4..1b0c422da 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 { ScriptCast, StrCast } from '../../fields/Types'; +import { DocCast, 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'; @@ -525,6 +525,17 @@ export class DocumentOptions { ai?: string; // to mark items as ai generated 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); } export const DocOptions = new DocumentOptions(); @@ -586,6 +597,17 @@ export namespace Docs { }, }, ], + + [ + DocumentType.TASK, + { + layout: { view: EmptyBox, dataField: 'text' }, + options: { + title: 'Task', + acl_Guest: SharingPermissions.View, + }, + }, + ], // AARAV ADD // ]); @@ -922,31 +944,6 @@ export namespace Docs { // AARAV ADD // export function DailyJournalDocument(text: string | RichTextField, options: DocumentOptions = {}, fieldKey: string = 'text') { - // const getFormattedDate = () => { - // const date = new Date().toLocaleDateString(undefined, { - // weekday: 'long', - // year: 'numeric', - // month: 'long', - // day: 'numeric', - // }); - // return date; - // }; - - // const getDailyText = () => { - // const placeholderText = 'Start writing here...'; - // const dateText = `${getFormattedDate()}`; - - // return RichTextField.textToRtfFormat( - // [ - // { text: 'Journal Entry:', styles: { bold: true, color: 'black', fontSize: 20 } }, - // { text: dateText, styles: { italic: true, color: 'gray', fontSize: 15 } }, - // { text: placeholderText, styles: { fontSize: 14, color: 'gray' } }, - // ], - // undefined, - // placeholderText.length - // ); - // }; - return InstanceFromProto( Prototypes.get(DocumentType.JOURNAL), '', @@ -959,24 +956,17 @@ export namespace Docs { ); } - // AARAV ADD // - - export function LinkDocument(source: Doc, target: Doc, options: DocumentOptions = {}, id?: string) { - const linkDoc = InstanceFromProto( - Prototypes.get(DocumentType.LINK), - undefined, + export function TaskDocument(text = '', options: DocumentOptions = {}, fieldKey = 'text') { + return InstanceFromProto( + Prototypes.get(DocumentType.TASK), + '', { - link_anchor_1: source, - link_anchor_2: target, + title: '', ...options, }, - id, - 'link' + undefined, + fieldKey ); - - Doc.AddLink(linkDoc); - - return linkDoc; } export function InkDocument(points: PointData[], options: DocumentOptions = {}, strokeWidth: number, color: string, strokeBezier: string, fillColor: string, arrowStart: string, arrowEnd: string, dash: string, isInkMask: boolean) { diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 99a67ebb2..121af72ed 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -407,6 +407,7 @@ pie title Minerals in my tap water {key: "DataViz", creator: opts => Docs.Create.DataVizDocument("", opts), opts: { _width: 300, _height: 300, }}, // AARAV ADD // {key: "DailyJournal",creator:opts => Docs.Create.DailyJournalDocument("", opts),opts: { _width: 300, _height: 300, }}, + {key: "Task", creator: opts => Docs.Create.TaskDocument("", opts), opts: { _width: 250, _height: 100, _layout_autoHeight: true, title: "Task", }}, {key: "Chat", creator: Docs.Create.ChatDocument, opts: { _width: 500, _height: 500, _layout_fitWidth: true, }}, {key: "MetaNote", creator: metaNoteTemplate, opts: { _width: 300, _height: 120, _header_pointerEvents: "all", _header_height: 50, _header_fontSize: 9,_layout_autoHeightMargins: 50, _layout_autoHeight: true, treeView_HideUnrendered: true}}, {key: "ViewSlide", creator: slideView, opts: { _width: 400, _height: 300, _xMargin: 3, _yMargin: 3,}}, @@ -450,6 +451,7 @@ pie title Minerals in my tap water { toolTip: "Tap or drag to create a scripting box", title: "Script", icon: "terminal", dragFactory: doc.emptyScript as Doc, clickFactory: DocCast(doc.emptyScript), funcs: { hidden: "IsNoviceMode()"}}, { toolTip: "Tap or drag to create a data viz node", title: "DataViz", icon: "chart-bar", dragFactory: doc.emptyDataViz as Doc, clickFactory: DocCast(doc.emptyDataViz)}, { toolTip: "Tap or drag to create a journal entry", title: "Journal", icon: "book", dragFactory:doc.emptyDailyJournal as Doc,clickFactory: DocCast(doc.emptyDataJournal), }, + { toolTip: "Tap or drag to create a task", title: "Task", icon: "check-square", dragFactory: doc.emptyTask as Doc, clickFactory: DocCast(doc.emptyTask), }, { toolTip: "Tap or drag to create a bullet slide", title: "PPT Slide", icon:"person-chalkboard",dragFactory: doc.emptySlide as Doc, clickFactory: DocCast(doc.emptySlide), openFactoryLocation: OpenWhere.overlay, funcs: { hidden: "IsNoviceMode()"}}, { toolTip: "Tap or drag to create a view slide", title: "View Slide", icon: "address-card", dragFactory: doc.emptyViewSlide as Doc, clickFactory: DocCast(doc.emptyViewSlide), openFactoryLocation: OpenWhere.overlay, funcs: { hidden: "IsNoviceMode()"}}, { toolTip: "Tap or drag to create a data note", title: "MetaNote", icon: "window-maximize", dragFactory: doc.emptyMetaNote as Doc, clickFactory: DocCast(doc.emptyMetaNote), openFactoryAsDelegate: true, funcs: { hidden: "IsNoviceMode()"} }, diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index e4bbb1c0f..b0bed927e 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -65,6 +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'; dotenv.config(); @@ -119,6 +120,7 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0, message: 'cache' }; StickerPalette: StickerPalette, FormattedTextBox, DailyJournal, // AARAV + TaskManagerTask, // AARAV ImageBox, FontIconBox, LabelBox, diff --git a/src/client/views/nodes/TaskManagerTask.tsx b/src/client/views/nodes/TaskManagerTask.tsx new file mode 100644 index 000000000..29acba75e --- /dev/null +++ b/src/client/views/nodes/TaskManagerTask.tsx @@ -0,0 +1,96 @@ +import { makeObservable, action, observable } from 'mobx'; +import { observer } from 'mobx-react'; +import * as React from 'react'; +import { Docs } from '../../documents/Documents'; +import { DocumentType } from '../../documents/DocumentTypes'; +import { FieldView } from './FieldView'; + +import { DateField } from '../../../fields/DateField'; +import { Doc, FieldType } from '../../../fields/Doc'; + +interface TaskManagerProps { + Document: Doc; +} + +@observer +export class TaskManagerTask extends React.Component<TaskManagerProps> { +public static LayoutString(fieldStr: string) { + return FieldView.LayoutString(TaskManagerTask, fieldStr); +} + +@action +updateText = (e: React.ChangeEvent<HTMLInputElement>) => { + this.props.Document.text = e.target.value; +}; + +@action +updateAllDay = (e: React.ChangeEvent<HTMLInputElement>) => { + this.props.Document.allDay = e.target.checked; +}; + +@action +updateStart = (e: React.ChangeEvent<HTMLInputElement>) => { + this.props.Document.startTime = new DateField(new Date(e.target.value)); +}; + +@action +updateEnd = (e: React.ChangeEvent<HTMLInputElement>) => { + this.props.Document.endTime = new DateField(new Date(e.target.value)); +}; + +render() { + const doc = this.props.Document; + + const taskDesc = typeof doc.text === 'string' ? doc.text : ''; + const allDay = !!doc.allDay; + + const startTime = doc.startTime instanceof DateField ? doc.startTime.date.toISOString().slice(0, 16) : ''; + + const endTime = doc.endTime instanceof DateField ? doc.endTime.date.toISOString().slice(0, 16) : ''; + + return ( + <div style={{ padding: 8, display: 'flex', flexDirection: 'column', gap: 8 }}> + <input + type="text" + placeholder="What’s your task?" + value={taskDesc} + onChange={this.updateText} + /> + + <label> + <input type="checkbox" checked={allDay} onChange={this.updateAllDay} /> + All day + </label> + + {!allDay && ( + <div style={{ display: 'flex', gap: 8 }}> + <label> + Start: + <input type="datetime-local" value={startTime} onChange={this.updateStart} /> + </label> + <label> + End: + <input type="datetime-local" value={endTime} onChange={this.updateEnd} /> + </label> + </div> + )} + </div> + ); +} +} + +Docs.Prototypes.TemplateMap.set(DocumentType.TASK, { + layout: { view: TaskManagerTask, dataField: 'text' }, + options: { + acl: '', + _height: 35, + _xMargin: 10, + _yMargin: 10, + _layout_autoHeight: true, + _layout_nativeDimEditable: true, + _layout_reflowVertical: true, + _layout_reflowHorizontal: true, + defaultDoubleClick: 'ignore', + systemIcon: 'BsCheckSquare', // or whatever icon you like + }, +}); |