Skip to content

fix(calendar): custom-repeat occurrence cannot be dragged back to its natural day after a prior move #953

Description

@renemadsen

Summary

With a custom Mon+Wed+Fri repeating task:

  • Dragging the Wednesday occurrence to Thursday (scope = Only this) works correctly.
  • Attempting to drag the Thursday occurrence back to Wednesday silently fails — the task stays on Thursday.

Root Cause (already analysed)

BackendConfigurationCalendarService.MoveTask scope = this always creates or updates a CalendarOccurrenceException keyed on OriginalDate = request.OriginalDate (the currently-displayed date).

When the task was first moved Wed Jun 10 → Thu Jun 11, exception E1 is created:

E1: OriginalDate=Jun10, NewDate=Jun11

The task now renders on Jun 11. When the user drags "Jun 11" back to Jun 10, the backend receives originalDate=Jun11, newDate=Jun10. It creates a new exception E2:

E2: OriginalDate=Jun11, NewDate=Jun10

But Jun 11 is not a natural occurrence of Mon/Wed/Fri — the occurrence calculator only matches exceptions against natural dates. E2 is therefore an orphan and has no effect. The task stays on Jun 11. E1 is never modified.

Fix required in MoveTask scope = this:
Before creating a new exception, check whether an existing exception has NewDate = request.OriginalDate (meaning a prior move placed the task at the current display date). If found:

  • Update that exception's NewDate = request.NewDate.
  • Special case: if request.NewDate == existingException.OriginalDate, delete the exception (task reverts to its natural date).

If no such exception exists, proceed with the current logic.

Files to fix:

  • BackendConfigurationCalendarService.csMoveTask method, scope = "this" branch (lines ~1739–1771).

Steps to reproduce

Use Playwright against http://localhost:4200. Login: <your-admin-email> / <your-local-admin-password>.

  1. Navigate to /plugins/backend-configuration-pn/calendar.
  2. Create a new task. Set Gentag Tilpasset (Custom Repeat), select Mon + Wed + Fri. Save.
  3. Confirm three tiles appear: Monday, Wednesday, Friday.
  4. Drag the Wednesday tile to Thursday. In the scope dialog select "Only this". Confirm.
  5. Verify the Wednesday tile is gone and a Thursday tile has appeared.
  6. Now drag the Thursday tile back to Wednesday. In the scope dialog select "Only this". Confirm.
  7. Observe the result.

Expected: The task tile moves back to Wednesday.
Actual: The task remains on Thursday; the drag has no visible effect.

How to verify the fix

Playwright test (Angular e2e)

  1. Create a Mon+Wed+Fri task.
  2. Drag Wed → Thu (scope=this). Assert Thu tile visible, Wed tile gone.
  3. Drag Thu → Wed (scope=this). Assert Wed tile visible, Thu tile gone (back to original).
  4. Bonus: drag Wed → Thu again to confirm the round-trip can be repeated.

C# integration test

In BackendConfiguration.Test:

  1. Seed an ARP with RepeatWeekdaysCsv = "1,3,5" (Mon/Wed/Fri), StartDate = 2026-06-08.
  2. Call MoveTask with originalDate = "2026-06-10", newDate = "2026-06-11", scope = "this".
  3. Assert a CalendarOccurrenceException exists with OriginalDate=Jun10, NewDate=Jun11.
  4. Call MoveTask with originalDate = "2026-06-11", newDate = "2026-06-10", scope = "this".
  5. Assert the CalendarOccurrenceException from step 3 is deleted (task reverted to natural).
  6. Assert NO orphan exception with OriginalDate=Jun11 exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions