Skip to content

Conversation

@carlobeltrame
Copy link
Member

@carlobeltrame carlobeltrame commented Sep 6, 2025

Problem: I noticed that when reloading the print configurator page and then client printing a program with some activities with checklist nodes in it, the checklist nodes remain blank.

I then found out that inside client print some data is not properly preloaded before printing. Inside each checklist node, there is a _linked collection checklistItems: { href: /api/checklist_items?checklistNodes=/api/content_node/checklist_nodes/1a2b3c4d }. Although all individual checklist items are present in the store, this filtered collection is missing. For material nodes and their attached material items, we don't have this problem.

Detailed problem 1: In client print, we need this missing data to render the PDF correctly. This PR is an attempt to fix this problem, so that PDFs can be rendered complete with all content. I am doing this by embedding the checklist items in each checklist node, just like we already do with material items in material nodes.

Detailed problem 2: Currently, client print does not fail and report the error, but silently renders an empty Vue component, leaving an empty space in the PDF. This is due to Vue 3 aggressively catching errors which happen in setup functions, and not escalating them to outside the Vue app by default. This will be tackled in a separate PR #8128, so we get all errors in client print in sentry.

If we first solved detailed problem 2, then exporting pdfs would break. Therefore, I am first opening this PR and later a fix for detailed problem 2.

@carlobeltrame carlobeltrame requested a review from a team September 6, 2025 12:34
Copy link
Contributor

@BacLuc BacLuc left a comment

Choose a reason for hiding this comment

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

I think we had a reason to not do this:
See in EndpointPerformanceTest
2025-09-06T12:37:42.9347400Z -/activities/item: 35\n
2025-09-06T12:37:42.9348030Z +/activities/item: 37\n

can't we solve this in the frontend?
something similar than this:
#7747

@carlobeltrame
Copy link
Member Author

Yes, looks like it introduces an n+1 problem. I don't fully understand why in the case of the material node we do not have an n+1, maybe because there it is a one-to-many relation instead of the many-to-many relation between checklist nodes <-> checklist items...?

Solving this in the frontend by preloading will result in n+1 API requests instead..
But I can maybe implement the filtering of checklist items by content node in the frontend instead of relying on the API for this.

@carlobeltrame
Copy link
Member Author

I tried several different ways to solve this, which turned out not to work:

  • Embed ChecklistItems in ChecklistNode. Although we do it similarly for MaterialItem in MaterialNode, for checklists this introduces n+1 DB queries. Maybe because the relation is many-to-many instead of one-to-many, didn't debug Doctrine / Api Platform deeply.
  • Disabling the related collection link by removing the SearchFilter 'checklistNode' from ChecklistItem, but this SearchFilter was explicitely added in Feature/activity load selected checklist items as collection #7199 for performance reasons elsewhere in the app.
  • Preloading the missing checklistNode.checklistItems() collections in the frontend leads to n+1 API requests, which is even worse.
  • Loading all checklist items in the client print component and filtering them there has the problem that the camp is not available on the content node, and if we use all checklist items from /checklist_items, the list can quickly get very large.

So the only way I found that works is to provide camp to the client print rendering component, and then getting all checklists in the camp, all checklist items in the camp and from there finally get the filtered list of checklist items used in this checklist node.

@carlobeltrame carlobeltrame added this pull request to the merge queue Sep 6, 2025
Merged via the queue into ecamp:devel with commit fcecf54 Sep 6, 2025
30 checks passed
@carlobeltrame carlobeltrame deleted the client-print-checklist-fix branch September 6, 2025 23:20
This was referenced Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants