Skip to content
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

HP-2387: refactor DateTimePicker #187

Merged
merged 3 commits into from
Mar 28, 2025
Merged

HP-2387: refactor DateTimePicker #187

merged 3 commits into from
Mar 28, 2025

Conversation

tafid
Copy link
Member

@tafid tafid commented Mar 25, 2025

Summary by CodeRabbit

  • New Features

    • Updated date and time input fields for a more consistent display format and streamlined options. Users will now see dates formatted uniformly, with selection restricted to the current day. Labels for date range pickers have been removed, replaced with contextual placeholders for better user guidance.
  • Tests

    • Revised test criteria by simplifying part number values for improved consistency with product naming.

Copy link

coderabbitai bot commented Mar 25, 2025

Walkthrough

This change updates multiple DateTimePicker widget configurations across various views. The modifications adjust option keys and values—switching from 'format' to 'dateFormat' and changing the format string, as well as removing the todayBtn option and replacing other options with maxDate in sell modals. Additionally, the part number in an end-to-end test has been simplified by removing a prefix.

Changes

File(s) Change Summary
src/views/order/_form.php Updated DateTimePicker key from 'format' to 'dateFormat' and changed the date format string from 'yyyy-mm-dd hh:ii' to 'Y-m-d H:i'.
src/views/part/modals/sell-by-plan.php
src/views/part/modals/sell.php
Removed the todayBtn option. In sell.php, replaced endDate and todayBtn with the maxDate option to adjust date selection constraints.
tests/playwright/e2e/manager/part/part-create.spec.ts Updated the partno field value from 'CHASSIS EPYC 7402P' to 'EPYC 7402P'.
src/views/order/_search.php Removed label elements for date range pickers and added placeholder attributes for "Time" and "Profit period" fields.

Possibly related PRs

Suggested reviewers

  • hiqsol
  • VadymHrechukha

Poem

I'm a rabbit, quick on my feet,
Celebrating changes that are really neat.
Date pickers now show a lighter style,
With options refined all the while.
Hop along with code so bright—
A rootin' tootin' update delight!
🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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: 1

🧹 Nitpick comments (2)
src/views/order/_search.php (2)

58-58: Consider accessibility implications of using only placeholders without labels.

While adding a placeholder for "Time" improves user experience, relying solely on placeholders without explicit labels can reduce accessibility for screen readers and other assistive technologies. Placeholders disappear when users start typing, which may also impact usability for all users.

Consider maintaining both the label and placeholder for maximum accessibility:

<div class="form-group">
+    <label for="time-range"><?= Yii::t('hipanel', 'Time') ?></label>
    <?= DateRangePicker::widget([
        'model' => $search->model,
        'attribute' => 'time_from',
        'attribute2' => 'time_till',
        'options' => [
            'class' => 'form-control',
+           'id' => 'time-range',
            'placeholder' => Yii::t('hipanel', 'Time'),
        ],
        'dateFormat' => 'yyyy-mm-dd',
    ]) ?>
</div>

74-74: Consider accessibility implications of using only placeholders without labels.

Similar to the "Time" field above, using only placeholders without explicit labels for the "Profit period" field may reduce accessibility. Additionally, ensure the translation category 'hipanel:stock' is consistent with other translations in the stock module.

Consider maintaining both the label and placeholder:

<div class="form-group">
+    <label for="profit-period-range"><?= Yii::t('hipanel:stock', 'Profit period') ?></label>
    <?= DateRangePicker::widget([
        'model' => $search->model,
        'attribute' => 'profit_time_from',
        'attribute2' => 'profit_time_till',
        'options' => [
            'class' => 'form-control',
+           'id' => 'profit-period-range',
            'placeholder' => Yii::t('hipanel:stock', 'Profit period'),
        ],
        'dateFormat' => 'yyyy-mm-dd',
    ]) ?>
</div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 896a9a0 and 89c3308.

📒 Files selected for processing (1)
  • src/views/order/_search.php (2 hunks)

Comment on lines 60 to 61
'dateFormat' => 'yyyy-mm-dd',
]) ?>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify DateRangePicker configuration consistency.

The dateFormat setting appears to be aligned with the DateTimePicker widget changes mentioned in the PR summary. Ensure that this format is consistent with other date-related widgets across the application and that it meets the requirements for displaying and parsing dates correctly.

Also applies to: 76-77


🏁 Script executed:

#!/bin/bash
# Search for other DateRangePicker/DateTimePicker usages to verify consistency
echo "Checking DateRangePicker/DateTimePicker usage patterns across the codebase:"
rg --type php "DateRangePicker::widget\(\[|DateTimePicker::widget\(\[" -A 10 -B 2 | grep -E "dateFormat|format"

Length of output: 698


Action: Resolve Date/Time Format Inconsistency

It appears there’s an inconsistency in how date formats are defined across similar widgets:

  • In src/views/move/_search.php, the widget uses 'dateFormat' => 'yyyy-MM-dd' (note the capital "MM").
  • In src/views/order/_search.php (lines 60–61), the new change sets 'dateFormat' => 'yyyy-mm-dd' (with lowercase "mm").
  • In src/views/part/_search.php, both variations appear—with one instance using the key 'format' and others using 'dateFormat', mixing formats.

Please verify whether the intended standard is to use the uppercase "MM" (commonly used for months) or the lowercase "mm". Then, update all date-related widget configurations to use a consistent format that aligns with both display and parsing requirements.

@SilverFire SilverFire merged commit b50a904 into hiqdev:master Mar 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants