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 --- .../views/nodes/formattedText/DailyJournal.tsx | 70 ++++++---------------- 1 file changed, 19 insertions(+), 51 deletions(-) (limited to 'src/client/views/nodes/formattedText') diff --git a/src/client/views/nodes/formattedText/DailyJournal.tsx b/src/client/views/nodes/formattedText/DailyJournal.tsx index ae5582ef7..564609494 100644 --- a/src/client/views/nodes/formattedText/DailyJournal.tsx +++ b/src/client/views/nodes/formattedText/DailyJournal.tsx @@ -12,7 +12,6 @@ import { RTFCast } from '../../../../fields/Types'; import { Mark } from 'prosemirror-model'; import { observer } from 'mobx-react'; - export class DailyJournal extends ViewBoxAnnotatableComponent() { @observable journalDate: string; @observable typingTimeout: NodeJS.Timeout | null = null; // track typing delay @@ -22,8 +21,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() @observable inlinePromptsEnabled = true; @observable askPromptsEnabled = true; - - _ref = React.createRef(); // reference to the formatted textbox predictiveTextRange: { from: number; to: number } | null = null; // where predictive text starts and ends private predictiveText: string | null = ' ... why?'; @@ -114,7 +111,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() @action.bound toggleAskPrompts() { this.askPromptsEnabled = !this.askPromptsEnabled; } - + /** * Method to handle click on document (to close prompt menu) * @param e - a click on the document @@ -123,33 +120,27 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() handleDocumentClick(e: MouseEvent) { const menu = document.getElementById('prompts-menu'); const button = document.getElementById('prompts-button'); - if ( - this.showPromptMenu && - menu && - !menu.contains(e.target as Node) && - button && - !button.contains(e.target as Node) - ) { + if (this.showPromptMenu && menu && !menu.contains(e.target as Node) && button && !button.contains(e.target as Node)) { this.showPromptMenu = false; } } - /** * Method to set initial date of document in the calendar view */ @action setInitialDateRange() { - if (!this.dataDoc.date_range && this.journalDate) { + if (!this.dataDoc.$task_dateRange && this.journalDate) { const parsedDate = new Date(this.journalDate); if (!isNaN(parsedDate.getTime())) { const localStart = new Date(parsedDate.getFullYear(), parsedDate.getMonth(), parsedDate.getDate()); const localEnd = new Date(localStart); // same day - this.dataDoc.date_range = `${localStart.toISOString()}|${localEnd.toISOString()}`; - this.dataDoc.allDay = true; + this.dataDoc.$task_dateRange = `${localStart.toISOString()}|${localEnd.toISOString()}`; + this.dataDoc.$task_allDay = true; + this.dataDoc.$task = ''; // needed only to make the keyvalue view look good. - // console.log('Set date_range and allDay on journal (from local date):', this.dataDoc.date_range); + // console.log('Set task_dateRange and task_allDay on journal (from local date):', this.dataDoc.$task_dateRange); } else { // console.log('Could not parse journalDate:', this.journalDate); } @@ -187,7 +178,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() if (this.inlinePromptsEnabled) { this.insertPredictiveQuestion(); } - }, 3500); }; @@ -196,7 +186,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() */ @action insertPredictiveQuestion = async () => { - const editorView = this._ref.current?.EditorView; if (!editorView) return; @@ -347,7 +336,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() */ @action handleGeneratePrompts = async () => { if (this.isLoadingPrompts) { - return + return; } this.isLoadingPrompts = true; @@ -391,8 +380,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() // Insert formatted text const transaction = state.tr.insert(state.selection.from, headerText).insert(state.selection.from + headerText.nodeSize, responseText); dispatch(transaction); - (this._props as any)?.updateLayout?.(); - } } catch (err) { console.error('Error calling GPT:', err); @@ -402,7 +389,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() }; /** - * Method to render the styled DailyJournal + * Method to render the styled DailyJournal * @returns - the HTML component for the journal */ render() { @@ -438,8 +425,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() cursor: 'pointer', zIndex: 10, }} - onClick={this.togglePromptMenu} - > + onClick={this.togglePromptMenu}> Prompts {this.showPromptMenu && ( @@ -458,16 +444,14 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() minWidth: '170px', maxWidth: 'fit-content', overflow: 'auto', - }} - > + }}>
+ }}>
- +
+ }}>
@@ -531,15 +502,12 @@ export class DailyJournal extends ViewBoxAnnotatableComponent() opacity: this.isLoadingPrompts ? 0.6 : 1, padding: '5px 10px', float: 'right', - }} - > + }}> Generate Prompts )} - - ); -- cgit v1.2.3-70-g09d2