Skip to content

feat: add support for class name generator for InlineDatePicker #92

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 7 commits into from
Mar 10, 2025

Conversation

javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Mar 7, 2025

Close #91

Summary by CodeRabbit

  • New Features
    • Calendar components now support dynamic styling, enabling custom visual cues for dates such as weekends and public holidays.
    • Month views update responsively in real time, ensuring that style changes are immediately reflected as the displayed month shifts.

@javier-godoy javier-godoy requested review from mlopezFC and paodb March 7, 2025 22:48
Copy link

coderabbitai bot commented Mar 7, 2025

Walkthrough

This pull request updates the project’s build configuration and several code components. The project version in pom.xml is incremented and the license plugin version is updated with an additional exclusion pattern. Multiple Java source files and tests have been updated with new functional enhancements, refactored logic for date styling in calendar components, and consistent copyright year modifications. Frontend JavaScript and CSS files show similar copyright updates and minor enhancements for styling and event handling.

Changes

Files Change Summary
pom.xml Updated project version from 4.3.2-SNAPSHOT to 4.4.0-SNAPSHOT; upgraded license-maven-plugin from 1.14 to 2.3.0 and added exclusion pattern **/main/dev-bundle/**.
src/main/java/com/flowingcode/addons/ycalendar/{AbstractCalendarComponent.java, DateSelectedEvent.java, YearChangedEvent.java, YearMonthField.java} Updated copyright statements (e.g., from ranges ending in 2023/2024 to 2025).
src/main/java/com/flowingcode/addons/ycalendar/{InlineDatePicker.java, MonthCalendar.java, YearCalendar.java} Enhanced calendar functionality: added new fields and public methods in InlineDatePicker, refactored refresh logic in MonthCalendar, streamlined styling logic with Optional in YearCalendar (including adding the corresponding import).
src/main/resources/META-INF/frontend/{fc-inline-date-picker/fc-inline-date-picker.js, fc-month-calendar/fc-month-calendar.js, month-calendar-mixin.js, fc-calendar-utils.js, fc-year-calendar/fc-year-calendar.js, fc-year-month-field/fc-year-month-field.js} In JavaScript files, updated copyright years; in fc-inline-date-picker.js, modified month change handling and added methods _setStyleForDay and _clearEmptyDaysStyle for day styling.
src/test/java/com/flowingcode/addons/ycalendar/{DemoView.java, InlineDatePickerDemo.java, LocaleSelector.java, MonthDemo.java, YearDemo.java, YearI18NDemo.java, YearMonthCalendarDemoView.java, YearMonthFieldDemo.java, YearReadonlyDemo.java, it/AbstractViewTest.java, it/ViewIT.java, test/SerializationTest.java, ../vaadin/addons/DemoLayout.java} Test and demo files: Updated copyright years; InlineDatePickerDemo.java adds a DayOfWeek import and class name generator logic; TestUtils.java includes new holiday dates.
src/test/resources/META-INF/frontend/styles/{test_year-month-calendar.css, ycalendar-styles.css} Updated copyright notices to extend protection through 2025.

Suggested reviewers

  • scardanzan
  • mlopezFC
  • paodb
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

sonarqubecloud bot commented Mar 7, 2025

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/addons/ycalendar/YearI18NDemo.java (1)

55-61: Demonstration of Class Name Generator Feature
Within the conditional block (using the //#if vaadin eq 0 directive), the demo sets a class name generator on the calendar component. This generator assigns the "weekend" class for Saturdays and Sundays, illustrating the new feature support. Ensure that usage of this generator (particularly its integration with the InlineDatePicker component) is documented and thoroughly tested in real-world scenarios.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a43cee9 and 9b07a69.

📒 Files selected for processing (30)
  • pom.xml (2 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/AbstractCalendarComponent.java (1 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/DateSelectedEvent.java (1 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java (5 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/MonthCalendar.java (4 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/YearCalendar.java (3 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/YearChangedEvent.java (1 hunks)
  • src/main/java/com/flowingcode/addons/ycalendar/YearMonthField.java (1 hunks)
  • src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js (2 hunks)
  • src/main/resources/META-INF/frontend/fc-month-calendar/fc-month-calendar.js (1 hunks)
  • src/main/resources/META-INF/frontend/fc-month-calendar/month-calendar-mixin.js (1 hunks)
  • src/main/resources/META-INF/frontend/fc-year-calendar/fc-calendar-utils.js (1 hunks)
  • src/main/resources/META-INF/frontend/fc-year-calendar/fc-year-calendar.js (1 hunks)
  • src/main/resources/META-INF/frontend/fc-year-month-field/fc-year-month-field.js (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/DemoView.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java (3 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/LocaleSelector.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/MonthDemo.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/TestUtils.java (2 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/YearDemo.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/YearI18NDemo.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/YearMonthCalendarDemoView.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/YearMonthFieldDemo.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/YearReadonlyDemo.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/it/AbstractViewTest.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/it/ViewIT.java (1 hunks)
  • src/test/java/com/flowingcode/addons/ycalendar/test/SerializationTest.java (1 hunks)
  • src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java (1 hunks)
  • src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css (1 hunks)
  • src/test/resources/META-INF/frontend/styles/ycalendar-styles.css (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-vaadin24
🔇 Additional comments (47)
src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css (1)

5-5: Consistent Copyright Update
The updated notice now correctly reflects the extended period ("2021 - 2025"). No functional changes were made in this CSS file, and the update is consistent with other files in the project.

src/main/resources/META-INF/frontend/fc-year-calendar/fc-year-calendar.js (1)

5-6: Metadata Update Confirmation
The copyright notice has been updated from "2021 - 2023" (or similar previous range) to "2021 - 2025", ensuring consistency across the project.

src/test/java/com/flowingcode/addons/ycalendar/YearI18NDemo.java (1)

1-6: Header Update Consistency
The copyright header is updated to "2021 - 2025", which aligns with the recent metadata updates across multiple files.

src/test/java/com/flowingcode/addons/ycalendar/it/ViewIT.java (1)

1-6: Consistent Copyright Notice Update
The header now reflects the updated copyright period ("2021 - 2025"). As this change is purely metadata, no further action is required.

src/test/java/com/flowingcode/addons/ycalendar/LocaleSelector.java (1)

1-6: Alignment of Copyright Metadata
The copyright notice in this file has been extended to "2021 - 2025", which maintains consistency with the overall project update.

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

5-5: Update Copyright Notice
The copyright line has been updated to "Copyright (C) 2021 - 2025 Flowing Code". This metadata change is consistent with other updates in the project and does not affect functionality.

src/test/java/com/flowingcode/addons/ycalendar/MonthDemo.java (1)

5-5: Update Copyright Notice
The copyright notice has been extended to 2025 to reflect the updated period.

src/main/resources/META-INF/frontend/fc-month-calendar/fc-month-calendar.js (1)

5-5: Maintain Consistent Copyright Update
The diff updates the copyright statement to "Copyright (C) 2021 - 2025 Flowing Code". No functional changes are introduced in this file.

src/test/java/com/flowingcode/addons/ycalendar/YearMonthCalendarDemoView.java (1)

5-5: Update Copyright Notice
The copyright range in the header has been updated to "2021 - 2025 Flowing Code". This is a straightforward metadata update that aligns with project-wide consistency.

src/main/resources/META-INF/frontend/fc-year-calendar/fc-calendar-utils.js (1)

5-5: Update Copyright Notice
The copyright header now reflects "Copyright (C) 2021 - 2025 Flowing Code". There is no impact on the functionality of the formatDate utility.

src/test/java/com/flowingcode/addons/ycalendar/test/SerializationTest.java (1)

5-5: Update Copyright Notice

The copyright header was updated to extend the year range to 2025. This is a metadata update only and does not impact the test or serialization functionality.

src/main/resources/META-INF/frontend/fc-year-month-field/fc-year-month-field.js (1)

5-5: Update Copyright Notice

The copyright comment now correctly reflects the extended period (2021 - 2025). This change is purely informational and does not affect the component functionality.

src/main/java/com/flowingcode/addons/ycalendar/DateSelectedEvent.java (1)

5-5: Update Copyright Notice

The change in the copyright header—from "2021 - 2023" to "2021 - 2025"—ensures consistency with the project's updated metadata. No functional aspects are impacted.

src/main/java/com/flowingcode/addons/ycalendar/YearChangedEvent.java (1)

5-5: Update Copyright Notice

The copyright notice has been updated to extend the range to 2025. This is a simple metadata update and does not affect the event logic or API.

src/main/resources/META-INF/frontend/fc-month-calendar/month-calendar-mixin.js (1)

5-5: Update Copyright Notice

The copyright information in the header now reflects "2021 - 2025". As with the other files, this is a metadata update that does not impact functionality or styling.

src/main/java/com/flowingcode/addons/ycalendar/YearMonthField.java (1)

5-5: Metadata Update – Copyright Header Change

The header now reflects "Copyright (C) 2021 - 2025 Flowing Code". This is a coordinated metadata refresh across the project and does not impact functionality.

src/test/java/com/flowingcode/addons/ycalendar/it/AbstractViewTest.java (1)

5-5: Metadata Update – Copyright Header Refresh

The updated header showing "2021 - 2025" ensures consistency with the project’s branding. This change is purely informational.

src/test/java/com/flowingcode/addons/ycalendar/YearReadonlyDemo.java (1)

5-5: Metadata Update – License Header Revision

The revision in the header to "Copyright (C) 2021 - 2025 Flowing Code" aligns with the project-wide update. No functionality is affected.

src/test/java/com/flowingcode/addons/ycalendar/YearMonthFieldDemo.java (1)

5-5: Metadata Update – Uniform Header Update

The license header in this file has been updated to "2021 - 2025", matching the rest of the project. This is a non-functional update.

src/main/java/com/flowingcode/addons/ycalendar/AbstractCalendarComponent.java (1)

5-5: Metadata Update – Revised Copyright Notice

The header now presents "Copyright (C) 2021 - 2025 Flowing Code". This update is consistent across multiple files and does not introduce any changes to functionality.

src/test/java/com/flowingcode/addons/ycalendar/YearDemo.java (1)

5-5: Copyright year updated appropriately.

The copyright year has been extended to 2025, which aligns with the project's ongoing development and maintenance.

src/test/java/com/flowingcode/addons/ycalendar/DemoView.java (1)

5-5: Copyright year updated correctly.

The copyright notice has been extended to include 2025, consistent with the project's active development.

src/test/resources/META-INF/frontend/styles/ycalendar-styles.css (1)

5-5: Copyright year updated appropriately.

The copyright year range has been extended to 2025, maintaining consistency with other files in the project.

src/test/java/com/flowingcode/addons/ycalendar/TestUtils.java (2)

5-5: Copyright year updated correctly.

The copyright notice has been extended to include 2025, consistent with other files in the project.


70-74: Holiday dates for 2025 added appropriately.

Five new holiday dates for 2025 have been added to the HOLIDAYS set, ensuring the calendar will properly display holidays for the upcoming year. This proactively maintains the utility's functionality for future dates.

pom.xml (3)

7-7: Version increment aligns with semantic versioning

The version increase from 4.3.2-SNAPSHOT to 4.4.0-SNAPSHOT follows semantic versioning principles, correctly indicating a minor version bump for the new feature being added (class name generator for InlineDatePicker).


210-210: Added exclusion pattern for generated files

Adding "/main/dev-bundle/" to the exclusion patterns for the license plugin prevents it from adding license headers to generated files in the dev-bundle directory, which is appropriate since these files are machine-generated.


204-204:

✅ Verification successful

Updated license-maven-plugin to a newer version

The license-maven-plugin has been updated from version 1.14 to 2.3.0, which is a significant version jump. This update likely provides bug fixes and new features for license management.


🏁 Script executed:

#!/bin/bash
# Check release dates and release notes for license-maven-plugin versions
curl -s "https://search.maven.org/solrsearch/select?q=g:org.codehaus.mojo+AND+a:license-maven-plugin+AND+v:2.3.0&rows=20&wt=json" | jq '.response.docs[0]'

Length of output: 628


License Maven Plugin Update Verified

  • The updated version in pom.xml is now <version>2.3.0</version>, confirming the switch from 1.14 to 2.3.0.
  • The Maven Central query indicates that version 2.3.0 is valid and available, suggesting added bug fixes and features for improved license management.
src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java (3)

5-5: Updated copyright year

The copyright year has been updated to include 2025, maintaining compliance with intellectual property requirements.


27-27: Added import for DayOfWeek enum

Added necessary import for the DayOfWeek enum which is used in the new class name generator implementation.


46-54: Implemented class name generator for InlineDatePicker

The implementation adds visual distinction for weekends and holidays in the calendar by assigning specific CSS class names. This directly addresses the feature requested in issue #91.

The class name generator follows a clear, logical pattern:

  • "weekend" for Saturdays and Sundays
  • "holiday" for public holidays (as determined by TestUtils.isPublicHoliday)
  • null for regular weekdays

This approach provides good customization flexibility while maintaining clear semantics.

src/main/java/com/flowingcode/addons/ycalendar/YearCalendar.java (3)

5-5: Updated copyright year

The copyright year has been updated to include 2025, maintaining compliance with intellectual property requirements.


33-33: Added import for Optional class

Added necessary import for the java.util.Optional class which is used in the refactored refreshItem method.


98-99: Refactored className generation using Optional

The code has been refactored to use Optional.ofNullable instead of a conditional check, making it more concise and readable while maintaining the same functionality.

This functional programming approach reduces the risk of null pointer exceptions and follows modern Java best practices. The change also maintains consistency with similar implementations in other calendar components.

src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js (3)

5-5: Updated copyright year

The copyright year has been updated to include 2025, maintaining compliance with intellectual property requirements.


94-96: Enhanced month change handler with event dispatching

The __onDisplayMonthChange method has been improved to:

  1. Store the yearMonth value in a variable for better clarity
  2. Dispatch a "month-change" event with the yearMonth value

This change enables the Java InlineDatePicker component to track the currently displayed month, which is essential for the class name generator functionality when refreshing calendar items.


103-109: Added day styling methods to support class name generator

Two new methods have been added that delegate to the underlying month calendar component:

  • _setStyleForDay: Applies a CSS class to a specific day
  • _clearEmptyDaysStyle: Removes styling from empty days

These methods are crucial for implementing the class name generator functionality, allowing the InlineDatePicker to apply custom styling to specific dates (weekends, holidays, etc.).

src/main/java/com/flowingcode/addons/ycalendar/MonthCalendar.java (3)

5-5: Updated copyright year.

Copyright year has been extended to 2025.


125-127: Improved code with stream operations.

The refactoring of the refreshAll method using streams is a good improvement that simplifies the code and makes it more maintainable. This approach is more concise than the previous implementation using a loop.


139-143: Improved null handling with Optional.

Using Optional.ofNullable is a clean approach to handle potential null values from the class name generator. This simplifies the code while maintaining the same functionality.

src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java (7)

47-49: Added fields to support class name generation.

New private fields classNameGenerator and yearMonth provide the foundation for the class name generation feature, allowing customized styling of calendar days.


60-62: Added event listener to track month changes.

The month-change event listener ensures the component's internal state stays synchronized with the UI, which is essential for correctly applying styles when the user navigates between months.


106-109: Added class name generator API.

The setClassNameGenerator method provides a clean API for setting custom styling logic, following the same pattern used in other Vaadin components. The immediate call to refreshAll() ensures styles are applied without requiring additional user action.


112-117: Implemented style refresh functionality.

The refreshAll method efficiently updates styles for all days in the current month using a stream operation, maintaining consistency with the implementation in MonthCalendar.


124-131: Added item-specific refresh method.

The refreshItem method allows for targeted style updates of individual dates, with proper validation to ensure the date belongs to the current month and year. Using Optional for handling potentially null class name generators is a good practice.


133-138: Enhanced setValue to maintain state consistency.

The overridden setValue method ensures that the yearMonth field is updated when a new date is set, maintaining consistency between the selected date and the displayed month. The null check adds robustness.


140-146: Added helper method for month updates.

The private setYearMonth method centralizes the logic for updating the month state and refreshing the display, with an optimization to avoid unnecessary refreshes when the month hasn't changed.

Copy link
Member

@paodb paodb left a comment

Choose a reason for hiding this comment

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

LGTM

@paodb paodb merged commit a4c41d3 into master Mar 10, 2025
4 checks passed
@paodb paodb deleted the feat-inlineDatePicker-styles branch March 10, 2025 12:10
@github-project-automation github-project-automation bot moved this from In Progress to Pending release in Flowing Code Addons Mar 10, 2025
@paodb paodb moved this from Pending release to Done in Flowing Code Addons Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Add support for class name generator for InlineDatePicker
2 participants