<% @pagetitle = "Projects Maintained by #{@project}" %>
<% project_bread_crumb 'Maintained Projects' %>

<%= render :partial => 'tabs' %>

<h3>Maintained Projects</h3>
<% if @maintained_projects.length > 0 %>
  <table id="maintained_projects_table">
    <thead>
      <tr>
        <th class="hidden">Name</th>
        <% if User.current.can_modify_project?(@project) %>
          <th style="width: 1%">Actions</th>
        <% end %>
      </tr>
    </thead>
    <tbody>
      <% @maintained_projects.each do |maintained_project| %>
        <tr>
          <td><%= link_to(maintained_project, :action => 'show', :project => maintained_project) %></td>
          <% if User.current.can_modify_project?(@project) %>
            <td>
              <%# TODO: Convert into a dialog and use link_to + :remote => true %>
	      <%= link_to(sprite_tag('brick_delete', title: 'Remove project from maintenance'), { :controller => 'project', :action => 'remove_maintained_project', :project => @project, :maintained_project => maintained_project }, method: :post) %>
            </td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
  <%= javascript_tag do %>
    $(function() {
      $('#maintained_projects_table').dataTable({
        "bSort": false,
      });
    });
  <% end %>
<% else %>
  <p><i>No projects in maintenance</i></p>
<% end %>

<% if User.current.can_modify_project?(@project) %>
  <p>
    <%= link_to(sprite_tag('brick_add', title: 'Add project to maintenance') + 'Add project to maintenance', {:controller => 'project', :action => 'add_maintained_project_dialog', :project => @project}, :remote => true) %>
  </p>
<% end %>
