-
Notifications
You must be signed in to change notification settings - Fork 153
Jayapraksh1234 patch 1 #13597
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
base: development
Are you sure you want to change the base?
Jayapraksh1234 patch 1 #13597
Conversation
Fix: Make environment samples toggle independent from case samples on Map Dashboard - Environment samples are now OFF by default. - Toggling the case samples checkbox does not affect environment samples. - Environment samples checkbox is fully independent.
WalkthroughThe map component’s environment samples layer is now disabled by default, its checkbox initialization reflects the internal flag, and the value change listener directly assigns the checkbox value to the state. Map refresh on toggle remains unchanged. No public APIs were modified. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as Checkbox: Env Samples
participant Comp as SampleDashboardMapComponent
participant Map as MapRenderer
Note over Comp: Initialization
Comp->>Comp: showEnvironmentalSamples = false
Comp->>UI: setValue(showEnvironmentalSamples)
Note over User,UI: Toggle interaction
User->>UI: Click checkbox
UI->>Comp: valueChange(e.value)
Comp->>Comp: showEnvironmentalSamples = e.value
Comp->>Map: refreshLayers()
Map-->>Comp: rerender complete
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (1 passed, 1 warning, 1 inconclusive)❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java (1)
257-259: Legend hidden when only environment samples are shownEarly return suppresses the legend even if
showEnvironmentalSamplesis true and no human samples are selected.- if (displayedHumanSamples.size() == 0) { - return Collections.emptyList(); - } + if (displayedHumanSamples.isEmpty() && !showEnvironmentalSamples) { + return Collections.emptyList(); + }
🧹 Nitpick comments (3)
sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java (3)
63-66: Permission checks for env samples are inconsistent — verify intended gatingInit uses
UiUtil.permitted(FeatureType.ENVIRONMENT_MANAGEMENT, UserRight.ENVIRONMENT_SAMPLE_VIEW)while the checkbox usesUiUtil.permitted(UserRight.ENVIRONMENT_VIEW). This may expose the toggle to users who shouldn’t see env samples or hide it for those who should. Please confirm the correct rights combo and align both places.If the stricter combo is desired, apply:
- if (UiUtil.permitted(UserRight.ENVIRONMENT_VIEW)) { + if (UiUtil.permitted(FeatureType.ENVIRONMENT_MANAGEMENT, UserRight.ENVIRONMENT_SAMPLE_VIEW)) {Also applies to: 242-246
158-159: Capacity pre-allocation bug: uses env size twice
new ArrayList<>(environmentSamples.size() + environmentSamples.size())should include human sample size to avoid over/under-allocation.- List<LeafletMarker> markers = new ArrayList<>(environmentSamples.size() + environmentSamples.size()); + List<LeafletMarker> markers = new ArrayList<>(humanSamples.size() + environmentSamples.size());
247-250: Minor: prefer null-safe, clearer value accessOptional readability tweak: use the checkbox value instead of the event property.
- showEnvironmentSamplesCheckBox.addValueChangeListener(e -> { - showEnvironmentalSamples = (boolean) e.getProperty().getValue(); + showEnvironmentSamplesCheckBox.addValueChangeListener(e -> { + showEnvironmentalSamples = showEnvironmentSamplesCheckBox.getValue(); refreshMap(true); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java(2 hunks)
🔇 Additional comments (2)
sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java (2)
64-65: Default OFF for environment samples — aligns with PR intentSetting
showEnvironmentalSamples = false(behind permission check) cleanly makes env samples OFF by default and decoupled from human sample toggles.
246-250: Checkbox now reflects its own state and directly updates flag — goodUsing
showEnvironmentalSamplesfor initial value and direct assignment in the listener cleanly decouples env from human toggles.
Fixes # [13593]
Summary
This pull request fixes the issue where environment samples are turned on when initially toggling case samples on the Map Dashboard. Now, the toggles for human samples (case, contact, event participant) and environment samples are fully independent.
Type of change
How to test
Checklist
Additional notes
N/A
Summary by CodeRabbit
Bug Fixes
New Features