<% if User.current.allowed_to?(:edit_deals, @project) %>
  <% @issue.build_deals_issue(:deal_id => '') if @issue.deals_issue.blank? %>

  <%= form.fields_for :deals_issue do |f| %>
    <div class="attributes">
      <div class="splitcontent">
        <div class="splitcontentleft">
          <p>
            <% deal = @issue.deals_issue.deal %>
            <%= f.select :deal_id,
                         options_for_select([[deal.try(:name), deal.try(:id)]], deal.try(:id)),
                         :label => l(:label_deal) %>
          </p>
        </div>
      </div>
    </div>

    <%= javascript_tag do %>
      initDealSelect2('issue_deals_issue_attributes_deal_id', '<%= auto_complete_deals_path(:project_id => @project) %>', ' ');
    <% end %>
  <% end %>

<% end %>
