Skip to content

feat: drag-and-drop entries across days and editable date in entry modal#198

Merged
BenGWeeks merged 2 commits into
mainfrom
fix/194-drag-drop-entries-edit-date
May 5, 2026
Merged

feat: drag-and-drop entries across days and editable date in entry modal#198
BenGWeeks merged 2 commits into
mainfrom
fix/194-drag-drop-entries-edit-date

Conversation

@EdiWeeks
Copy link
Copy Markdown
Contributor

@EdiWeeks EdiWeeks commented May 5, 2026

Summary

  • Edit modal gains a Date dropdown constrained to the current week; the title now updates as the date changes. Saving a new date moves the entry.
  • Weekly view supports HTML5 drag-and-drop between day columns with a green highlight on the drop target.
  • Both gated by the existing isTimesheetEditable check, so locked/submitted/approved timesheets stay read-only.
  • New service method moveEntryDate(entryId, newDate): writes hours to the new date, then zeros the old one (BC details key on line+date). Same-line conflicts on the target date are merged (hours sum).
image

Test plan

  • Open a time entry, change Date to another day in the week, click Update — entry moves; weekly totals update.
  • Drag an entry from one day onto another — target column highlights green; on drop entry moves.
  • Try dragging an entry onto its own day — no-op, no toast.
  • Submit timesheet, then try to drag an entry — drag is gated (modal also blocks edits).
  • Move an entry to a day that already has an entry on the same line (same project/task/notes) — hours sum.
  • Move an entry to a day that has an entry on a different line — both entries appear separately on that day.
  • Modal title updates as you change the Date dropdown.

Fixes #194
Fixes #195

🤖 Generated with Claude Code

- Edit modal: new Date dropdown constrained to the current week; modal title
  reacts to the selection. Saving a new date moves the entry to that day.
- Weekly view: time entries are draggable between day columns when the
  timesheet is open; target column highlights on hover.
- Service: add moveEntryDate() that writes hours to the new date then zeros
  the old date (BC has no first-class date field on a detail). Same-line
  conflicts on the target date are merged (sum of hours).
- Both behaviors are gated by the existing canEdit / isTimesheetEditable
  check, so locked timesheets stay read-only.

Closes #194
Closes #195

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 5, 2026 08:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the ability to reassign time entries to different days within the current week, via both a Date selector in the entry modal and HTML5 drag-and-drop in the weekly grid. This builds on the existing Business Central timesheet-line + date-detail model by introducing a dedicated “move date” mutation and refreshing client state from the service cache after moves.

Changes:

  • Added timeEntryService.moveEntryDate(entryId, newDate) plus a cache-to-entries helper to refresh UI state after merges.
  • Wired a new moveEntryDate action into the Zustand time entries store.
  • Updated weekly timesheet UI to support drag/drop across day columns and updated the modal to allow changing an entry’s date within the week.

Reviewed changes

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

Show a summary per file
File Description
src/services/bc/timeEntryService.ts Adds moveEntryDate (including same-line merge behavior) and getCachedEntries for post-mutation refresh.
src/hooks/useTimeEntriesStore.ts Exposes moveEntryDate in the store and refreshes entries from the service cache after moves.
src/components/timesheet/WeeklyTimesheet.tsx Plumbs onMoveEntry into day cells and passes weekStart to the modal.
src/components/timesheet/TimeEntryModal.tsx Adds an in-week Date dropdown and triggers move+update flow when editing entries.
src/components/timesheet/TimeEntryCell.tsx Implements HTML5 drag-and-drop source/target behavior with drop-target highlighting.

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

Comment thread src/components/timesheet/TimeEntryModal.tsx Outdated
Comment thread src/services/bc/timeEntryService.ts
When editing an entry and changing the date, moveEntryDate may merge with an
existing detail on the same timesheet line at the target date (sum of hours).
The follow-up updateEntry call was unconditionally writing the form's hours
to that date, overwriting the merged total.

Only forward fields the user actually changed; if only the date changed, skip
the updateEntry call entirely so the merge result stands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EdiWeeks EdiWeeks requested a review from BenGWeeks May 5, 2026 08:30
@BenGWeeks BenGWeeks merged commit 5bdaa15 into main May 5, 2026
11 checks 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.

[ENHANCEMENT] I would like the ability to drag and drop entries across days Drag/drop entries across days and edit date in entry modal

3 participants