tabletop-companion/app/views/stats/_stat.html.erb

28 lines
1.1 KiB
Plaintext

<div class="stat" id="<%= dom_id(stat) %>">
<% if @editable %>
<div class="feature-edit-buttons">
<%= icon_link_to("cod-triangle_left", reorder_down_character_sheet_feature_path(stat),
data: { turbo_method: :patch }) %>
<%= icon_link_to("md-delete", stat,
data: { turbo_method: :delete, turbo_confirm: t(".confirm_delete", name: stat.name) }) %>
<%= icon_link_to("cod-triangle_right", reorder_up_character_sheet_feature_path(stat),
data: { turbo_method: :patch }) %>
</div>
<% end %>
<h6><%= stat.name %></h6>
<% if @editable %>
<%= form_with model: stat, class: "stat-form", data: { controller: "auto-update" } do |f| %>
<%= hidden_field_tag :editable, value: true %>
<%= f.number_field :value %>
<% end %>
<% else %>
<%= link_to stat, data: { turbo_frame: :modal } do %>
<div class="stat-value">
<%= stat.value %>
<div class="stat-min-value"><%= stat.min_allowed %></div>
<div class="stat-max-value"><%= stat.max_allowed %></div>
</div>
<% end %>
<% end %>
</div>