estimancy/projestimate

View on GitHub
app/views/projects/show.html.erb

Summary

Maintainability
Test Coverage
<div>
  <%= simple_form_for(@project) do |f| %>
  <%= f.error_notification %>

  <div class="tabs">
    <ul>
      <li><a href="#tabs-1"><%= I18n.t(:global_properties) %></a></li>
      <li><a href="#tabs-2"><%= I18n.t(:wbs_product) %></a></li>
      <li class="tabs_4_with_estimation_plan"><a href="#tabs-4"><%= I18n.t(:estimation_plan) %></a></li>
      <li><a href="#tabs-5"><%= I18n.t(:securities) %></a></li>
      <li><a href="#tabs-history"><%= I18n.t(:label_project_history) %> </a></li>
    </ul>

    <div id="tabs-1">
      <%= hidden_field_tag :project_id, @project.id %>
      <%= hidden_field_tag :is_project_show_view, "true" %>

      <%= f.input :title, :label => "#{I18n.t 'label_project_name'}", :input_html => {:class => 'input-xxlarge', :autofocus => (controller.action_name == 'new')}, :disabled => true %>
      <table>
        <tr>
          <td><%= f.input :product_name, label: I18n.t(:label_product_name), :disabled => true, :input_html => {:class => 'input-large', value: (@project.root_component.nil? ? '' : @project.root_component.name) } %></td>
          <td><%= f.input :version, :input_html => {:class => 'input-large'}, :disabled => true %></td>
        </tr>
      </table>

      <%= tinymce %>
      <label>
        <b>
          Description
        </b>
      </label>
      <%= simple_format(@project.description) %>

      <% if can_alter_estimation?(@project) && can?(:alter_project_description, @project) %>
        <%= f.input :description, :label => false, :input_html => {:class => 'input-large tinymce', :rows => 5, :cols => 10 } %>
      <% end %>

      <table>
        <tr>
          <td><%= f.input :estimation_status_id, label: "Estimation Status", as: :select, collection: @project.project_estimation_statuses, :disabled => !( can_alter_estimation?(@project) && can?(:alter_estimation_status, @project) ), :input_html => {:class => 'input-xlarge'}  %></td>
          <% if can_alter_estimation?(@project) && can?(:alter_project_status_comment, @project) %>
            <td><%= link_to('', main_app.add_comment_on_status_change_path(:project_id => @project.id), :class => "icon-comment", :title => "#{I18n.t(:label_add_status_change_comment)}" , :remote => true) %></td>
          <% end %>
        </tr>
        <tr>
          <td>
            <%= f.input :start_date, :as => :string, :disabled => !( can_alter_estimation?(@project) && can?(:alter_start_date, @project)), :input_html => { :class => 'date-picker', :value => (@project.start_date.nil? ? '' : I18n.l(@project.start_date))} %>
          </td>

          <script>
              $(document).ready(function () {
                  $(".date-picker").datepicker({
                      language: '<%= set_user_language %>',
                      autoclose: true,
                      todayHighlight: true,
                      todayBtn: true
                  });
              });
          </script>

          <td><%= f.input :organization_id, :label => "#{I18n.t 'organizations'}", :as => :select, :collection => @organizations.map{|i| [i.name, i.id] }, :input_html => {:class => 'input-xlarge'}, :disabled => true %></td>
        </tr>
      </table>

      <%= f.input :project_area_id, :label => "#{I18n.t 'project_area'}", :as => :select, :collection => @project_areas, :input_html => {:class => 'input-xxlarge'}, :disabled => !( can_alter_estimation?(@project) && can?(:alter_project_areas, @project) ) %>
      <%= f.input :acquisition_category_id, :label => "#{I18n.t 'acquisition_category'}", :as => :select, :collection => @acquisition_categories, :input_html => {:class => 'input-xxlarge'}, :disabled => !( can_alter_estimation?(@project) && can?(:alter_acquisition_categories, @project) ) %>
      <%= f.input :platform_category_id, :label => "#{I18n.t 'platform_category'}", :as => :select, :collection => @platform_categories, :input_html => {:class => 'input-xxlarge'}, :disabled => !( can_alter_estimation?(@project) && can?(:alter_platform_categories, @project) ) %>
      <%= f.input :project_category_id, :label => "#{I18n.t 'project_category'}", :as => :select, :collection => @project_categories, :input_html => {:class => 'input-xxlarge'}, :disabled => !( can_alter_estimation?(@project) && can?(:alter_project_categories, @project) ) %>

      <div class="actions-tabs">
        <% if can_alter_estimation?(@project) %>
            <%= submit_tag I18n.t('save'), :class => 'btn submit_project' %>
            <%= submit_tag I18n.t('apply'), :class => 'btn submit_project' %>
        <% end %>
        <% if @project.is_model %>
            <%= link_to I18n.t('back'), organization_setting_path(@organization, anchor: "tabs-estimation-models"), :class => 'btn' %>
        <% else %>
            <%= link_to I18n.t('back'), organization_estimations_path(@organization), :class => 'btn' %>
        <% end %>
      </div>
    </div>
  <% end %>


    <div id="tabs-2">
      <div class="component_tree" id="project_wbs_product_section">
        <% unless @project.nil? || @pe_wbs_project_product.nil? %>
          <%= raw generate_wbs_product(@project.root_component, @project, '', 5, true) unless @pe_wbs_project_product.pbs_project_elements.last.nil? %>
        <% end %>
      </div>
    </div>

    <div id="tabs-4" class="tabs_4_with_estimation_plan2">
      <% if controller.controller_name == 'projects' %>
        <% if @project.is_locked == false or @project.is_locked.nil? %>
          <% if can? :alter_estimation_plan, @project %>
            <div class="row-fluid">
              <div class="span12">
                <%= I18n.t(:label_add_a_module_to_project) %>
                <%= select_tag 'select_module', grouped_options_for_select({"Modules d'estimation génériques" => @modules_selected,
                                                                            "Modules de Jugement d'Expert" => @ej_modules,
                                                                            "Modules Activités / Profils" => @wbs_instances,
                                                                            "Module d'Unité d'Oeuvres Génériques" => @guw_modules,
                                                                            "Module d'Effort Génériques (ax^b)" => @ge_models}), :prompt => '' %>
              </div>
            </div>

            <br>
            <div class="row-fluid">
              <div class="span12">
                <%= hidden_field_tag 'project_id', @project.id %>
                <%= link_to I18n.t(:button_build_estimation_path), module_projects_matrix_path(@project.id), :class => 'btn' %>
              </div>
            </div>
          <% end %>
        <% end %>
      <% end %>


      <br>
      <div class="module_box"  style=" width: auto; overflow-x:auto;">
        <%= render :partial => 'module_projects/estimation_plan', :locals => { :module_projects => @project.module_projects } %>
      </div>
    </div>

    <div id="tabs-5">
      <div id="accordion-security">
        <!--define the security of the model itself-->
        <% if @project.is_model %>
          <div id="accordion_model" class="accordion">
            <div class="accordion-group accordion-caret">
              <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion_model" href="#collapseModel">
                  <i class="fa-caret-down"></i>
                  <b><%= @project.is_model ? I18n.t(:label_model_group_security_resume) : I18n.t(:label_group_security_resume) %></b>
                </a>
              </div>
              <% can_alter_project_securities = can_alter_estimation?(@project) && can?(:manage_project_security, @project) %>
              <div id="collapseModel" class="accordion-body in collapse">
                <div class="accordion-inner">
                  <table id="table_list_1" class="table tablesorterPager table-striped table-bordered table-condensed">
                    <thead>
                    <tr>
                      <th>Group name</th>
                      <% @organization.project_security_levels.each do |prj_level| %>
                        <th><span class="attribute_tooltip" title='<%= display_security_level_description(prj_level) %>'><%= prj_level.name %></span></th>
                      <% end %>
                    </tr>
                    </thead>
                    <tbody>
                    <% @organization.groups.each do |group| %>
                      <tr>
                        <td>
                          <%= group.name %>
                          <% @organization.project_security_levels.each do |prj_level| %>
                            <%
                               ps = ProjectSecurity.where(group_id: group.id,
                                                          project_id: @project.id,
                                                          project_security_level_id: prj_level.id,
                                                          is_model_permission: true).first
                            %>
                          <td style="text-align: center">
                            <%= check_box_tag("group_securities[#{prj_level.id}][#{group.id}]", group.name, !ps.nil?, disabled: !can_alter_project_securities) %>
                          </td>
                        <% end %>
                      </tr>
                    <% end %>
                    </tbody>
                    <%= render :partial => 'layouts/footer_table' %>
                  </table>

                  <%= submit_tag I18n.t('save'), :name => "model_group_security_levels", :class => 'btn' %>
                  <%= submit_tag I18n.t('apply'), :name => "model_group_security_levels", :class => 'btn', :anchor_value => params[:anchor_value] %>
                  <%= link_to I18n.t('back'), organization_setting_path(@organization, anchor: "tabs-estimation-models"), :class => 'btn' %>
                </div>
              </div>
            </div>
          </div>
        <% end %>
      </div>

      <div id="accordion-security">
        <div class="accordion" id="accordion1">
          <div class="accordion-group accordion-caret">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1" href="#collapseOne">
                <i class="fa fa-caret-down"></i>
                <b><%= I18n.t(:label_user_security_resume) %></b>
              </a>
            </div>
            <% can_alter_project_securities = can_alter_estimation?(@project) && can?(:manage_project_security, @project) %>
            <div id="collapseOne" class="accordion-body in collapse">
              <div class="accordion-inner">
                <table id="table_list_2" class="table tablesorterPager table-striped table-bordered table-condensed">
                  <thead>
                    <tr>
                      <th>User name</th>
                      <% @project.organization.project_security_levels.each do |prj_level| %>
                          <th><span class="attribute_tooltip" title='<%= display_security_level_description(prj_level) %>'><%= prj_level.name %></span></th>
                      <% end %>
                    </tr>
                  </thead>
                  <tbody>
                    <% @organization.users.each do |user| %>
                      <tr>
                        <td>
                          <%= user %>
                          <% @organization.project_security_levels.each do |prj_level| %>
                            <%
                               ps = ProjectSecurity.where(user_id: user.id,
                                                          project_id: @project.id,
                                                          project_security_level_id: prj_level.id,
                                                          is_model_permission: false).first
                            %>
                          <td style="text-align: center">
                            <%= check_box_tag("user_securities_from_model[#{prj_level.id}][#{user.id}]", user.id, ps.nil? ? false : true, disabled: !can_alter_project_securities) %>
                          </td>
                        <% end %>
                      </tr>
                    <% end %>
                  </tbody>
                  <%= render :partial => 'layouts/footer_table' %>
                </table>
                <% if can_alter_estimation?(@project) && can?(:manage_project_security, @project) %>
                  <%= submit_tag I18n.t('save'), :name => "user_security_levels", :class => 'btn' %>
                  <%= submit_tag I18n.t('apply'), :name => "user_security_levels", :class => 'btn', :anchor_value => params[:anchor_value] %>
                <% end %>
                <%= link_to I18n.t('back'), organization_estimations_path(@organization), :class => 'btn' %>
              </div>
            </div>
          </div>
        </div>

        <div id="accordion2" class="accordion">
          <div class="accordion-group accordion-caret">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                <i class="fa fa-caret-down"></i>
                <b>
                  <%= I18n.t(:label_group_security_resume) %>
                </b>
              </a>
            </div>
            <div id="collapseTwo" class="accordion-body in collapse">
              <div class="accordion-inner">
                <table  id="table_list_3" class="table tablesorterPager table-striped table-bordered table-condensed">
                  <thead>
                    <tr>
                      <th>Group name</th>
                      <% @project.organization.project_security_levels.each do |prj_level| %>
                        <th>
                          <span class="attribute_tooltip" title='<%= display_security_level_description(prj_level) %>'>
                            <%= prj_level.name %>
                          </span>
                        </th>
                      <% end %>
                    </tr>
                  </thead>

                  <tbody>
                    <% @organization.groups.each do |group| %>
                      <tr>
                        <td>
                          <%= group.name %>
                          <% @organization.project_security_levels.each do |prj_level| %>
                            <% ps = ProjectSecurity.where(group_id: group.id,
                                                          project_id: @project.id,
                                                          project_security_level_id: prj_level.id,
                                                          is_model_permission: false).first %>
                          <td style="text-align: center">
                            <%= check_box_tag("group_securities_from_model[#{prj_level.id}][#{group.id}]", group.id, !ps.nil?, disabled: !can_alter_project_securities) %>
                          </td>
                        <% end %>
                      </tr>
                    <% end %>
                  </tbody>
                  <%= render :partial => 'layouts/footer_table' %>
                </table>

                <% if can_alter_estimation?(@project) && can?(:manage_project_security, @project) %>
                  <%= submit_tag I18n.t('save'), :name => "group_security_levels", :class => 'btn' %>
                  <%= submit_tag I18n.t('apply'), :name => "group_security_levels", :class => 'btn', :anchor_value => params[:anchor_value] %>
                <% end %>

                <%= link_to I18n.t('back'), organization_estimations_path(@organization), :class => 'btn' %>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div id="tabs-history">
      <%= hidden_field_tag "current_showed_project_id", @project.id %>
      <div id="project_tree_id" data-project_tree="<%= @projects_json_tree %>"></div>
      <%= render :partial => "show_project_tree_history", :object => [@projects_json_tree] %>
    </div>

    <script>
      $(document).ready(function () {
          $('.component_tree ul li, .widget-content ul li').hover(
              function () {
                  $('.block_link').hide();

              }
          );
      });
    </script>

  </div>
</div>