estimancy/projestimate

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

Summary

Maintainability
Test Coverage
<div class="tabs">
  <ul>
    <li><a href="#tabs-1"><%= I18n.t(:general) %> </a></li>
    <% if action_name.in?(%w(edit update)) %>
        <li><a href="#tabs-2"><%= I18n.t(:wbs_elements) %></a></li>
        <li><a href="#tabs-3"><%= I18n.t(:ratios) %> </a></li>
        <li><a href="#tabs-4"><%= I18n.t(:ratios_elements) %></a></li>
    <% end %>
  </ul>

    <div id="tabs-1">
      <%= simple_form_for(@wbs_activity) do |f| %>
        <%= f.error_notification %>

        <%= f.input :organization_id, as: :hidden, :input_html => { value: @organization_id } %>
        <% if controller.action_name == 'edit' and @wbs_activity.retired? %>
          <%= f.input :state, :label => I18n.t('state'), :as => :select, :collection => WbsActivity.aasm.states_for_select, :input_html => {:class => 'input-xxlarge'} %>
        <% else %>
          <%= f.input :name, :label => I18n.t('name'), :input_html => {:class => 'input-xxlarge', :autofocus => (controller.action_name == 'new')} %>
          <%= f.input :description, :label => I18n.t('description'), :input_html => {:class => 'input-xxlarge', :rows => 5} %>
          <%= f.input :three_points_estimation, :label => "Estimation 3 points" %>
          <%= f.input :enabled_input, label: "Modification des valeurs d'entrées" %>
          <%= f.input :effort_unit, :label => "Libellé de l'unité d'effort du module" %>
          <%= f.input :effort_unit_coefficient, :label => "Coefficient de conversion en effort standard" %>

        <% end %>

        <% if can? :manage_modules_instances, ModuleProject %>
          <% if action_name == 'new' || action_name=='create' %>
            <%= submit_tag I18n.t('apply'), :class => 'btn' %>
          <% elsif action_name == 'edit' || action_name=='update' %>
            <%= submit_tag I18n.t('save'), :class => 'btn' %>
            <%= submit_tag I18n.t('apply'), :class => 'btn' %>
          <% end %>
        <% end %>

        <%= link_to I18n.t('back'), organization_module_estimation_path(@organization_id, anchor: "activite"), :class => 'btn back' %>
      <% end %>
    </div>

    <% if action_name.in?(%w(edit update)) %>
        <div id="tabs-2">
          <div class="well component_tree">
            <%= raw generate_activity_element_tree(@wbs_activity_elements.first, '') %>
          </div>
        </div>

        <div id="tabs-3">
          <table border="0" width="100%">
            <tr>
              <td style="text-align:right;">
                <%= link_to I18n.t(:new_wbs_activity_ratio), new_wbs_activity_ratio_path(:activity_id => @wbs_activity.id), :class => 'btn' %>
              </td>
            </tr>
          </table>

          <table id="table_list_3" class="table tablesorterPager table-striped table-bordered table-condensed">
            <thead>
              <tr>
                <th><%= I18n.t(:name) %></th>
                <th><%= I18n.t(:description) %></th>
                <th class="action" colspan=5><%= I18n.t(:actions) %></th>
              </tr>
            </thead>
            <% @wbs_activity_ratios.each do |wbs_activity_ratio| %>
                <tr>
                  <td><%= link_to wbs_activity_ratio.name, edit_wbs_activity_path(@wbs_activity.id, :anchor => 'tabs-4') %></td>
                  <td><%= wbs_activity_ratio.description %></td>
                  <td class="align-center">
                    <%= link_to '', edit_wbs_activity_ratio_path(wbs_activity_ratio, :activity_id => wbs_activity_ratio.wbs_activity_id), :class => 'button_attribute_tooltip icon-pencil', :title => I18n.t(:edit) %>
                    <% if can? :manage_modules_instances, ModuleProject %>
                        <%= link_to '', wbs_activity_ratio, confirm: I18n.t(:are_you_sure), method: :delete, :class => 'button_attribute_tooltip icon-trash', :style => 'color:red', :title => I18n.t(:delete) %>
                        <%= link_to '', export_wbs_activity_ratios_path(wbs_activity_ratio), :class => 'button_attribute_tooltip icon-download', :title => I18n.t(:export) %>
                        <a href="#myWBSModal" role="button" class="button_attribute_tooltip icon-upload" data-toggle="modal" title="Import a CSV file"></a>
                    <% end %>
                  </td>
                </tr>

                <div id="myWBSModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <%= form_tag import_wbs_activity_ratios_path, :multipart => true, :class => 'simple_form' do %>
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                      <h3 id="myModalLabel"><%= I18n.t(:import) %> Wbs Activity Ratio</h3>
                    </div>
                    <div class="modal-body">
                      <label><%= I18n.t(:file_csv) %></label>
                      <%= file_field_tag :file %>

                      <label><%= I18n.t(:separator) %> '<%= I18n.t(:general_csv_separator) %>') </label>
                      <%= text_field_tag :separator %>

                      <label><%= I18n.t(:encoding) %></label>
                      <%= select_tag :encoding, options_for_select(Project::encoding, :selected => I18n.t(:general_csv_encoding)) %>


                      <%= hidden_field_tag :wbs_activity_ratio_id, wbs_activity_ratio.id %>

                    </div>
                    <div class="modal-footer">
                      <button class="btn" data-dismiss="modal" aria-hidden="true"><%= I18n.t(:close) %></button>
                      <%= submit_tag 'Import', :class => 'btn btn-primary', :onclick => "$('.loading').show();" %>
                    </div>
                    <div class="loading span11 hide">
                      <h4><%= I18n.t(:please_wait_import) %> <%= image_tag 'ajax-loader.gif' %> </h4>
                    </div>
                  <% end %>
                </div>

            <% end %>
            <%= render :partial => 'layouts/footer_table' %>
          </table>
        </div>

        <div id="tabs-4">
          <div class="pull-left">
            <%= I18n.t(:select_ratio_table) %>
            <%= select_tag 'Ratio', options_for_select(@wbs_activity_ratios.map { |i| [i.name, i.id] }, :selected => (params[:project_default_ratio] || @wbs_activity_ratio)), :class => 'select_ratio' %>
          </div>

          <%= form_tag '/save_values', :id => 'save_ratio_elt_reference', :remote => true, :class => 'simple_form' do %>
            <div id="ratio_section">
              <%= render :partial => 'wbs_activity_ratio_elements', :object => @wbs_activity_ratio_elements %>
            </div>
          <% end %>

          <br /><br />
          <!-- Table of of Ratio values per profile -->
          <div>
            <div class="pull-left">
              <h4 style="color: #0073ea;"><%= I18n.t(:wbs_ratio_per_profile) %></h4>
            </div><br>
            <%= form_tag save_wbs_activity_ratio_per_profile_path, remote: true, class: 'simple_form' do %>
              <div id="activities_ratio_per_profile">
                <%= render :partial => 'wbs_activities/activities_ratio_per_profile', :object => [@wbs_activity_ratio_elements, @wbs_organization_profiles] %>
              </div>
            <% end %>
          </div>

        </div>
    <% end %>

</div>