<div class="box tabular">
  <%- if issue.safe_attribute?(:subject) -%>
    <p>
      <%= f.text_field :subject, :size => 10, :maxlength => 255, :required => true %>
    </p>
  <%- end -%>

  <%- if issue.safe_attribute?(:project_id) and
         issue.sprint and issue.sprint.project and
         issue.sprint.shared? and issue.sprint.project.children.any? -%>
    <p>
      <%= f.select :project_id, project_selector_tree(issue.sprint.project), {:required => true} %>
    </p>
  <%- end -%>

  <%- allowed_statuses = issue.new_statuses_allowed_to(User.current) -%>
  <%- if issue.safe_attribute?(:status_id) and allowed_statuses.present? -%>
    <p>
      <%= f.select :status_id, (allowed_statuses.collect {|status| [status.name, status.id]}), {:required => true} %>
    </p>
  <%- end -%>

  <%- if issue.safe_attribute?(:priority_id) -%>
    <p>
      <%= f.select :priority_id, (IssuePriority.active.collect {|p| [p.name, p.id]}), {:required => true, :disabled => !issue.leaf?} %>
    </p>
  <%- end -%>

  <%- if issue.field?(:assigned_to_id) -%>
    <p>
      <%= f.select :assigned_to_id, principals_options_for_select(issue.assignable_users, issue.assigned_to), :include_blank => true, :required => issue.required_attribute?('assigned_to_id') %>
    </p>
  <%- end -%>

  <%- if issue.field?(:category_id) and issue.project.issue_categories.any? -%>
    <p>
      <%= f.select :category_id,
                   (issue.project.issue_categories.collect {|c| [c.name, c.id]}),
                   :include_blank => true,
                   :required => issue.required_attribute?(:category_id) %>
    </p>
  <% end %>

  <%- if issue.field?(:fixed_version_id) and issue.assignable_versions.any? -%>
    <p><%= f.select :fixed_version_id, version_options_for_select(issue.assignable_versions, issue.fixed_version), :include_blank => true, :required => issue.required_attribute?('fixed_version_id') %>
    </p>
  <%- end -%>

  <%- method = (Redmine::VERSION::STRING < '3.3.0') ? :text_field : :date_field -%>

  <%- if issue.field?(:start_date) -%>
    <p>
      <%= f.send method, :start_date, :size => 10, :disabled => !issue.leaf?, :required => issue.required_attribute?('start_date') %><%= calendar_for('issue_start_date') if issue.leaf? %>
    </p>
  <%- end -%>

  <%- if issue.field?(:due_date) -%>
    <p>
      <%= f.send method, :due_date, :size => 10, :disabled => !issue.leaf?, :required => issue.required_attribute?('due_date') %><%= calendar_for('issue_due_date') if issue.leaf? %>
    </p>
  <%- end -%>

  <%- if issue.field?(:estimated_hours) -%>
    <p>
      <%= f.text_field :estimated_hours, :size => 4, :maxlength => 10 %>
    </p>
  <%- end -%>

  <%- if User.current.allowed_to?(:edit_pending_effort, issue.project) and
         issue.is_task? -%>
    <p>
      <%= f.text_field :pending_effort, :size => 4, :maxlength => 10, :label => l(:field_pending_effort) %>
    </p>
  <%- end -%>

  <%- if issue.field?(:done_ratio) and issue.leaf? and Issue.use_field_for_done_ratio? -%>
    <p>
      <%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r * 10} %", r * 10] }), :required => issue.required_attribute?('done_ratio') %>
    </p>
  <%- end -%>

  <%- issue.editable_custom_field_values.each do |value| -%>
    <%- if issue.custom_field?(value.custom_field) -%>
      <p>
        <%= custom_field_tag_with_label :issue, value, :required => value.custom_field.is_required %>
      </p>
    <%- end -%>
  <%- end -%>

  <%- if User.current.allowed_to?(:edit_pending_effort, issue.project) and
         issue.is_pbi? and Scrum::Setting::use_remaining_story_points? -%>
    <p>
      <%= f.text_field :pending_effort, :size => 4, :maxlength => 10,
                       :label => l(:label_pending_sps) %>
    </p>
  <%- end -%>

  <%- if issue.field?(:description) -%>
    <p>
      <%= f.label_for_field :description, :required => issue.required_attribute?(:description) %>
      <%= content_tag :span, :id => "issue_description_and_toolbar" do %>
        <%= f.text_area :description,
                        :rows => 8,
                        :accesskey => accesskey(:edit),
                        :class => "wiki-edit",
                        :no_label => true %>
      <% end %>
    </p>
    <%= wikitoolbar_for 'issue_description' %>
  <%- end -%>

  <%- if issue.id -%>
    <p>
      <%= f.text_area :notes, :rows => 8, :class => "wiki-edit" %>
    </p>
    <%= wikitoolbar_for 'issue_notes' %>
  <%- end -%>
</div>

<%= render :partial => "scrum/issue_attributes", :formats => [:js],
           :locals => {:issue => issue} %>
