<% content_for :sidebar do %>
  <div id="slide-panel" class="visible">

    <div class="sidebar-header">
      <div class="sidebar-header-title">
        <h5><%=t "sidebar.title" %></h5>
      </div>
    </div>
    <div class="sidebar-header-toggle">
      <a href="" id="toggle-sidebar-link">
        <span class="glyphicon glyphicon-play-circle"></span>
      </a>
    </div>

    <div class="tree">
      <ul>
        <li class="<%= "active" if not is_module_page? %>">
          <span class="tree-link line-wrap">
            <i></i>
            <% if is_module_page? %>
              <%= link_to @project.name, project_action_to_link_to(@project), title: @project.name %>
            <% else %>
              <span title="<%= @project.name %>"><%= @project.name %></span>
            <% end %>
          </span>
          <% if @project.active_modules.present? then %>
            <ul>
              <% @project.active_module_groups.each do |my_module_group| %>
                <li data-module-group="<%= my_module_group.id %>">
                  <span>
                    <i></i>
                    <span class="line-wrap short" title="<%= my_module_group.name %>">
                      <%= my_module_group.name %>
                    </span>
                    <% if is_canvas? %>
                      <a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
                    <% end %>
                  </span>
                  <% if my_module_group.my_modules.present? then %>
                    <ul>
                      <% my_module_group.my_modules.sort_by{|m| m.workflow_order}.each do |my_module| %>
                        <li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
                          <span class="tree-link">
                            <% if currently_active? my_module %>
                              <%= my_module.name %>
                            <% else %>
                              <% if can_view_module(my_module) then %>
                                <%= link_to my_module.name, module_action_to_link_to(my_module), class: "module-link" %>
                              <% else %>
                                <%= my_module.name %>
                              <% end %>
                            <% end %>
                            <% if is_canvas? %>
                              <a href="#" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
                            <% end %>
                          </span>
                        </li>
                      <% end %>
                    </ul>
                  <% end %>
                </li>
              <% end %>
              <% modules_without_group = @project.modules_without_group %>
              <% if modules_without_group.present? then %>
                <li>
                  <span>
                    <i></i>
                    <span class='sidebar-no-module-group'><%= t("sidebar.no_module_group") %></span>
                  </span>
                  <ul>
                    <% modules_without_group.each do |my_module| %>
                      <li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
                        <span class="tree-link">
                          <% if currently_active? my_module %>
                              <%= my_module.name %>
                          <% else %>
                            <%= link_to my_module.name, module_action_to_link_to(my_module) %>
                          <% end %>
                          <% if is_canvas? %>
                            <a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
                          <% end %>
                        </span>
                      </li>
                    <% end %>
                  </ul>
                </li>
              <% end %>
            </ul>
          <% end %>
        </li>
      </ul>
    </div>
  </div>
<% end %>

<%= javascript_include_tag("sidebar") %>
