<!-- TASKBOARD VIEW -->
<% content_for :head_tags do %>
  <%= javascript_include_tag  'show_main', 'board_updater', 'taskboard_updater', 'taskboard', 'model', 'issue', 'task', 'impediment', 'jquery/jquery.qtip.pack.js', 'jquery/jquery.qtip.setup.js', :plugin => 'redmine_backlogs' %>
  <%= stylesheet_link_tag 'jquery.qtip.css', :plugin => 'redmine_backlogs' %>
  <%= stylesheet_link_tag 'taskboard.css', :plugin => 'redmine_backlogs', :media => 'print,screen' %>
  <%= stylesheet_link_tag 'taskboard_print.css', :plugin => 'redmine_backlogs', :media => 'print' %>
  <script type="text/javascript" src="<%= url_for(:controller => 'rb_server_variables', :action => 'show', :section => 'taskboard', :project_id => @project.identifier, :sprint_id => @sprint.id, :format => 'js') %>"></script>
  <script type="text/javascript">
    if(!RB.constants.workflow) {
      alert('<%= escape_javascript(l(:error_no_workflow_for_task_tracker)) %>');
      window.location.replace('/trackers'); // '<% url_for(:controller => 'trackers', :action => 'index') %>';
    }
  </script>
<% end %>

<% content_for :breadcrumbs do %>
  <%= link_to l(:label_master_backlog), :controller => "rb_master_backlogs", :action => "show", :project_id => @project %>
  <%= breadcrumb_separator %>
  <%= @sprint.name %>
<% end %>

<%- content_for :view_specific_links do %>
  <% if @sprint.has_burndown? %>
    <a id='show_charts'><%= l(:label_burndown) %></a>
  <% end %>
  <span id="col_width"><%= l(:label_column_width) %>: <input name="col_width"/></span>
  <a id="disable_autorefresh">Disable Auto-refresh</a>
  <a id="refresh">Refresh</a>
<%- end %>

<%- content_for :main do %>
<div id="taskboard">
  <table id="board_header" cellspacing="0">
    <tr>
      <td><%= l(:backlogs_story) %></td>
      <%- @statuses.each do |status| %>
      <td class="swimlane"><%= status.name %></td>
      <%- end %>
    </tr>
  </table>

  <table id="impediments" class="board" cellspacing="0">
    <tr>
      <td><div class="label_sprint_impediments"><%= l(:label_sprint_impediments) %></div></td>
      <td class="add_new">+</td>
      <%- @statuses.each do |status| %>
      <td class="swimlane list <%= status.is_closed? ? 'closed' : '' %>" id="impcell_<%= status.id %>">
        <%= render :partial => "rb_impediments/impediment", :collection => @sprint.impediments.select{|impediment| impediment.status_id==status.id} %>
      </td>
      <%- end %>
    </tr>
  </table>

  <table id="tasks" class="board" cellspacing="0">
    <%- @sprint.stories.each do |story| %>  
    <tr>
      <td>
        <div class="story <%= mark_if_closed(story) %>" style="border-top: 3px solid <%= build_inline_style_color(story) %>">
          <div class="id story_tooltip" title="<%= render :partial => "rb_stories/tooltip", :object => story %>">
            <div style="float:left; padding-left:3px; font-weight:bold;"><%= assignee_name_or_empty(story) %></div>
            <%= link_to story.id, {:controller => 'issues', :action => 'show', :id => story.id}, { :target => "_blank" } %>
          </div>
          <div class="subject"><%= story.subject %></div>
          <div class="id project"><%= story.project %></div>
          <div class="story_points editable" fieldname="story_points" fieldlabel="<%=l(:field_story_points)%>"><%= story.story_points %></div>
        </div>
      </td>
      <td class="add_new">+</td>
      <%- @statuses.each do |status| %>
      <td class="swimlane list <%= status.is_closed? ? 'closed' : '' %>" id="<%= story.id %>_<%= status.id %>">
        <%= render :partial => "rb_tasks/task", :collection => story.descendants.select{|task| task.status.id==status.id} %>
      </td>
      <%- end %>
    </tr>
    <%- end %>
  </table>
</div>
<%- end %>

<%- content_for :helpers do %>
  <select class="time_entry_user_id template" id="time_entry_user_id_options">
    <%- users_allowed_to_log_on_task.each do |u| %>
      <option value="<%= u[1] %>"><%= u[0] %></option>
    <%- end %>
  </select>

  <select class="priority_id template" id="priority_id_options">
    <%- IssuePriority.all.each do |p| %>
    <option value="<%= p.id %>"><%= p.name %></option>
    <%- end %>
  </select>

  <select class="assigned_to_id template" id="assigned_to_id_options">
    <option value=""> </option>
    <%- @project.members.each do |member| %>
    <option value="<%= member.user_id %>" color="<%= member.user.backlogs_preference(:task_color) %>"><%= member.name %></option>
    <%- end %>
  </select>
  <div id="task_template">
    <%= render :partial => "rb_tasks/task", :object => RbTask.new %>
  </div>
  <div id="impediment_template">
    <%= render :partial => "rb_impediments/impediment", :object => RbTask.new %>
  </div>
  <!-- end of templates -->
  <div id="issue_editor"> </div>
  <div class="meta" id="last_updated"><%= date_string_with_milliseconds( (@last_updated.blank? ? Time.now : @last_updated.updated_on) )  %></div>
  <div id="charts"> </div>
  <div id="preloader">
    <div id="spinner"> </div>
    <div id="warning"> </div>
  </div>
<%- end %>
