- @pagetitle = "Subprojects of #{@project}"
- @metarobots = 'noindex'
- project_bread_crumb 'Subprojects'

= render partial: "tabs"

- if @parentprojects.present?
  %h3 Parent projects of #{@project}
  %table.compact.fit.stripe.no-footer#parentprojects-table
    %thead
      %tr
        %th Parent project
        %th Title
    %tbody
      - @parentprojects.each do |project|
        %tr
          %td.project_name= link_to(word_break(project.name), {action: 'show', project: project.name})
          %td.project_title= word_break(project.title)

%h3= @pagetitle
- if @subprojects.present?
  %table.compact.fit.stripe.no-footer#subprojects-table
    %thead
      %tr
        %th Subproject
        %th Title
    %tbody
      - @subprojects.each do |project|
        %tr
          %td.project_name= link_to(word_break(remove_parent_name(project.name, @project.name), 50), {action: 'show', project: project.name})
          %td.project_title= word_break(project.title)
- else
  %p
    %i This project has no subprojects

- if @siblings.present?
  %h3 Sibling projects of #{@project}
  %table.compact.fit.stripe.no-footer#siblingprojects-table
    %thead
      %tr
        %th Sibling project
        %th Title
    %tbody
      - @siblings.each do |project|
        %tr
          %td.project_name= link_to(word_break(remove_parent_name(project.name, @parent_name), 50), {action: 'show', project: project.name})
          %td.project_title= word_break(project.title)

- if User.current.can_modify_project?(@project)
  %p
    = link_to sprite_tag('brick_add', title: 'New subproject') + ' New subproject', '#', id: 'create_subproject_link'
    .hidden#create-subproject
      = render partial: 'form', locals: { project: Project.new, configuration: @configuration, ns: @project.name }

- if @subprojects.present? || @parentprojects.present?
  - content_for :ready_function do
    setup_subprojects_tables();
- content_for :ready_function do
  $("#create_subproject_link").click(function() { $('#create-subproject').show(); $('#create_subproject_link').hide() });
