<!-- TASKBOARD VIEW -->
<%# early javascript before common.hs %>
<%- controller.rb_jquery_plugins = capture do %>
  <%= javascript_include_tag(
    'jquery/jquery.multiselect.js', 'jquery/jquery.qtip.pack.js', 'jquery/jquery.qtip.setup.js',
     :plugin => 'redmine_backlogs')
  %>
<%- end %>
<% content_for :head_tags do %>
  <%= javascript_include_tag(
    'show_main', 'board_updater', 'taskboard_updater', 'taskboard', 'model', 'issue', 'task', 'impediment',
     :plugin => 'redmine_backlogs')
  %>
  <%= stylesheet_link_tag 'jquery/jquery.qtip.css', :plugin => 'redmine_backlogs' %>
  <%= stylesheet_link_tag 'jquery/jquery.multiselect.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 => 'sprint', :sprint_id => @sprint.id,
                           :context => 'taskboard',
                           :format => 'js') %>">
  </script>
  <%# Usability: display default cursor if tasks cannot be dragged %>
  <% unless User.current.allowed_to?(:update_tasks, @project) %> 
    <style type="text/css">
    #taskboard .issue{cursor:default;}
    </style>
  <% end %>
<% end %>

<% content_for :breadcrumbs do %>
  <% unless Backlogs.setting[:show_redmine_std_header] %>
    <%= link_to l(:label_master_backlog), :controller => "rb_master_backlogs", :action => "show", :project_id => @project %>
    <%= breadcrumb_separator %>
  <% end %>
  <%= h @sprint.name %>
<% end %>

<%- content_for :view_specific_users do %>
<span id="userselect">
<ul style="list-style:none; margin:0px">
  <li><label>
    <select class="userfilter" size="5" name="filter-user-selection" multiple="multiple" title="User selection">
      <option value='s'>Show empty Stories</option>
      <optgroup label="Users">
      <% @project.assignable_users.sort.each do |member| %>
        <option value="<%= member.id %>"> <%= member.name %></option>
      <% end %>
      </optgroup>
      </select>
  </label></li>
</ul>
<br style="clear:both" />
</span>
<%- 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 %>
<span id="userid" style="visibility:hidden;"><%= User.current.id %></span>
<div id="taskboard">


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

  <table id="impediments" class="board" cellspacing="0">
    <tr>
      <td><div class="label_sprint_impediments">
            <% if User.current.allowed_to?(:create_impediments, @project) %>
            <span class="add_new">
              <%= image_tag("add.png", :alt => "+") %>
            </span>
            <% end %>
            <%= l(:label_sprint_impediments) %>
      </div></td>
      <%- @statuses.each do |status| %>
      <td class="swimlane list <%= status.is_closed? ? 'closed' : '' %>" id="impcell_<%= status.id %>" -rb-status-id="<%= status.id %>" -rb-project-id="impediments">
        <%= 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 id="swimlane-<%= story.id %>" class="story-swimlane">
      <td>
        <div class="story <%= mark_if_closed(story) %>" <%= build_inline_style(story).html_safe %>>
          <div class="id story_tooltip">
            <div class="tooltip_text"><%= render :partial => "rb_stories/tooltip", :object => story %></div>
            <%= link_to story.id, {:controller => 'issues', :action => 'show', :id => story.id}, { :target => "_blank" } %>
            <% if User.current.allowed_to?(:create_tasks, @project) %>
            <span class="add_new">
              <%= image_tag("add.png", :alt => "+") %>
            </span>
            <% end %>
            <span class="assignee">
              <%= assignee_name_or_empty(story) %>
            </span>
            <span class="remaininghours">(<%= story.remaining_hours.to_i %> <%= l(:label_hours) %>)</span>
          </div>
          <div class="subject"><%= h story.subject %></div>
          <%- if @project != story.project %>
            <div class="id project">
              <span class="t"><%= h story.project %></span>
              <span class="v"><%= story.project.id %></span>
            </div>
          <%- end %>
          <div class="story_points editable" fieldname="story_points" fieldlabel="<%=l(:field_story_points)%>"><%= story.story_points %></div>
        </div>
      </td>
      <%- @statuses.each do |status| %>
      <td class="swimlane list <%= status.is_closed? ? 'closed' : '' %>" id="<%= story.id %>_<%= status.id %>" -rb-status-id="<%= status.id %>" -rb-project-id="<%= story.project.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 %>"><%= h p.name %></option>
    <%- end %>
  </select>

  <select class="assigned_to_id template" id="assigned_to_id_options">
    <option value="" color="#AAAAAA" color_light="#E0E0E0"> </option>
    <%= users_assignable_options_for_select(@project.assignable_users) %>
  </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 %>
