-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(ZMS-3420): Update condition to display main content only when at least #713
feat(ZMS-3420): Update condition to display main content only when at least #713
Conversation
…one button is enabled across multiple scopes
WalkthroughThe changes to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
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: 1
🧹 Outside diff range and nitpick comments (1)
zmsticketprinter/templates/page/customized/default.twig (1)
12-22
: LGTM! Consider extracting scope collection logicThe initialization and scope collection logic is well-implemented. The code effectively tracks unique scopes and button states, which aligns with the PR objective.
Consider extracting the scope collection logic into a separate included template file for better maintainability, especially if this pattern is used elsewhere:
{# _collect_scopes.twig #} {% set scopes = [] %} {% set allButtonsDisabled = true %} {% for button in ticketprinter.buttons %} {% if button.scope.id not in scopes %} {% set scopes = scopes|merge([button.scope.id]) %} {% endif %} {% if button.enabled %} {% set allButtonsDisabled = false %} {% endif %} {% endfor %} {% set number_of_scopes = scopes|length %}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
zmsticketprinter/templates/page/customized/default.twig
(1 hunks)
🔇 Additional comments (3)
zmsticketprinter/templates/page/customized/default.twig (3)
55-57
: LGTM! Clean notification block implementation
The notification block implementation correctly checks department preferences before rendering.
29-29
: Verify the usage of buttonLabelPrefix
The variable buttonLabelPrefix
is set but its usage isn't visible in this context.
✅ Verification successful
buttonLabelPrefix
is properly used in button labels across templates
The variable buttonLabelPrefix
is used in templates/block/content/buttons.twig
to construct button labels by concatenating it with button names. It's used in three places:
- For the first button when there's a single button:
{% set label = buttonLabelPrefix ~ ticketprinter.buttons|first.name %}
- For multiple buttons in two different contexts:
{% set label = buttonLabelPrefix ~ button.name %}
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usage of buttonLabelPrefix
rg "buttonLabelPrefix" --type=twig -A 5
Length of output: 4214
24-24
: Verify the complex display condition
The condition combines multiple checks which might be difficult to maintain. Please ensure all edge cases are covered:
- Single scope with all buttons enabled
- Single scope with mixed button states
- Multiple scopes with all buttons disabled
- Multiple scopes with mixed button states
✅ Verification successful
Let's examine the actual implementation of these conditions to better understand the logic.
Based on the code analysis, I can now generate the final response:
The complex display condition is correctly implemented
The condition (enabled and not hasDisabledButton) or (number_of_scopes > 1 and not allButtonsDisabled)
is well-structured and handles all edge cases:
- For single scope (
number_of_scopes <= 1
): Shows content only ifenabled
is true and no buttons are disabled - For multiple scopes (
number_of_scopes > 1
): Shows content if at least one button is enabled (not allButtonsDisabled
)
The implementation in TicketprinterByScope.php
and Index.php
correctly sets these flags by checking button states, and the template properly calculates allButtonsDisabled
by iterating through all buttons. The logic effectively covers all the mentioned scenarios.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for test cases covering these scenarios
rg -l "buttonDisplay.*button_single|hasDisabledButton|allButtonsDisabled" --type=php --type=twig
Length of output: 492
Script:
#!/bin/bash
# Check the implementation in PHP files
rg "hasDisabledButton|allButtonsDisabled" -A 5 --type=php
# Check template usage patterns
rg "hasDisabledButton|allButtonsDisabled" -A 5 --type=twig
# Look for test cases
rg "test.*button.*disabled|test.*scope" --type=php
Length of output: 6566
<div style="font-size: 60px; | ||
text-align: center; | ||
padding: 10px; | ||
border-radius: 5px; | ||
font-weight: bold; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: 100%; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
">Kundenservice ist geschlossen</div> |
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.
🛠️ Refactor suggestion
Move inline styles to CSS file
The inline styles for the closed message should be moved to a CSS file for better maintainability and separation of concerns. Consider using a class instead.
-<div style="font-size: 60px;
- text-align: center;
- padding: 10px;
- border-radius: 5px;
- font-weight: bold;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- overflow: hidden;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- ">Kundenservice ist geschlossen</div>
+<div class="service-closed-message">Kundenservice ist geschlossen</div>
Add to your CSS file:
.service-closed-message {
font-size: 60px;
text-align: center;
padding: 10px;
border-radius: 5px;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
box-sizing: border-box;
overflow: hidden;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
…one button is enabled across multiple scopes
Description
Short description or comments
Reference
Issues #XXX
Summary by CodeRabbit