<div class="contextual">
  <%= link_to(icon_with_label('add', l(:label_version_new)), new_project_version_path(@project),
              :class => 'icon icon-add') if User.current.allowed_to?(:manage_versions, @project) %>
  <%= actions_dropdown do %>
  <%= link_to_if_authorized icon_with_label('settings', l(:label_settings)),
              {:controller => 'projects', :action => 'settings', :id => @project, :tab => 'versions'},
              :class => 'icon icon-settings' if User.current.allowed_to?(:manage_versions, @project) %>
  <% end %>
</div>

<h2><%=l(:label_roadmap)%></h2>

<% if @versions.empty? %>
  <p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
  <div id="roadmap">
  <% @versions.each do |version| %>
  <article class="version-article <%= version.css_classes %>">
    <% if User.current.allowed_to?(:manage_versions, version.project) %>
      <div class="contextual">
        <%= link_to icon_with_label('edit', l(:button_edit)), edit_version_path(version), :title => l(:button_edit), :class => 'icon-only icon-edit' %>
      </div>
    <% end %>
    <header>
      <h3 class="icon icon-package version inline-flex"><%= link_to_version version, :name => version_anchor(version) %></h3>
      <span class="badge badge-status-<%= version.status %>"><%= l("version_status_#{version.status}") %></span>
    </header>
    <%= render :partial => 'versions/overview', :locals => {:version => version} %>
    <%= render(:partial => "wiki/content",
               :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
    <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
      <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
        <table class="list related-issues">
        <caption><%= l(:label_related_issues) %></caption>
        <% issues.each do |issue| -%>
          <tr class="hascontextmenu <%= issue.css_classes %>">
            <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td>
            <td class="assigned_to"><%= assignee_avatar(issue.assigned_to, :size => 16) %></td>
            <td class="subject"><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
            <td class="buttons"><%= link_to_context_menu %></td>
          </tr>
        <% end -%>
        </table>
      <% end %>
    <% end %>
    <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
  </article>
  <% end %>
  </div>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'versions/sidebar' %>
<% end %>

<% html_title(l(:label_roadmap)) %>

<%= context_menu %>
