{'heading': 'How dated Notes (`NodeEditorView`) link to your workouts and meals', 'summary': 'In `Ayurveda & Asana Yoga`, creating a note (`New Node` in `NodeEditorView`) does more than save plain text: as soon as you pick a `Date:`, the editor queries your calendar for that day (`loadDataFromCalendar()`) and populates two interactive checklists—`Link Foods from this Day` and `Link Exercises from this Day`. Tapping any food or exercise attaches that exact catalog or user record (`linkedFoods` / `linkedExercises`) to your written observation.', 'bullets': ['Calendar-driven checklists: Foods and workouts must be logged on your calendar for the selected date to appear in `Link Foods from this Day` and `Link Exercises from this Day`.', 'Date-change reset: Changing the `Date:` picker while creating a `New Node` clears any previously checked foods and exercises (`selectedFoodIDs.removeAll()`) and reloads items for the new date.', 'Locked date on edit: When editing an existing note (`Edit Node`), the `Date:` picker is intentionally locked (`.disabled(nodeToEdit != nil)`) so existing day links stay consistent.', 'Non-empty text requirement: The `Save` button stays disabled until you type at least one non-whitespace character into the `Note` text box.']}
In `Ayurveda & Asana Yoga`, creating a note (`New Node` in `NodeEditorView`) does more than save plain text: as soon as you pick a `Date:`, the editor queries your calendar for that day (`loadDataFromCalendar()`) and populates two interactive checklists—`Link Foods from this Day` and `Link Exercises from this Day`. Tapping any food or exercise attaches that exact catalog or user record (`linkedFoods` / `linkedExercises`) to your written observation.
Calendar-driven checklists: Foods and workouts must be logged on your calendar for the selected date to appear in `Link Foods from this Day` and `Link Exercises from this Day`.
Date-change reset: Changing the `Date:` picker while creating a `New Node` clears any previously checked foods and exercises (`selectedFoodIDs.removeAll()`) and reloads items for the new date.
Locked date on edit: When editing an existing note (`Edit Node`), the `Date:` picker is intentionally locked (`.disabled(nodeToEdit != nil)`) so existing day links stay consistent.
Non-empty text requirement: The `Save` button stays disabled until you type at least one non-whitespace character into the `Note` text box.
Creating a "New Node" and Loading Items from Your Calendar Day
Written practice notes are most useful when they are tied to what you actually practiced and ate rather than floating in a separate notebook. When you open `NodeEditorView` (`New Node`), the top card (`generalSection`) presents a `Date:` picker (defaulting to today) and a multi-line `Note` text editor with the placeholder *"Enter your thoughts, notes, or observations..."*
Triggered by `.task(id: date)`, the view runs `loadDataFromCalendar()` for the selected date and populates two cards below the text box: `Link Foods from this Day` and `Link Exercises from this Day`. If no meals or workouts have been logged on the calendar for that date yet, those cards display *"No foods logged in calendar for this day."* or *"No workouts logged in calendar for this day."* Because of this workflow, always log your yoga workout or meal on the calendar first, then open `New Node` so every item is ready to link with a single tap.
- Step 1: Log your yoga sequence, individual posture, or meal on the calendar for that day.
- Step 2: Open `New Node`, verify the `Date:`, and type your observation in the `Note` field (`Save` unlocks as soon as `nodeText` is non-empty).
- Step 3: Tap any row under `Link Foods from this Day` (`SelectableFoodRowNode`) or `Link Exercises from this Day` (`SelectableExerciseRowNode`) to attach it to the note.
Why Changing the Date Clears Selections—and Editing Locks the Date
Two protective rules in `NodeEditorView.swift` prevent a note from accidentally linking to foods or exercises from the wrong calendar day. First, when you are creating a `New Node` (`nodeToEdit == nil`) and you change the `Date:` picker to a past day, the `.onChange(of: date)` handler immediately calls `selectedFoodIDs.removeAll()` and `selectedExerciseIDs.removeAll()` before loading the new day's calendar entries.
Second, once a note is saved and you reopen it later (`Edit Node`, where `nodeToEdit != nil`), the `CustomDatePicker` is disabled (`.disabled(nodeToEdit != nil)`) and dimmed to 60% opacity. Locking the date on existing notes guarantees that the `linkedFoods` and `linkedExercises` stored on that `Node` always correspond to the calendar day on which they were logged.
- Pick the date first on a `New Node`: Set the `Date:` before tapping food or exercise links so you do not reset your selections.
- Edit text and links anytime: In `Edit Node`, you can freely update the note text or toggle linked foods and exercises from that same date.
- Keyboard dismissal tip: Tap anywhere outside the text box on the scroll view to dismiss the on-screen keyboard (`isTextEditorFocused = false`) before scrolling through your food and exercise rows.
What to Record in Linked Practice and Meal Notes
Because a single `Node` can link both `FoodItem` and `ExerciseItem` records from the same day, it serves as a unified bridge between your kitchen and your mat. Instead of writing long diary entries, record one or two concrete variables that help you adjust your next session or meal plan.
For linked exercises, note prop heights (such as *"2 folded blankets under hips in Seated Forward Fold; blocks on medium in Triangle"*), left-vs-right balance differences, or how a sequence felt relative to meal timing. For linked meals, note digestion comfort 1 to 2 hours after eating, spice or sourness adjustments, or batch-cooking yield notes.
- Meal-to-practice timing check: Link both your midday meal and afternoon yoga workout when noting whether practicing 90 minutes vs. 3 hours after eating felt comfortable.
- Prop recipe memory: Link a specific yoga sequence and write down the exact block height or strap loop length that made a pose click.
- Pre-teacher summary: Review your linked `Node` entries before a studio class so you have exact posture names ready to discuss.
Frequently Asked Questions
Why does "Link Exercises from this Day" say "No workouts logged in calendar for this day"?
`NodeEditorView` pulls candidate exercises and foods directly from your calendar events for the selected `Date:`. Log the workout or meal on that calendar date first, then open `New Node`.
Why is the Save button grayed out when I select a food or exercise in New Node?
`isSaveDisabled` remains `true` as long as `nodeText` is empty or contains only spaces. Type a brief note in the `Note` text field to enable `Save`.
Can I change the date of an existing Note after saving it?
No. In `Edit Node`, the date picker is locked so the note's linked calendar foods and exercises remain tied to the day they were logged. To move a note to another date, copy the text and create a `New Node` on the target date.





