Skip to content

Conversation

@Jayapraksh1234
Copy link

@Jayapraksh1234 Jayapraksh1234 commented Sep 11, 2025

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.

  • Environment samples are OFF by default.
  • Toggling the case samples checkbox does NOT affect the environment samples checkbox.
  • The environment samples checkbox reflects its own toggle state and only enables/disables environment samples.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update

How to test

  1. Go to the Sample Dashboard Map.
  2. Toggle the Case Samples checkbox – only human samples should be affected.
  3. Toggle the Environment Samples checkbox – only environment samples should be affected.
  4. Confirm that toggling one does not automatically toggle the other.

Checklist

  • I have read the Contributing guidelines.
  • I have tested my changes.
  • I have added necessary documentation (if applicable).
  • I have linked the related issue.

Additional notes

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Environment samples toggle now correctly reflects its current state on load.
    • Toggling environment samples consistently updates the map.
  • New Features

    • Environment samples are now turned off by default for users with relevant permissions, reducing initial map clutter and improving readability.

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.
@coderabbitai
Copy link

coderabbitai bot commented Sep 11, 2025

Walkthrough

The 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

Cohort / File(s) Change Summary
Sample dashboard map behavior
sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java
Initialize showEnvironmentalSamples to false under permission check; checkbox initial value bound to showEnvironmentalSamples instead of shouldShowEventParticipantSamples(); simplify listener to direct assignment; refresh remains triggered on change.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (1 passed, 1 warning, 1 inconclusive)

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The current title "Jayapraksh1234 patch 1" is a generic, autogenerated label that does not describe the changes in this PR; the changes actually make the environment-samples toggle on the Sample Dashboard Map independent from human sample toggles and default environment samples to OFF. Because the title is non-descriptive, a teammate scanning history would not understand the primary change. This makes the title inconclusive for review purposes. Replace the title with a concise descriptive sentence such as "Sample Dashboard Map: make environment samples toggle independent and default to OFF" or "Make environment samples toggle independent (off by default) on Sample Dashboard Map" so the main change is immediately clear.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description follows the repository template and includes the Fixes reference, a clear summary of the bugfix, the type of change, step-by-step testing instructions, a checklist, and additional notes; these items align with the PR objectives to make environment samples independent and off by default on the Sample Dashboard Map. The description is actionable for reviewers and QA and contains the required information from the template. Therefore the description is complete and acceptable.

Poem

A checkbox hops from true to false—surprise!
The map now waits with quieter skies.
One toggle click, the markers bloom,
Then fade again, make tidy room.
I twitch my ears at cleaner states—
Less fuss, more hops, and snappier updates. 🐇🗺️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The pull request title "Jayapraksh1234 patch 1" is a generic placeholder-style title that does not convey meaningful information about the changeset. While it is not unrelated to the actual changes, it uses a username and a vague "patch 1" label that fails to clearly summarize what the pull request addresses. A teammate scanning the git history would have no insight into what this change accomplishes without reviewing the full description or code. The title does not satisfy the requirement to be "clear and specific enough that a teammate scanning history understands the primary change."
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description is comprehensive and well-structured, covering all essential elements required by the template. It includes the issue reference (Fixes #13593), a clear summary explaining the bugfix and expected behavior changes, explicitly identifies the change type as a bugfix, provides specific testing instructions with numbered steps, and completes the checklist with all items marked. The description clearly articulates the problem being solved and how to verify the fix, making it easy for reviewers to understand the intent and scope of the changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 shown

Early return suppresses the legend even if showEnvironmentalSamples is 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 gating

Init uses UiUtil.permitted(FeatureType.ENVIRONMENT_MANAGEMENT, UserRight.ENVIRONMENT_SAMPLE_VIEW) while the checkbox uses UiUtil.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 access

Optional 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

📥 Commits

Reviewing files that changed from the base of the PR and between 75e5985 and 602b579.

📒 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 intent

Setting 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 — good

Using showEnvironmentalSamples for initial value and direct assignment in the listener cleanly decouples env from human toggles.

@raulbob raulbob self-assigned this Oct 28, 2025
@raulbob raulbob added the bug An error or misbehavior of an existing feature (ticket type) label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An error or misbehavior of an existing feature (ticket type)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map Dashboard - environment samples turn on when initially turning on case samples

2 participants