Skip to content

fix(calendar): pass the SDK case id into the eForm editor in both dialogs - #1159

Merged
renemadsen merged 1 commit into
stablefrom
fix/1155-bind-case-id-in-calendar-dialogs
Sep 3, 2026
Merged

fix(calendar): pass the SDK case id into the eForm editor in both dialogs#1159
renemadsen merged 1 commit into
stablefrom
fix/1155-bind-case-id-in-calendar-dialogs

Conversation

@renemadsen

Copy link
Copy Markdown
Member

Fixes #1155

Important

Blocked on microting/eform-angular-frontend#8033. Plugin CI pins the frontend to stable, so until that PR merges this one fails to compile, not merely to test — it binds an @Input that does not exist on stable yet. Do not merge first.

Problem

Completing a calendar event whose eForm has a picture field fails on upload with the toast "Sagen blev ikke fundet" (CaseNotFound). Reported as a blocker for upgrading existing customers to Calendar.

The case was never missing. PrepareComplete materialises the Compliance via EnsureComplianceForOccurrenceAsync and returns a real SdkCaseId, and the modal already holds it — it uses it for getCase() and for the save. It simply never reached the picture component, which resolved its case id from the router URL. Inside a dialog the injected ActivatedRoute is the route the dialog was opened from, and backend-configuration-pn/calendar declares neither :id nor :sdkCaseId, so the id came out NaN and bound to 0 server-side.

Deleting and rotating existing images in the same modal always worked, because those endpoints take fileName/uploadedObjId rather than caseId — which is why this went unnoticed.

Change

Two one-line template bindings, passing the id the modals already have.

compliance-case-modal carries the same latent defect — currently unreachable from the web calendar since the combined-complete modal superseded it, but real — so it is fixed here too.

Provenance of the bound values

Both are the SDK cases.Id that EFormFilesController.AddNewImage resolves via sdkDbContext.Cases.Where(x => x.Id == caseId)not a Compliance, planning, PlanningCaseSite or occurrence id:

  • prepared.sdkCaseIdCalendarPrepareCompleteResult.SdkCaseId, set from Cases.FirstOrDefaultAsync(c => c.Id == compliance.MicrotingSdkCaseId) in PrepareComplete.
  • data.sdkCaseId → via calendar-container.component.ts, from CalendarToggleCompleteResult.SdkCaseId, set from the identical lookup in ToggleComplete.

Verified independently in review, since a wrong-but-plausible id would attach pictures to the wrong case — a silent corruption far worse than the current visible error.

Verification

  • Reviewed by subagent: no MUST-fix findings. It confirmed the id provenance independently, and closed the async question — prepared is assigned synchronously in the prepareComplete callback before loadCase() runs, and replyElement.elementList only becomes non-empty inside loadCase()'s subscribe, so there is no window where the picture renders with caseId unset.
  • Completeness check: the only other app-case-edit-element render sites in this plugin are two routed pages, where the route fallback works correctly and no binding is needed.
  • ng serve rebuilt cleanly with both changes in the bundle.

Related

Nested pictures (inside a FieldContainer question group) needed a further fix in the shared chain — included in #8033. Extra-picture upload is separately broken for an unrelated reason and is tracked in microting/eform-angular-frontend#8032.

🤖 Generated with Claude Code

https://claude.ai/code/session_015sXLtgzZU8QL9m84GqMkoJ

…logs

Completing a calendar event whose eForm has a picture field failed on
upload with the toast "Sagen blev ikke fundet" (CaseNotFound).

The case was never missing. PrepareComplete materialises the Compliance
and returns a real SdkCaseId, and the modal already holds it -- it uses it
for getCase() and for the save. It simply never reached the picture
component, which resolved its case id from the router URL. Inside a dialog
the injected ActivatedRoute is the route the dialog was opened from, and
backend-configuration-pn/calendar declares neither :id nor :sdkCaseId, so
the id came out NaN and bound to 0 server-side.

Bind the id the modals already have. compliance-case-modal carries the
same latent defect -- currently unreachable from the web calendar since
the combined-complete modal superseded it, but real -- so it is fixed
here too.

Both bound values are the SDK cases.Id that AddNewImage resolves, taken
from Cases.FirstOrDefaultAsync(c => c.Id == compliance.MicrotingSdkCaseId)
in PrepareComplete and ToggleComplete respectively -- not a Compliance,
planning or occurrence id.

Requires the shared-chain change in
microting/eform-angular-frontend#8033, which adds the optional caseId
input. That must merge first or this fails to compile.

Refs #1155

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sXLtgzZU8QL9m84GqMkoJ
Copilot AI lite review requested due to automatic review settings September 3, 2026 07:07

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.

🔵 Needs a closer look

It is explicitly blocked on an upstream frontend change and is expected to fail compilation against the currently pinned stable, so the change can’t be validated end-to-end from this PR alone.

Pull request overview

This PR fixes calendar picture uploads inside the “complete event” and “compliance case” dialogs by explicitly passing the SDK case id down to the shared case editor component, avoiding the dialog-route fallback that resolves to NaN/0 and triggers CaseNotFound.

Changes:

  • Bind [caseId] to the already-available SDK case id in calendar-complete-event-modal (prepared?.sdkCaseId).
  • Bind [caseId] to the injected dialog data SDK case id in compliance-case-modal (data.sdkCaseId).
File summaries
File Description
eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/modals/compliance-case-modal/compliance-case-modal.component.html Passes dialog-provided sdkCaseId into the case editor to ensure picture uploads target the correct SDK case.
eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/modals/calendar-complete-event-modal/calendar-complete-event-modal.component.html Passes prepared sdkCaseId into the case editor so nested picture components don’t rely on route params inside a dialog.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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