<%= content_tag('tr', :id => dom_id(metric), :class => metric.child? ? 'child' : 'root') do %>
  <td class="title"><%= h metric.friendly_name %></td>
    <% if @plan.pricing_enabled? %>
    <td class="metrics-subtable-toggle pricing">
      <%= link_to polymorphic_path([:admin, @plan, metric, :pricing_rules]), :class => 'action remote' do %>
        <%= icon('money')  %>
        Pricing (<span id="pricing_rules_counter_<%= metric.id %>"><%= @plan.pricing_rules.of_metric(metric).size %></span>)
      <% end %>
    </td>
    <% end %>

  <td class="metrics-subtable-toggle limits">
    <%= link_to polymorphic_path([:admin, @plan, metric, :usage_limits]), :class => 'action remote', title: "Edit limits of #{metric.friendly_name}" do %>
      <%= icon('signal')  %>
      Limits (<span id="limits_counter_<%= metric.id %>"><%= @plan.usage_limits.of_metric(metric).size %></span>)
    <% end %>
  </td>

  <td></td>

<td>
  <span id="<%= dom_id(metric) %>_status" class="<%= @plan.metric_enabled?(metric) ? 'enabled' : 'disabled' %>">
    <%= fancy_button_to @plan.metric_enabled?(metric) ?
                          image_tag('tick.png', :alt => "Metric is enabled for this plan") :
                          image_tag('cross.png', :alt => "Metric is disabled for this plan"),
                      polymorphic_path([:toggle_enabled, :admin, @plan, metric]),
                      :method => :put, :remote => true, title: "#{@plan.metric_enabled?(metric) ? 'Disable' : 'Enable'} metric #{metric.friendly_name}" -%>
  </span>
</td>
<td>
  <span id="<%= dom_id(metric) %>_visible" class="<%= @plan.metric_visible?(metric) ? 'visible' : 'hidden' %>">
    <%= fancy_button_to @plan.metric_visible?(metric) ?
                          image_tag('tick.png', :alt => "Metric is visible for this plan") :
                          image_tag('cross.png', :alt => "Metric is disabled hidden for this plan"),
                      polymorphic_path([:toggle_visible, :admin, @plan, metric]),
                      :method => :put, :remote => true, title: "Make metric #{metric.friendly_name} #{@plan.metric_visible?(metric) ? 'invisible' : 'visible'}" -%>
  </span>
</td>
<td>
  <span id="<%= dom_id(metric) %>_icons" class="<%= @plan.limits_only_text?(metric) ? 'text' : 'icon' %>">
    <%= fancy_button_to @plan.limits_only_text?(metric) ?
                          image_tag('tick.png', :alt => "Metric limits will be shown with icons and text", title: "Make metric #{metric.friendly_name} be shown with icons and text") :
                          image_tag('cross.png', :alt => "Metric limits will be shown with text only", title: "Make metric #{metric.friendly_name} be shown with text only"),
                      polymorphic_path([:toggle_limits_only_text, :admin, @plan, metric]),
                      :method => :put, :remote => true -%>
  </span>
</td>
<td class="operations" <%= @plan.pricing_enabled? ? "" : "colspan='2'"  %>
</td>
<% end %>
