You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

预订操作按钮:调整激活状态前后的勾选标记逻辑需求

Solution for Conditional Checkmarks on Booking Action Buttons

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_active to true - 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:
    1. The button is disabled ($action.enabled == false)
    2. We haven't reached the active action yet ($found_active == false)

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:21:20