opf/openproject

View on GitHub
modules/budgets/app/views/budgets/subform/_labor_budget_subform.html.erb

Summary

Maintainability
Test Coverage
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2024 the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>

<%# we have to assign the budget here as following methods depend on the item having an object -%>
<% template_object = @budget.labor_budget_items.build.tap do |i|
  i.budget = @budget
end -%>

<fieldset id="labor_budget_items_fieldset"
          class="form--fieldset -collapsible"
          data-controller="costs--budget-subform"
          data-application-target="dynamic"
          data-costs--budget-subform-item-count-value="<%= @budget.labor_budget_items.length %>"
          data-costs--budget-subform-update-url-value="<%= url_for(action: :update_labor_budget_item, project_id: @project.id) %>">
  <legend class="form--fieldset-legend"><%= Budget.human_attribute_name(:labor_budget) %></legend>
  <div class="generic-table--container">
    <div class="generic-table--results-container">
      <table class="generic-table" id="labor_budget_items">
        <colgroup>
          <col opHighlightCol>
          <col opHighlightCol>
          <col opHighlightCol>
          <% if User.current.allowed_in_project?(:view_cost_rates, @project)%>
            <col opHighlightCol>
          <%end%>
          <col>
        </colgroup>
        <thead>
          <tr>
            <th class="cost_units">
              <div class="generic-table--sort-header-outer">
                <div class="generic-table--sort-header">
                  <span>
                    <%= LaborBudgetItem.human_attribute_name(:hours) %>
                  </span>
                </div>
              </div>
            </th>
            <th>
              <div class="generic-table--sort-header-outer">
                <div class="generic-table--sort-header">
                  <span>
                    <%= LaborBudgetItem.human_attribute_name(:user) %>
                  </span>
                </div>
              </div>
            </th>
            <th>
              <div class="generic-table--sort-header-outer">
                <div class="generic-table--sort-header">
                  <span>
                    <%= LaborBudgetItem.human_attribute_name(:comment) %>
                  </span>
                </div>
              </div>
            </th>
            <% if User.current.allowed_in_project?(:view_cost_rates, @project)%>
              <th class="currency" id="labor_budget_items_price">
                <div class="generic-table--sort-header-outer">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= LaborBudgetItem.human_attribute_name(:budget) %>
                    </span>
                  </div>
                </div>
              </th>
            <%end%>
            <th></th>
          </tr>
        </thead>
        <tbody id="labor_budget_items_body"
               class="budget-item-container"
               data-costs--budget-subform-target="table">
          <%- @budget.labor_budget_items.each_with_index do |labor_budget_item, index| -%>
            <%= render partial: 'budgets/items/labor_budget_item', object: labor_budget_item, locals: {index: index} %>
          <%- end -%>
        </tbody>
      </table>

    </div>
  </div>
  <div class="wp-inline-create-button">
    <a href="#"
       class="budget-add-row wp-inline-create--add-link"
       role="link"
       title="<%= t(:button_add_budget_item) %>"
       data-action="costs--budget-subform#addRow">
      <%= op_icon('icon icon-add') %>
    </a>
  </div>
  <table style="display:none"
         data-costs--budget-subform-target="template">
    <%= render partial: "budgets/items/labor_budget_item", object: template_object, locals: { templated: true } %>
  </table>
</fieldset>