Skip to content

Add note history to make it easier to use the same notes for several clock-ins - #3

Merged
MakingSpiderSense merged 12 commits into
mainfrom
feature/149-improve-notes-memory
Jul 31, 2026
Merged

Add note history to make it easier to use the same notes for several clock-ins#3
MakingSpiderSense merged 12 commits into
mainfrom
feature/149-improve-notes-memory

Conversation

@MakingSpiderSense

Copy link
Copy Markdown
Owner

This pull request introduces a new feature for retrieving recent notes associated with a subcategory. The main changes are the addition of a note history button, a controller method to fetch recent notes, and the corresponding route to expose this functionality via the API.

Details

  • Added a note history button for quick retrieval of previous notes for a subcategory.
  • Added a getRecentNotes method to ClockInOutController that returns the 20 most recent notes (history) and the latest note for a given subcategory, filtering out empty notes and ensuring uniqueness in the history.
  • Registered a new GET route /recent-notes/{subcategory_id} in routes/web.php to expose the recent notes retrieval functionality.

https://trello.com/c/qlPlr7nu

Copilot AI review requested due to automatic review settings July 31, 2026 04:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “recent notes” (note history) feature to the clock-in dashboard so users can quickly reuse previously-entered notes per subcategory, backed by a new controller endpoint and route.

Changes:

  • Added a new GET endpoint to fetch recent notes for a given subcategory.
  • Added dashboard UI controls to cycle through recent notes and clear the notes field.
  • Added client-side fetching/caching logic to auto-populate notes based on the selected category/subcategory.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
routes/web.php Registers a new /recent-notes/{subcategory_id} route exposing the recent-notes API.
resources/js/Pages/Dashboard.vue Adds the note-history UI and fetch/cycle behavior tied to category/subcategory selection.
app/Http/Controllers/ClockInOutController.php Implements getRecentNotes() returning latest and a de-duplicated history payload.
Suppressed comments (1)

resources/js/Pages/Dashboard.vue:248

  • When data.latest is blank, getNotesHistory() forcibly clears form.notes. This can unexpectedly erase notes the user has already typed when switching categories/subcategories. Only auto-populate when there is a non-empty latest note and the notes field is still empty; otherwise leave the user's input untouched.
                // Auto-populate only if the latest note wasn't blank
                if (data.latest && data.latest.trim() !== "") {
                    this.isCyclingHistory = true; // Prevent the notes watcher from resetting the index
                    this.form.notes = data.latest;
                    this.historyIndex = 0; // Reset to the first item in the history
                } else {
                    this.form.notes = ""; // Clear notes if no history is found for subcategory
                }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 132 to 137
@@ -147,6 +137,14 @@ export default {
},

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to PR

Comment on lines +230 to +234
if (!subId) {
this.lastFetchedSubId = null;
this.form.notes = ""; // Clear notes if subcategory isn't recognized
return;
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. It's the last field, so less likely. And it's a trade-off to help clear old notes from other sub-category's notes.

this.form.manualTime = dateTimeUTCFormatted;
// Close modal and remove event listener
document.querySelector('.modal').style.display = 'none';
modalFooter.removeEventListener('click', saveTime);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing and unrelated to this PR.

Comment on lines +254 to +263
$raw = TempLog::where('user_id', auth()->user()->id)
->where('subcategory_id', $subcategory_id)
->orderBy('created_at', 'desc')
->take(20)
->pluck('notes');

return response()->json([
'latest' => $raw->first(),
'history' => $raw->filter(fn($n) => !empty(trim($n)))->unique()->values()
]);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be an issue. We don't actually need 20 and the null issue can't actually happen.

Comment on lines +101 to +105
<a v-if="notesHistory.length > 0" href="#" @click.prevent="cycleNotesHistory" title="Cycle Recent Notes">
<i class="fas fa-clock-rotate-left"></i>
</a>
<a v-if="form.notes" href="#" @click.prevent="clearNotes" title="Clear Notes">
<i class="fas fa-times"></i>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@MakingSpiderSense
MakingSpiderSense merged commit 302cdbc into main Jul 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants