estimancy/projestimate

View on GitHub
app/views/module_projects/_estimation_plan.html.erb

Summary

Maintainability
Test Coverage

<% module_projects = @project.module_projects %>
<% @alphabet = %w(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) %>

<% unless module_projects.empty? %>
  <table class="table table-striped table-condensed table-estimation" >
    <theader>
    <tr>
      <td class="center">
        <% if can_alter_estimation?(@project) && can?(:alter_estimation_plan, @project) %>
            <%= link_to "", locked_plan_path(@project.id), :class => "#{ @project.locked? ? 'icon-lock' : 'icon-unlock' } icon-large", :title => "#{ @project.locked? ? 'Unlock estimation plan' : 'Lock estimation plan' }" %>
        <% end %>
      </td>
      <% for x in 1..@module_positions_x.to_i do %>
        <td class="center">
          <h4>
            <%= @alphabet[x-1] %>
          </h4>
        </td>
      <% end %>
    </tr>
    </theader>
    <!-- The INITIALIZATION module -->
    <%= render :partial => 'module_projects/initialization_module' %>

    <!-- Others modules -->
      <% for y in 1..@module_positions do %>
        <tr>
          <td class="line_number">
              <h4 class="text-center"><%= y %></h4>
          </td>

          <% for x in 1..@module_positions_x.to_i do %>
            <td class="module_bloc_size" >
              <% pmod = @project.module_projects.where("position_x = ? AND position_y = ?", x, y).first %>

              <% unless pmod.nil? %>
                <% if @pbs_project_element %>
                  <% if pmod.pbs_project_elements.map(&:id).include?(@pbs_project_element.id) %>
                    <% pbs_class = 'highlight' %>
                  <% else %>
                      <% pbs_class= "" %>
                  <% end %>
                <% end %>

                <div class="<%= pbs_class %> module_project <%= "#{pmod.pemodule.alias}_#{pmod.position_x}_#{pmod.position_y}" %> text-center">
                    <%= pmod %>
                    <br>
                    <% unless @project.locked? %>
                      <% if can_alter_estimation?(@project) && can?(:alter_estimation_plan, @project) %>
                          <%= link_to '', pemodules_left_path(pmod.id), :class => 'icon-arrow-left a_white' %>
                          <%= link_to '', pemodules_up_path(pmod.id), :class => 'icon-arrow-up a_white' %>
                          <%= link_to '', pemodules_down_path(pmod.id), :class => 'icon-arrow-down a_white' %>
                          <%= link_to '', pemodules_right_path(pmod.id), :class => 'icon-arrow-right a_white' %>
                          <%= link_to '', '#', :title => "#{pmod.pemodule.title}: \n #{pmod.pemodule.description}", :class => "icon-info attribute_tooltip a_white" %>
                          <%#= link_to '', edit_module_project_path(pmod.id), :class => "icon-pencil a_white" %>
                          <%= link_to '', pmod, confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash a_white' %>
                      <% else %>
                          <%= link_to '', '#', :title => "#{pmod.pemodule.title}: \n #{pmod.pemodule.description}", :class => "icon-info attribute_tooltip a_white" %>
                      <% end %>

                      <% if pmod.show_results_view %>
                        <%= link_to '', show_module_project_results_view_path(module_project_id: pmod.id), id:"show_results_view", :class => "icon-eye-open a_white", :title => I18n.t(:title_hide_results_view, :value => "#{pmod.pemodule.title}"), remote: true %>
                      <% else %>
                        <%= link_to '', show_module_project_results_view_path(module_project_id: pmod.id), id:"show_results_view", :class => "icon-eye-close a_white", :title => I18n.t(:title_show_results_view, :value => "#{pmod.pemodule.title}"), remote: true %>
                      <% end %>
                    <% end %>
                </div>

                <%= render :partial => 'module_projects/estimation_paths', :locals => { :pmod => pmod } %>

              <% end %>
            </td>
          <% end %>
        </tr>
      <% end %>
  </table>
<% else %>
  <%= content_tag(:div, I18n.t(:notice_no_estimation_plan_defined), :class => 'alert alert-info') %>
<% end %>