Skip to content

Add support to make an item "hybrid" #86

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

Merged
merged 2 commits into from
May 16, 2025
Merged

Add support to make an item "hybrid" #86

merged 2 commits into from
May 16, 2025

Conversation

paodb
Copy link
Member

@paodb paodb commented May 16, 2025

When an item its set to "hybrid", the item's descendant children will be arranged vertically.

Close #85.

When testing this feature with drag and drop enabled, the no background style, was being ignore after the first drag. I move the rule to the stylesheet of the component to avoid this.

Summary by CodeRabbit

  • New Features

    • Added support for marking organization chart nodes as "hybrid," enabling vertical arrangement of their descendant nodes.
    • Introduced a new demo showcasing the hybrid node feature and custom data properties in the organization chart.
  • Style

    • Updated styles to ensure the organization chart background image is consistently removed.
  • Documentation

    • Updated demo titles and included the new hybrid node demo in the demo view.

paodb added 2 commits May 16, 2025 10:17
When testing new feature "hybrid" with dnd, the style for no background was being ignored. Moving it to the stylesheet makes it not visible even when doing dnd as expected.
@paodb paodb requested review from javier-godoy and mlopezFC May 16, 2025 13:29
Copy link

coderabbitai bot commented May 16, 2025

Walkthrough

This change introduces hybrid node support to the organizational chart component by adding a hybrid property to OrgChartItem, updating serialization, and providing a new demo showcasing hybrid functionality. Related CSS and JavaScript handling for background images are refactored, and the demo registry is updated to include the new example.

Changes

Files/Paths Change Summary
pom.xml Updated orgchart-addon version from 5.1.1-SNAPSHOT to 5.2.0-SNAPSHOT.
src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChartItem.java Added hybrid boolean field with getter and setter (with JSON property annotation) to support hybrid nodes.
src/main/resources/META-INF/frontend/fc-orgchart.js Removed explicit setting of background-image: none from the component's shadow DOM via JavaScript.
src/main/resources/META-INF/resources/frontend/fc-orgchart-styles.css Added CSS rule to set .orgchart { background-image: none; }.
src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridDataPropertyDemo.java Added new demo class to showcase hybrid node functionality, including custom node templates and hierarchical structure.
src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridEnhancedChartDemo.java Updated the chart title string to clarify the hybrid chart demo purpose.
src/test/java/com/flowingcode/vaadin/addons/orgchart/OrgchartDemoView.java Registered the new HybridDataPropertyDemo class in the demo view's constructor.

Assessment against linked issues

Objective Addressed Explanation
Add OrgChart hybrid functionality allowing vertical child node orientation for specific nodes (#85)
Support setting hybrid property via node data attribute and demonstrate via example (#85)
Provide demo for hybrid functionality using the new hybrid property (#85)

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (1)
src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridDataPropertyDemo.java (1)

72-72: Fix typo in email address.

There's a small typo in the email address for Charles Thomas.

-    item6.setData("mail", "ctomas@example.com");
+    item6.setData("mail", "cthomas@example.com");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 945b6cc and fd1ebc0.

📒 Files selected for processing (7)
  • pom.xml (1 hunks)
  • src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChartItem.java (3 hunks)
  • src/main/resources/META-INF/frontend/fc-orgchart.js (0 hunks)
  • src/main/resources/META-INF/resources/frontend/fc-orgchart-styles.css (1 hunks)
  • src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridDataPropertyDemo.java (1 hunks)
  • src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridEnhancedChartDemo.java (1 hunks)
  • src/test/java/com/flowingcode/vaadin/addons/orgchart/OrgchartDemoView.java (1 hunks)
💤 Files with no reviewable changes (1)
  • src/main/resources/META-INF/frontend/fc-orgchart.js
🔇 Additional comments (12)
src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChartItem.java (3)

31-31: Added Jackson annotation import for JSON property handling.

The import for JsonProperty annotation is correctly added to support the serialization mapping in the new hybrid property.


49-49: New hybrid property added.

The boolean field is appropriately defined for storing the hybrid state of an item.


136-158: Well-documented hybrid property methods.

The implementation of the getter and setter methods for the hybrid property is clean and follows Java Bean conventions. The JavaDoc is thorough and clearly explains the purpose and behavior of the hybrid property.

The @JsonProperty("isHybrid") annotation ensures proper JSON serialization naming, which is important for JavaScript interoperability.

pom.xml (1)

5-5: Appropriate version bump for new feature.

Increasing the minor version from 5.1.1-SNAPSHOT to 5.2.0-SNAPSHOT is appropriate for adding the new hybrid node feature.

src/main/resources/META-INF/resources/frontend/fc-orgchart-styles.css (1)

30-32: Fixed background styling issue.

Adding this CSS rule to explicitly set background-image: none for the .orgchart class addresses the issue mentioned in the PR objectives where the "no background" style was being ignored after drag operations. Moving this style to the component's stylesheet ensures consistent styling behavior.

src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridEnhancedChartDemo.java (1)

67-67: Updated chart title for clarity.

The title has been updated to clarify that this example demonstrates the vertical level property approach to hybrid charts, distinguishing it from the new hybrid data property approach.

src/test/java/com/flowingcode/vaadin/addons/orgchart/OrgchartDemoView.java (1)

43-43: LGTM! Demo registration added correctly.

The new HybridDataPropertyDemo class is properly registered in the demo view, following the established pattern of the existing demo registrations.

src/test/java/com/flowingcode/vaadin/addons/orgchart/HybridDataPropertyDemo.java (5)

30-34: LGTM! Class structure and annotations look good.

The class is properly annotated with @PageTitle, @DemoSource, and @Route annotations, consistent with other demo classes in the codebase.


38-42: LGTM! Well-structured node template with conditional rendering.

The node template nicely demonstrates the ability to conditionally display additional information (email) when present in the node's data.


46-46: Clarify the purpose of setChartNodeContent("title").

You're setting the chart node content to "title" while also using a custom template that displays more than just the title. Consider adding a comment explaining the relationship between these two approaches, or whether this call is necessary given the custom template usage.


59-61: LGTM! Clear demonstration of hybrid property.

Good use of descriptive comments to highlight where the hybrid property is being set, making the demo's purpose clear.


74-76: LGTM! Second hybrid node clearly indicated.

The second demonstration of the hybrid property is well-commented, helping users understand where to look for the feature implementation.

@javier-godoy javier-godoy merged commit 26fd12f into master May 16, 2025
6 checks passed
@javier-godoy javier-godoy moved this from To Do to Pending release in Flowing Code Addons May 19, 2025
@javier-godoy javier-godoy deleted the issue-85 branch May 19, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending release
Development

Successfully merging this pull request may close these issues.

add OrgChart hybrid functionality
2 participants