-
Notifications
You must be signed in to change notification settings - Fork 34
feat: unit options for pre-configured conditions #1954
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @abdimo101 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts:86` </location>
<code_context>
+ const unitsOptions = this.data.condition?.unitsOptions;
+
+ // if pre-configured condition has unitsOptions, store and use them.
+ if (lhs && unitsOptions?.length) {
+ this.unitsOptionsService.setUnitsOptions(lhs, unitsOptions);
+ this.units = unitsOptions;
</code_context>
<issue_to_address>
unitsOptions may contain duplicates; consider deduplication.
If duplicates are unnecessary, deduplicate unitsOptions before storing or displaying.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
if (lhs && unitsOptions?.length) {
this.unitsOptionsService.setUnitsOptions(lhs, unitsOptions);
this.units = unitsOptions;
=======
if (lhs && unitsOptions?.length) {
const dedupedUnitsOptions = Array.from(new Set(unitsOptions));
this.unitsOptionsService.setUnitsOptions(lhs, dedupedUnitsOptions);
this.units = dedupedUnitsOptions;
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts:98` </location>
<code_context>
getUnits = (parameterKey: string): void => {
- this.units = this.unitsService.getUnits(parameterKey);
+ const stored = this.unitsOptionsService.getUnitsOptions(parameterKey);
+ if (stored?.length) {
+ this.units = stored;
+ } else if (this.data.condition?.unitsOptions?.length) {
</code_context>
<issue_to_address>
getUnits may return undefined; ensure downstream code handles this.
If both stored and data.condition.unitsOptions are missing, this.units could be undefined. Make sure this.units is always set to an array to prevent template errors.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts
Outdated
Show resolved
Hide resolved
src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some AI review comments already that might be worth checking. But other than that I don't have anything more. It looks fine.
Description
This PR implements limited units in the unit dropdown within the condition panel when unit options are provided in

frontend-config.json
.Ex.
Motivation
Some users that provide pre-configured conditions want to only show the units they provided, instead of displaying all available units.
Fixes:
Please provide a list of the fixes implemented in this PR
Changes:
Please provide a list of the changes implemented by this PR
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included
Backend version
Summary by Sourcery
Allow datasets filter conditions to restrict available unit options based on pre-configured settings.
New Features:
Enhancements:
Tests: