预订操作按钮:调整激活状态前后的勾选标记逻辑需求
I get what you're trying to achieve here - instead of every disabled button having a checkmark, you only want the ones that come before the currently active (clickable) action to show the checkmark, and any disabled actions after that should not. Since this is a Smarty template, we can add a simple tracking variable to handle this logic cleanly.
Here's how to modify your existing code:
<div class="card card"> <div class="card-title card-white-title">Booking Actions</div> <div class="card-body"> {* Initialize a variable to track if we've found the first active action *} {assign var="found_active" value=false} {foreach from=$booking_actions item=action} {* Update tracker when we hit the active (enabled) action *} {if $action.enabled == true} {assign var="found_active" value=true} {/if} <button data-price="{$booking.est_price}" value="{$booking.reference}" id="{$action.integra_status}" class="btn btn-booking-control {$action.integra_action}{if $action.enabled == false} disabled action-disabled-btn{else} btn-success{/if}{if $action.show_on_portal == 'NO'} hidden{/if}" {if $action.enabled != false}onclick="javascript:performButtonAction('{$action.integra_action}', '{$action.integra_status}', '{$booking.reference}', '{$action.stop_ref}',this)"{/if}> {$action.description} {$action.applies_to_desc} {* Only show checkmark for disabled actions BEFORE the active one *} {if $action.enabled == false && $found_active == false} <div class="pull-right"><div class="fas fa-check"/></div> {/if} </button> {/foreach} </div> </div>
Key Changes Breakdown:
- Tracking Variable: We added
{assign var="found_active" value=false}right before the loop to keep tabs on whether we've encountered the active (clickable) action yet. - Update Tracker: Inside the loop, as soon as we hit an enabled action, we flip
$found_activetotrue- this marks the "cutoff point" for checkmarks. - Conditional Checkmark: Instead of showing the checkmark for all disabled buttons, we now only display it if two conditions are met:
- The button is disabled (
$action.enabled == false) - We haven't reached the active action yet (
$found_active == false)
- The button is disabled (
This setup ensures only completed/disabled actions before the current active step get the checkmark, while any disabled steps after the active one stay unmarked - exactly the behavior you wanted.
内容的提问来源于stack exchange,提问作者Nick Coleby
相关产品推荐
相关产品推荐

