fix(calendar): pass the SDK case id into the eForm editor in both dialogs - #1159
Merged
Merged
Conversation
…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
There was a problem hiding this comment.
🔵 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 incalendar-complete-event-modal(prepared?.sdkCaseId). - Bind
[caseId]to the injected dialog data SDK case id incompliance-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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@Inputthat does not exist onstableyet. 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.
PrepareCompletematerialises the Compliance viaEnsureComplianceForOccurrenceAsyncand returns a realSdkCaseId, and the modal already holds it — it uses it forgetCase()and for the save. It simply never reached the picture component, which resolved its case id from the router URL. Inside a dialog the injectedActivatedRouteis the route the dialog was opened from, andbackend-configuration-pn/calendardeclares neither:idnor:sdkCaseId, so the id came outNaNand bound to0server-side.Deleting and rotating existing images in the same modal always worked, because those endpoints take
fileName/uploadedObjIdrather thancaseId— which is why this went unnoticed.Change
Two one-line template bindings, passing the id the modals already have.
compliance-case-modalcarries 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.IdthatEFormFilesController.AddNewImageresolves viasdkDbContext.Cases.Where(x => x.Id == caseId)— not a Compliance, planning, PlanningCaseSite or occurrence id:prepared.sdkCaseId→CalendarPrepareCompleteResult.SdkCaseId, set fromCases.FirstOrDefaultAsync(c => c.Id == compliance.MicrotingSdkCaseId)inPrepareComplete.data.sdkCaseId→ viacalendar-container.component.ts, fromCalendarToggleCompleteResult.SdkCaseId, set from the identical lookup inToggleComplete.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
preparedis assigned synchronously in theprepareCompletecallback beforeloadCase()runs, andreplyElement.elementListonly becomes non-empty insideloadCase()'s subscribe, so there is no window where the picture renders withcaseIdunset.app-case-edit-elementrender sites in this plugin are two routed pages, where the route fallback works correctly and no binding is needed.ng serverebuilt cleanly with both changes in the bundle.Related
Nested pictures (inside a
FieldContainerquestion 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