Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make local context available in data-items loop #2304

Closed
wants to merge 10 commits into from

Conversation

jfmcquade
Copy link
Collaborator

@jfmcquade jfmcquade commented Apr 26, 2024

PR Checklist

  • PR title descriptive (can be used in release notes)

TODO

Description

Allows rows within a data-items loop to reference local variables (#2303).

Dev notes

This feels like a hack, and adding another caveat to the template-variables service logic doesn't feel great, but it does seem to work.

NB: view the code changes for template-variables.service.ts with whitespace changes hidden in order to see meaningful diff.

Git Issues

Closes #2303

Screenshots/Videos

debug_data_items

Screenshot 2024-04-26 at 12 35 03 Screenshot 2024-04-26 at 12 30 11

debug_data_items_local

Screenshot 2024-04-26 at 12 36 07 Screenshot 2024-04-26 at 12 30 17

fields: MOCK_FIELDS,
local: {},
},
thisCtxt: {},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because calcContext gets overridden by templateCalcService.getCalcContext() as part of evaluatePLHString(), the values here has no effect on the results of evaluatePLHData() in current test cases

@jfmcquade jfmcquade changed the title spike: make local context available in data-items loop feat: make local context available in data-items loop May 1, 2024
@github-actions github-actions bot added feature Work on app features/modules and removed feature Work on app features/modules labels May 1, 2024
@jfmcquade jfmcquade marked this pull request as ready for review May 1, 2024 17:48
@jfmcquade jfmcquade removed the request for review from chrismclarke May 1, 2024 17:48
@jfmcquade jfmcquade requested a review from chrismclarke May 1, 2024 17:48
@esmeetewinkel
Copy link
Collaborator

I found this works in general, but there is a case where somehow the first iteration of a local variable in a data-items loop is found, but next iterations are not. I thought it had to do with the presence of a display group, but that doesn't seem to be the case since this template works.

debug_kids
image
image

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

I'm slightly reluctant to add more case handling to the template-variable service as (like you mentioned), it's already feeling pretty difficult to follow/maintain.

I've proposed an alternate fix in #2314, let me know what you think and whether there would still be use to migrate any of the tests/notes from this PR over

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Work on app features/modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] data_items doesn't find local variables
3 participants