estimancy/projestimate

View on GitHub
app/views/organization_technologies/_abacus.html.erb

Summary

Maintainability
Test Coverage
<%= form_tag 'set_abacus', :method => 'POST', :class => 'simple_form' do %>
    <table>
      <tr>
        <td>
          <b><%= I18n.t(:text_organization_abacus) %></b>
        </td>
        <td>&nbsp;&nbsp; </td>
        <td>
          <%= select_tag 'technology', options_for_select(@organization.organization_technologies.map { |i| [i.name, i.id] }, :selected => @ot.nil? ? '' : @ot.id) %>
        </td>
      </tr>
    </table>

    <br/>

    <table id="table_list_8" class="table table-striped table-bordered table-condensed permissions">
      <tr>
        <th style="text-align:left;"><%= I18n.t(:organization_abacus) %></th>
        <% @complexities.each do |ouc| %>
            <th class="text-center">
              <% if ouc.state == 'retired' %>
                <span class="attribute_tooltip" style="font-style:italic; color:Red" title='<%= ouc.description %>'>
                  <%= ouc.name %>
                </span>
              <% elsif ouc.state == 'draft' %>
                <span class="attribute_tooltip" style="font-style:italic; color:DarkOrange " title='<%= ouc.description %>'>
                  <%= ouc.name %>
                </span>
              <% else %>
                <span class="attribute_tooltip" title='<%= ouc.description %>'>
                    <%= ouc.name %>
                </span>
              <% end %>
            </th>
        <% end %>
      </tr>

      <% if @unitofworks %>
          <% @unitofworks.each do |unit| %>
              <tr>
                <td style="text-align: right;">
                  <% if unit.state == 'retired' %>
                    <span class="attribute_tooltip" style="font-style:italic; color:Red" title='<%= unit.description %>'>
                        <%= unit.name %>
                    </span>
                  <% elsif unit.state == 'draft' %>
                    <span class="attribute_tooltip" style="font-style:italic; color:DarkOrange" title='<%= unit.description %>'>
                        <%= unit.name %>
                    </span>
                  <% else %>
                    <span class="attribute_tooltip" style="font-weight:bold" title='<%= unit.description %>'>
                        <%= unit.name %>
                    </span>
                  <% end %>

                </td>
                <% @complexities.each do |c| %>
                    <td style="text-align: center;">
                      <% a = AbacusOrganization.where(:unit_of_work_id => unit.id,
                                                      :organization_uow_complexity_id => c.id,
                                                      :organization_technology_id => @ot.id,
                                                      :organization_id => @organization.id).first %>
                      <%= text_field_tag "abacus[#{unit.id}][#{c.id}]", a.nil? ? '' : a.value, :class => 'span' %>
                    </td>
                <% end %>
              </tr>
          <% end %>
      <% end %>
    </table>
    <% if can? :edit_organizations, Organization %>
        <%= submit_tag I18n.t('save'), :class => 'btn' %>
        <%= submit_tag I18n.t('apply'), :class => 'btn' %>
        <a href="#myAbacusImportModal" role="button" class="btn" data-toggle="modal"><%= I18n.t('import') %></a>
    <% end %>
    <%= link_to I18n.t('export'), export_abacus_path(@organization.id), :class => 'btn' %>

<% end %>

<div id="myAbacusImportModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <%= form_tag import_abacus_path(@organization.id), :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) %> <%= I18n.t(:organization_abacus) %></h3>
      </div>
      <div class="modal-body">
        <label><%= I18n.t(:file_xls) %></label>
        <%= file_field_tag :file %>
      </div>
      <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true"><%= I18n.t(:cancel) %></button>
        <%= submit_tag I18n.t(: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>