<% content_for :title, "Site Settings" %>

<h1><%= current_page?(global_settings_path) ? 'Global' : '' %> Site Settings</h1>
<p>
  The settings on this page control various aspects of the display or operation of the site. Change these
  rarely and with care. Bear in mind that setting changes will generally not be retroactive - so if you change
  the reputation values, they will only apply going forward - users' reputation will not be recalculated automatically.
</p>

<p>Click on a setting's value to edit it.</p>

<% @settings.each do |category, settings| %>
  <details>
    <summary><%= category&.underscore&.humanize || 'Uncategorized' %></summary>
    <table class="table">
      <tbody>
        <% settings.each do |setting| %>
          <tr>
            <td>
              <h4>
                <%= setting.name %>
                <% if setting.community_id.nil? %>
                  <span class="badge is-tag is-master-tag">global</span>
                <% else %>
                  <span class="badge is-tag">site</span>
                <% end %>
                <span class="badge is-tag"><%= setting.value_type %></span>
              </h4>
              <div class="form-caption"><%= setting.description %></div>
            </td>
            <td class="site-setting--value js-setting-value" data-type="<%= setting.value_type %>" data-name="<%= setting.name %>"
                data-community-id="<%= current_page?(global_settings_path) ? nil : RequestContext.community_id %>">
              <%= setting.typed %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </details>
<% end %>
