estimancy/projestimate

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

Summary

Maintainability
Test Coverage
<div class="tabs">
  <ul>
    <li><a href="#tabs-project-areas"><%= I18n.t(:project_areas) %></a></li>
    <li><a href="#tabs-project-categories"><%= I18n.t(:project_categories) %></a></li>
    <li><a href="#tabs-platform-categories"><%= I18n.t(:platform_categories) %></a></li>
    <li><a href="#tabs-acquisition-categories"><%= I18n.t(:acquisition_categories) %></a></li>
    <li><a href="#tabs-wet"><%= I18n.t(:label_WorkElementType) %></a></li>
    <li><a href="#tabs-technology"><%= I18n.t(:organization_technology) %> </a></li>
    <li><a href="#tabs-estimations-statuses"><%= I18n.t(:estimations_statuses) %> </a></li>
    <li><a href="#tabs-profile"><%= I18n.t(:profiles) %></a></li>
    <li><a href="#tabs-fields"><%= I18n.t(:fields) %></a></li>
    <li><a href="#tabs-size_unit"><%= I18n.t(:size_unit) %></a></li>
    <li><a href="#tabs-estimation-models"><%= I18n.t(:estimation_models) %></a></li>
    <li><a href="#tabs-views"><%= I18n.t(:views) %></a></li>
    <li><a href="#tabs-select-columns-list"><%= I18n.t(:select_columns_list) %></a></li>
  </ul>

  <div id="tabs-project-areas">
    <% if can? :show_project_areas, ProjectArea %>

      <% if can? :manage, ProjectArea %>
         <%= link_to I18n.t('new_project_area'), new_organization_project_area_path(@organization), :class => 'btn pull-right' %>
      <% end %>

      <table id="table_list_1" class="table tablesorterPager table-striped table-bordered table-condensed">
        <thead>
        <tr>
          <th><%= I18n.t('name') %></th>
          <th><%= I18n.t('description') %></th>
          <th class="action"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>

        <tbody>
        <% @organization.project_areas.each do |pa| %>
          <tr>
            <td><%= pa.name %></td>
            <td><%= pa.description %></td>
            <td class="center">
              <%= link_to '', edit_organization_project_area_path(@organization, pa), :class => 'icon-pencil' %>
              <% if can? :manage, ProjectArea %>
                  <%= link_to '', organization_project_area_path(@organization, pa), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :title => I18n.t('delete') %>
              <% end %>
            </td>
          </tr>
        <% end %>
        <%= render :partial => 'layouts/footer_table' %>
        </tbody>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_project_areas) %></div>
    <% end %>
  </div>


  <div id="tabs-project-categories">
    <% if can? :show_project_categories, ProjectCategory %>

      <% if can? :manage, ProjectCategory %>
        <%= link_to I18n.t('new_project_category'), new_organization_project_category_path(@organization), :class => 'btn pull-right' %>
      <% end %>

      <table id="table_list_2" 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="2"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>

        <tbody>
        <% @organization.project_categories.each do |i| %>
          <tr>
            <td><%= i.name %></td>
            <td><%= i.description %></td>
            <td class="center">
              <%= link_to '', edit_organization_project_category_path(@organization, i), :class => 'icon-pencil' %>
              <% if can? :manage, ProjectCategory %>
                  <%= link_to '', organization_project_category_path(@organization, i), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :title => I18n.t('delete') %>
              <% end %>
            </td>
          </tr>
        <% end %>

        <%= render :partial => 'layouts/footer_table' %>
        </tbody>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_project_categories) %></div>
    <% end %>
  </div>

  <div id="tabs-platform-categories">
    <% if can? :show_platform_categories, PlatformCategory %>

      <% if can? :manage, PlatformCategory %>
         <%= link_to I18n.t('new_platform_category'), new_organization_platform_category_path(@organization), :class => 'btn pull-right' %>
      <% end %>

      <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="2"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>
        <tbody>
        <% @organization.platform_categories.each do |i| %>
          <tr>
            <td><%= i.name %></td>
            <td><%= i.description %></td>
            <td class="center">
              <%= link_to '', edit_organization_platform_category_path(@organization, i), :class => 'icon-pencil' %>
              <% if can? :manage, PlatformCategory %>
                  <%= link_to '', organization_platform_category_path(@organization, i), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :title => I18n.t('delete') %>
              <% end %>
            </td>
          </tr>
        <% end %>
        <%= render :partial => 'layouts/footer_table' %>
        </tbody>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_platform_categories) %></div>
    <% end %>
  </div>

  <div id="tabs-wet">
    <% if can? :show_work_element_types, WorkElementType %>
      <% if can? :manage, WorkElementType %>
         <%= link_to I18n.t(:new_work_element_type), new_organization_work_element_type_path(@organization), :class => 'btn pull-right' %>
      <% end %>

      <table id="table_list_4" class="table tablesorterPager table-striped table-bordered table-condensed">
        <thead>
        <tr>
          <th><%= I18n.t(:name) %></th>
          <th><%= I18n.t(:alias) %></th>
          <th><%= I18n.t(:description) %></th>
          <th class="action" colspan="2"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>
        <tbody>
        <% @work_element_types.each do |work_element_type| %>
          <tr>
            <td><%= work_element_type.name %></td>
            <td><%= work_element_type.alias %></td>
            <td><%= work_element_type.description %></td>
            <td class="center">
              <%= link_to '', edit_organization_work_element_type_path(@organization, work_element_type), :class => 'icon-pencil' %>
              <% if can? :manage, WorkElementType %>
                  <%= link_to '',  organization_work_element_type_path(@organization, work_element_type), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :title => I18n.t('delete') %>
              <% end %>
            </td>
          </tr>
        <% end %>
        </tbody>
        <%= render :partial => 'layouts/footer_table' %>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_work_element_types) %></div>
    <% end %>
  </div>


  <div id="tabs-acquisition-categories">
    <% if can? :show_acquisition_categories, AcquisitionCategory %>
      <% if can? :manage, AcquisitionCategory %>
         <%= link_to I18n.t('new_acquisition_category'), new_organization_acquisition_category_path(@organization), :class => 'btn pull-right' %>
      <% end %>

      <table id="table_list_5" 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="2"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>

        <tbody>
        <% @organization.acquisition_categories.each do |i| %>
          <tr>
            <td><%= i.name %></td>
            <td><%= i.description %></td>
            <td class="center">
              <%= link_to '', edit_organization_acquisition_category_path(@organization, i), :class => 'icon-pencil' %>
              <% if can? :manage, AcquisitionCategory %>
                  <%= link_to '',  organization_acquisition_category_path(@organization, i), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :title => I18n.t('delete') %>
              <% end %>
            </td>
          </tr>
        <% end %>
        <%= render :partial => 'layouts/footer_table' %>
        </tbody>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_acquisition_categories) %></div>
    <% end %>
  </div>

  <div id="tabs-technology">
    <b><%= I18n.t(:text_organization_technology) %></b>
    <br>
    <% if can? :show_organization_technologies, OrganizationTechnology %>

      <% if can? :manage, OrganizationTechnology %>
        <%= link_to I18n.t('new_organization_technology'), new_organization_technology_path(:organization_id => @organization.id), :class => 'btn pull-right' %>
      <% end %>

      <table id="table_list_6" class="table tablesorterPager table-striped table-bordered table-condensed">
        <thead>
        <tr>
          <th><%= I18n.t(:name) %></th>
          <th><%= I18n.t(:alias) %></th>
          <th><%= I18n.t(:description) %></th>
          <th><%= I18n.t(:productivity_ratio) %></th>
          <th class="action" colspan="2"><%= I18n.t(:actions) %></th>
        </tr>
        </thead>
        <tbody>
        <% @organization.organization_technologies.each do |ot| %>
          <% if ot.state == 'retired' %>
            <tr style="font-style:italic; color:Red">
          <% elsif ot.state == 'draft' %>
            <tr style="font-style:italic; color:DarkOrange ">
          <% else %>
            <tr>
          <% end %>
          <td><%= ot.name %></td>
          <td><%= ot.alias %></td>
          <td><%= ot.description %></td>
          <td><%= ot.productivity_ratio %></td>
          <td class="center">
            <%= link_to '', edit_organization_technology_path(ot.id, :organization_id => @organization.id), :class => 'icon-pencil', :title => I18n.t('edit') %>
            <% if can? :manage, OrganizationTechnology %>
              <%= link_to '', ot, confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :style => 'color:red', :title => I18n.t('delete') %>
            <% end %>
          </td>
          </tr>
        <% end %>

        <%= render :partial => 'layouts/footer_table' %>
        </tbody>
      </table>
    <% else %>
      <div class="red_color"><%= I18n.t(:notice_cannot_view_organization_technologies) %></div>
    <% end %>
  </div>

  <div id="tabs-fields">
    <b><%= I18n.t(:fields) %></b>

    <% if can? :show_custom_fields, Field %>
        <% if can? :manage, Field %>
            <%= link_to I18n.t(:new_field), new_organization_field_path(@organization), class: "btn pull-right" %>
        <% end %>

        <table class="table table-striped table-bordered table-condensed">
          <tr>
            <th><%= I18n.t(:name) %></th>
            <th><%= I18n.t(:coefficient) %></th>
            <th class="action" colspan="2"><%= I18n.t(:actions) %></th>
          </tr>

          <% @fields.each do |field| %>
            <tr>
              <td><%= field.name %></td>
              <td><%= field.coefficient %></td>
              <td class="center span3">
                <%= link_to '', edit_organization_field_path(@organization, field), :class => 'icon-pencil' %>
                <% if can? :manage, Field %>
                    <%= link_to '', field, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'icon-trash', :title => I18n.t('delete') %>
                <% end %>
              </td>
            </tr>
          <% end %>
        </table>
    <% else %>
        <div class="red_color"><%= I18n.t(:notice_cannot_view_organization_fields) %></div>
    <% end %>
  </div>

  <div id="tabs-profile">
    <b><%= I18n.t(:profiles) %></b>
    <% if can? :show_organization_profiles, OrganizationProfile %>
        <%= render :partial => 'organizations/profiles' %>
    <% else %>
        <div class="red_color"><%= I18n.t(:notice_cannot_view_organization_profiles) %></div>
    <% end %>
    <br><br>
  </div>

  <div id="tabs-estimations-statuses" style="min-height: 50px;">
    <br>
    <% if can? :show_estimation_statuses, EstimationStatus %>
        <% if can? :manage, EstimationStatus %>
            <%= link_to I18n.t('new_estimation_status'), new_estimation_status_path(:organization_id => @organization.id), :class => 'btn pull-right' %>
        <% end %>
        <%= render "estimation_statuses/statuses_management", object: [@organization, @organization_group] %>
    <% else %>
        <div class="red_color"><%= I18n.t(:notice_cannot_view_estimation_statuses) %></div>
    <% end %>
  </div>

  <div id="tabs-size_unit">
    <table class="table table-bordered">
      <tr>
        <th>Name</th>
        <th>Alias</th>
        <th>Description</th>
        <th></th>
        <th></th>
      </tr>

      <% @organization.size_unit_types.each do |size_unit_type| %>
        <tr>
          <td><%= size_unit_type.name %></td>
          <td><%= size_unit_type.alias %></td>
          <td><%= size_unit_type.description %></td>
          <td><%= link_to 'Edit', edit_size_unit_type_path(size_unit_type, organization_id: @organization.id) %></td>
          <td><%= link_to 'Destroy', size_unit_type, method: :delete, data: { confirm: 'Are you sure?' } %></td>
        </tr>
      <% end %>
    </table>

    <br />

    <%= link_to 'New Size unit type', new_size_unit_type_path(organization_id: @organization.id) %>
  </div>

  <div id="tabs-estimation-models">
    <b><%= I18n.t(:estimation_models) %></b>

    <%# if can? :show_estimation_models, Project %>
      <%= render partial: "projects/estimation_models", object: @estimation_models %>
    <%# else %>
        <!--<div class="red_color"><%#= I18n.t(:notice_cannot_view_estimation_models) %></div>-->
    <%# end %>
  </div>

  <div id="tabs-views">
    <% if can? :show_views, View %>

        <% if can? :manage, View %>
            <%= link_to I18n.t('new_view'), new_organization_view_path(@organization), :class => 'btn btn-primary pull-right' %>
        <% end %>
        <%= render partial: "views/views_and_widgets" %>
    <% else %>
        <div class="red_color"><%= I18n.t(:notice_cannot_view_views_and_widgets) %></div>
    <% end %>
  </div>

  <div id="tabs-select-columns-list" style="min-height: 50px;">
    <b><%= I18n.t(:select_columns_list) %></b>
    <br>
    <% if can? :show_projects_selected_columns, Organization %>
        <%= render partial: "organizations/select_project_columns_to_display" %>
    <% else %>
        <div class="red_color"><%= I18n.t(:notice_cannot_view_selected_columns_list) %></div>
    <% end %>
  </div>

</div>