<%= error_messages_for 'tracker' %>

<div class="splitcontent">
<div class="splitcontentleft">
<div class="box tabular">
<!--[form:tracker]-->
<p><%= f.text_field :name, :required => true %></p>
<p><%= f.select :default_status_id,
        IssueStatus.sorted.map {|s| [s.name, s.id]},
        :include_blank => @tracker.default_status.nil?,
        :required => true %>
</p>
<p><%= f.check_box :is_in_roadmap %></p>
<p><%= f.text_area :description, :rows => 4 %></p>
<p>
  <label><%= l(:field_core_fields) %></label>
  <% Tracker::CORE_FIELDS.each do |field| %>
  <label class="block">
    <%= check_box_tag 'tracker[core_fields][]', field, @tracker.core_fields.include?(field), :id => nil %>
    <%= l("field_#{field}".delete_suffix('_id')) %>
  </label>
  <% end %>
</p>
<%= hidden_field_tag 'tracker[core_fields][]', '' %>

<% @issue_custom_fields = IssueCustomField.sorted %>
<% if @issue_custom_fields.present? %>
<p>
  <label><%= l(:label_custom_field_plural) %></label>
  <% @issue_custom_fields.each do |field| %>
    <label class="block">
      <%= check_box_tag 'tracker[custom_field_ids][]',field.id, @tracker.custom_fields.to_a.include?(field), :id => nil %>
      <%= field.name %>
    </label>
  <% end %>
</p>
<%= hidden_field_tag 'tracker[custom_field_ids][]', '' %>
<% end %>

<% if @tracker.new_record? && @trackers.any? %>
<p><label for="copy_workflow_from"><%= l(:label_copy_workflow_from) %></label>
<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %></p>
<% end %>
<!--[eoform:tracker]-->
</div>
<%= submit_tag l(@tracker.new_record? ? :button_create : :button_save) %>
</div>

<div class="splitcontentright">
<% if @projects.any? %>
<fieldset class="box" id="tracker_project_ids"><legend><%= toggle_checkboxes_link("#tracker_project_ids input[type=checkbox]") %><%= l(:label_project_plural) %></legend>
<% project_ids = @tracker.project_ids.to_a %>
<%= render_project_nested_lists(@projects) do |p|
  content_tag('label', check_box_tag('tracker[project_ids][]', p.id, project_ids.include?(p.id), :id => nil) + ' ' + h(p))
end %>
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %>
</fieldset>
<% end %>
</div>
</div>
