estimancy/projestimate

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

Summary

Maintainability
Test Coverage
<div class="tabs">
  <ul>
    <% if @organization %>
      <li><a href="#tabs-1"><%= I18n.t(:text_organization_uow_complexity) %> </a></li>
    <% else %>
      <li><a href="#tabs-1">Complexity values used within Factor </a></li>
    <% end %>
  </ul>

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

      <%= f.error_notification %>

      <%= f.input :organization_id, :as => :hidden, :input_html => {:class => 'input-xxlarge', :value => params[:organization_id]} %>
      <%= f.input :name, :label => I18n.t('name'), :input_html => {:class => 'input-xxlarge', :autofocus => (controller.action_name == 'new')} %>
      <%= f.input :description, :label => I18n.t('criteria'), :input_html => {:class => 'input-xxlarge', :rows => 5} %>

      <% if params[:factor].present? %>
        <%= f.input :factor_id, as: :select, collection: Factor.order("factor_type").map{|i|["#{i.name} - #{i.factor_type.humanize}", i.id]}, selected: params[:factor].nil? ? @organization_uow_complexity.factor_id : params[:factor], include_blank: true %>
      <% else %>
        <%# f.input :unit_of_work_id, as: :select, collection: @organization.unit_of_works.map{|i|[i.name, i.id]} %>
      <% end %>

      <% if params[:organization_id].present? and !params[:factor].present? %>
        <%= f.input :unit_of_work_id, as: :select, collection: @organization.unit_of_works.map{|i|[i.name, i.id]}, selected: params[:uo_id] %>
      <% end %>

      <% if params[:organization_id].present? and !params[:factor].present? %>
        <%= f.input :organization_technology_id, as: :select, collection: @organization.organization_technologies.map{|i|[i.name, i.id]}, selected: params[:technology_id] %>
      <% end %>

      <table>
        <tr>
          <td><%= f.input :display_order, :label => I18n.t('display_order'), :input_html => {:class => 'input-small'} %></td>
          <td>&nbsp;&nbsp;&nbsp;</td>
          <td><%= f.input :state, :label => I18n.t('state'), :as => :select, :collection => OrganizationUowComplexity.aasm.states_for_select, :input_html => {:class => 'input-large'} %></td>
        </tr>
      </table>

      <table>
        <tr>
          <td>
            <%= f.association :record_status, :label => I18n.t('record_status'),
                              :collection => @organization_uow_complexity.record_status_collection,
                              :input_html => {:class => 'record_status'},
                              :selected => (@organization_uow_complexity.is_defined_or_nil? ? @proposed_status.id : @organization_uow_complexity.record_status_id),
                              :disabled => (true if @organization_uow_complexity.is_retired?) %>
          </td>
          <td>
            <%= f.input :custom_value, :label => I18n.t('custom_value'), :input_html => {:class => 'custom_value'}, :disabled => (true unless @organization_uow_complexity.is_custom?) %>
          </td>
        </tr>
      </table>
      <%= f.input :change_comment, :label => I18n.t('change_comment'), :input_html => {:class => 'input-xxlarge', :rows => 2} %>
      </div>

      <% if can? :edit_organizations, Organization %>
        <div class="actions-tabs">
          <% if action_name == 'new' || action_name=='create' %>
            <%= submit_tag I18n.t('save_and_create'), :class => 'btn' %>
            <%= submit_tag I18n.t('save'), :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 %>

      <% if @organization %>
        <%= link_to I18n.t('back'), organization_estimations_path(@organization || params[:organization_id], :anchor => 'tabs-cplx-factor'), :class => 'btn' %>
      <% else %>
        <%= link_to I18n.t('back'), factors_path, :class => 'btn' %>
      <% end %>
      </div>

    <% end %>
  </div>
</div>