estimancy/projestimate

View on GitHub
app/views/wbs_activities/_settings.html.erb

Summary

Maintainability
Test Coverage
<h3>
  Ventilation par activités
</h3>

<% effort = PeAttribute.find_by_alias("effort") %>
<% cev = EstimationValue.where(:pe_attribute_id => effort.id,
                               :module_project_id => current_module_project.id,
                               :in_out => "input").first %>
<% pev = EstimationValue.where(:pe_attribute_id => effort.id,
                               :module_project_id => current_module_project.previous.first,
                               :in_out => "output").first %>
<% component_id = current_component.id %>
<% organization = @project.organization %>
<% wai = WbsActivityInput.where(module_project_id: current_module_project.id, wbs_activity_id: current_module_project.wbs_activity_id).first_or_create! %>

<%= form_tag save_effort_breakdown_path do %>

  <table class="table table-bordered">
    <tr>
      <th></th>
      <th>Activity Ratio</th>
      <% if current_module_project.wbs_activity.three_points_estimation? %>
        <th>L</th>
      <% end %>
      <th>M</th>
      <% if current_module_project.wbs_activity.three_points_estimation? %>
        <th>H</th>
      <% end %>
      <th>Commentaire</th>
    </tr>
    <tr>
      <td>Effort (<%= current_module_project.wbs_activity.effort_unit %>)</td>

      <td>
        <%= select_tag "ratio", options_for_select(current_module_project.wbs_activity.wbs_activity_ratios.map{|i| [i.name, i.id]}, selected: wai.wbs_activity_ratio_id), readonly: cannot?(:execute_estimation_plan, @project) %>
      </td>

      <% if current_module_project.wbs_activity.three_points_estimation? %>
        <% if cev.string_data_low[component_id].blank? %>
          <td><%= text_field_tag "values[low]", pev.nil? ? '' : convert_with_specific_precision(pev.string_data_low[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
        <% else %>
          <td><%= text_field_tag "values[low]", convert_with_specific_precision(cev.string_data_low[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
        <% end %>
      <% end %>

      <% if cev.string_data_most_likely[component_id].blank? %>
        <td><%= text_field_tag "values[most_likely]", pev.nil? ? '' : convert_with_specific_precision(pev.string_data_most_likely[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
      <% else %>
        <td><%= text_field_tag "values[most_likely]", convert_with_specific_precision(cev.string_data_most_likely[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
      <% end %>

      <% if current_module_project.wbs_activity.three_points_estimation? %>

        <% if cev.string_data_high[component_id].blank? %>
          <td><%= text_field_tag "values[high]", pev.nil? ? '' : convert_with_specific_precision(pev.string_data_high[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
        <% else %>
          <td><%= text_field_tag "values[high]", convert_with_specific_precision(cev.string_data_high[component_id], organization, 5), readonly: (!current_module_project.wbs_activity.enabled_input || cannot?(:alter_estimation_plan, @project)) %></td>
        <% end %>
      <% end %>

      <td>
        <span class="pull-left" >
          <%= link_to (wai.comment.nil? || wai.comment.blank?) ? '----' : wai.comment.truncate(25), "#", title: wai.comment, :"data-toggle" => "modal", :"data-target" => "#comment#{wai.id}", :"data-backdrop" => "static"  %>
        </span>
        <div class="modal fade" id="comment<%= wai.id %>" tabindex="-1" role="dialog" aria-labelledby="comment_label<%= wai.id %>" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h4 class="modal-title" id="comment_label<%= wai.id %>">
                  <b>
                    <%= wai.wbs_activity.nil? ? '' : wai.wbs_activity.name %>
                  </b>
                </h4>
              </div>
              <div class="modal-body">
                <%= text_area_tag "comment[#{wai.id}]", wai.comment, class: "attribute_note_area" %>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" ><%= I18n.t(:close) %></button>
                <% if can?(:execute_estimation_plan, @project) %>
                    <button type="submit" class="btn btn-default"><%= I18n.t(:save) %></button>
                <% end %>
              </div>
            </div>
          </div>
        </div>
      </td>
    </tr>
  </table>
  <% if can?(:execute_estimation_plan, @project) %>
    <%= submit_tag "Run Estimation", class: "pull-right btn btn-mini" %>
  <% end %>
<% end %>