<%# we use a helper of our controller since we cannot inject content_for blocks into the hook which is rendering our javascript %>
<%- controller.rb_jquery_plugins = capture do %>
  <%= javascript_include_tag(
    'jquery/jquery.jqplot/plugins/jqplot.barRenderer.min.js',
    :plugin => 'redmine_backlogs')
  %>
<%- end %>

<style type="text/css">
tr.closed {text-decoration: line-through;}
.sprint {margin-bottom: 2em;}
h3.version {font-size: 14px; background: none; padding-left:0;}
#sprints, #releasebacklog, #closed-sprints {margin-bottom: 3em;}
</style>
<div class="contextual">
<%= link_to_if_authorized l(:button_edit),   {:controller => 'rb_releases', :action => 'edit',    :release_id => @release}, :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
<%= link_to_if_authorized l(:button_delete), {:controller => 'rb_releases', :action => 'destroy', :release_id => @release}, :confirm => l(:text_are_you_sure), :class => 'icon icon-del', :method => :delete %>
</div>

<h2><%= h @release.name %></h2>

<p><%= @release.description %></p>

<% if Backlogs.setting[:release_burnup_enabled] %>
  <h3>Release Burnup chart</h3>
  <!--Release Burnup Visualization-->
  <% unless @release.has_burndown? %>
    <p class="nodata">No burndown available</p>
  <% else %>
      <%= render :partial => "rb_release_burndown_charts/burndown", :locals => { :release => @release, :style => "margin-left:0px; margin-top:20px;"} %>
    <br />
  <% end %>
<% end %>

<!--Visualization of related sprints -->
<!--TODO: i18n-->
<br><h3>Sprints</h3>

<div id="sprints">
  <% @release.stories_by_sprint.each do |v,list|
    version = Version.find(v)
    if version.open? %>
    <%= render :partial => 'sprint', :locals => { :version=>version, :issues=>list} %>
  <%end
  end %>
</div>

<div id="releasebacklog">
  <h3>Release Backlog</h3>
  <%= render :partial => 'sprint', :locals => { :version=>nil, :issues=>RbStory.release_backlog(@release)} %>
</div>

<br><h3>Closed Sprints</h3>
<div id="closed_sprints">
  <% @release.stories_by_sprint.each do |v,list|
    version = Version.find(v)
    unless version.open? %>
    <%= render :partial => 'sprint', :locals => { :version=>version, :issues=>list} %>
  <%end
  end %>
</div>

<% if @release.has_burndown? && Backlogs.setting[:release_burnup_enabled] %>
  <% other_formats_links do |f| %>
    <%= f.link_to 'CSV', :url => { :release_id => @release } %>
  <% end %>
<% end %>
  <br />

<% content_for :sidebar do %>
  <h3><%= l(:label_release) %></h3>
  <p><b><%= l(:field_status) %>:</b>   <%= l("version_status_#{@release.status}")    %></p>
  <p><b><%= l(:field_release_start_date) %>:</b>   <%= @release.release_start_date   %></p>
  <p><b><%= l(:field_release_end_date) %>:</b>     <%= @release.release_end_date     %></p>
  <p><b><%= l(:remaining_story_points) %>:</b>     <%= @remaining_story_points       %></p>
  <p><b><%= l(:field_planned_velocity) %>:</b>     <%= @release.planned_velocity     %></p>
  <p><br/></p>
<% if @release.has_burndown? && Backlogs.setting[:release_burnup_enabled] %>
  <% if @release.burndown.planned_estimate_end_date.is_a? Date %>
    <p><b><%= l(:label_release_planned_velocity_end_date) %>:</b>     <%= @release.burndown.planned_estimate_end_date     %></p>
  <% end %>
  <% if @release.burndown.trend_estimate_end_date.is_a? Date %>
    <p><b><%= l(:label_release_trend_end_date) %>:</b>     <%= @release.burndown.trend_estimate_end_date     %></p>
  <% end %>
<% end # has burndown %>
<% end %>

<% html_title(@release.name) -%>
