<div class="form-group col-xs-8">
  <%= f.label(:title, _('Title'), class: "control-label") %>
  <%= f.text_field(:title, class: "form-control", "aria-required": true) %>
</div>

<div class="form-group col-xs-8" data-toggle="tooltip" title="<%= _('Enter a description that helps you to differentiate between templates e.g. if you have ones for different audiences') %>">
  <%= f.label(:description, _('Description'), class: "control-label") %>
  <%= f.text_area(:description, class: "template") %>
</div>

<% if current_user.org.funder? && !current_user.org.funder_only? %>
  <!-- If the Org is a funder and another org type then allow then to set the visibility -->
  <div class="form-group col-xs-8">
    <%= f.label _('Visibility'), class: 'control-label' %>
    <%= render partial: 'shared/popover',
               locals: { message: _('Checking this box prevents the template from appearing in the public list of templates.'),
                         placement: 'right' }%>
    <div class="checkbox">
      <%= f.label(:visibility) do %>
        <%= check_box_tag('template_visibility', '0',
                            (f.object.visibility == 'organisationally_visible')) %>

        <%= _('for internal %{org_name} use only') % { org_name: f.object.org.name } %>
      <% end %>
    </div>
  </div>
<% end %>

<div class="form-group col-xs-8">
  <%= label_tag(:status, _('Status'), class: "control-label") %>
    <p class="form-control-static">
      <% if f.object.published? %>
        <%= _('Published') %>
      <% elsif (f.object.version.present? && f.object.version <= 0) || !f.object.id.present? %>
        <%= _('Unpublished') %>
      <% else %>
        <%= _('Draft') %>
      <% end %>
    </p>
</div>

<% if f.object.id.present? %>
  <div class="form-group col-xs-8">
    <%= label_tag(:created_at, _('Created at'), class: "control-label") %>
    <p class="form-control-static">
      <%= l f.object.created_at.to_date, formats: :short %>
    </p>
  </div>
  <div class="form-group col-xs-8">
    <%= label_tag(:updated, _('Last updated'), class: "control-label") %>
    <p class="form-control-static">
      <%= l f.object.updated_at.to_date, formats: :short %>
    </p>
  </div>
<% end %>

<% if f.object.org.funder? %>
  <div class="col-xs-8">
    <%= render(partial: '/shared/links',
    locals: {
      context: 'funder',
      title: _('Funder Links'),
      links: Hash(f.object.links).fetch('funder', []),
      max_number_links: MAX_NUMBER_LINKS_FUNDER,
      tooltip: _('Add links to funder websites that provide additional information about the requirements for this template') }) %>
  </div>
  <div class="col-xs-8">
    <%= render(partial: '/shared/links',
    locals: {
      context: 'sample_plan',
      title: _('Sample Plan Links'),
      links: Hash(f.object.links).fetch('sample_plan', []),
      max_number_links: MAX_NUMBER_LINKS_SAMPLE_PLAN,
      tooltip: _('Add links to sample plans if provided by the funder.') }) %>
  </div>
  <%= hidden_field_tag('template-links', ActiveSupport::JSON.encode(f.object.links)) %>
<% end %>

<div class="form-group col-xs-8">
  <%= f.button(_('Save'), class: 'btn btn-default', type: "submit") %>
</div>
