From 27f4f85a49f3aaf31e8ff1f2c8aa9d5020eee6ac Mon Sep 17 00:00:00 2001 From: aaravkumar Date: Wed, 23 Apr 2025 23:03:16 -0400 Subject: added basic task nodes with descritpion, start and end times -- added doc options for starttime/endtime/allday --- src/client/views/nodes/TaskManagerTask.tsx | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/client/views/nodes/TaskManagerTask.tsx (limited to 'src/client/views/nodes/TaskManagerTask.tsx') 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 { +public static LayoutString(fieldStr: string) { + return FieldView.LayoutString(TaskManagerTask, fieldStr); +} + +@action +updateText = (e: React.ChangeEvent) => { + this.props.Document.text = e.target.value; +}; + +@action +updateAllDay = (e: React.ChangeEvent) => { + this.props.Document.allDay = e.target.checked; +}; + +@action +updateStart = (e: React.ChangeEvent) => { + this.props.Document.startTime = new DateField(new Date(e.target.value)); +}; + +@action +updateEnd = (e: React.ChangeEvent) => { + 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 ( +
+ + + + + {!allDay && ( +
+ + +
+ )} +
+ ); +} +} + +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 + }, +}); -- cgit v1.2.3-70-g09d2