opf/openproject

View on GitHub
modules/budgets/app/views/budgets/subform/_material_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.

++#%>

<% template_object = @budget.material_budget_items.build(cost_type: CostType.default) %>

<% if CostType.exists? %>
  <fieldset id="material_budget_items_fieldset"
            class="form--fieldset -collapsible"
            data-controller="costs--budget-subform"
            data-application-target="dynamic"
            data-costs--budget-subform-item-count-value="<%= @budget.material_budget_items.length %>"
            data-costs--budget-subform-update-url-value="<%=url_for(action: :update_material_budget_item, project_id: @project.id) %>">
    <legend class="form--fieldset-legend"><%= Budget.human_attribute_name(:material_budget) %></legend>
      <div class="generic-table--container">
        <div class="generic-table--results-container">
          <table class="generic-table" id="material_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>
                      <%= MaterialBudgetItem.human_attribute_name(:units) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= CostType.human_attribute_name(:unit) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= MaterialBudgetItem.human_attribute_name(:cost_type) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= MaterialBudgetItem.human_attribute_name(:comment) %>
                    </span>
                  </div>
                </div>
              </th>
              <% if User.current.allowed_in_project?(:view_cost_rates, @project)%>
                <th class="currency" id="material_budget_items_price">
                  <div class="generic-table--sort-header-outer">
                    <div class="generic-table--sort-header">
                      <span>
                        <%= MaterialBudgetItem.human_attribute_name(:budget) %>
                      </span>
                    </div>
                  </div>
                </th>
              <%end%>
              <th></th>
            </tr>
          </thead>
          <tbody
            id="material_budget_items_body"
            class="budget-item-container"
            data-costs--budget-subform-target="table">
            <%- @budget.material_budget_items.each_with_index do |material_budget_item, index| -%>
              <%= render partial: 'budgets/items/material_budget_item', object: material_budget_item, locals: {index: index} %>
            <%- end -%>
          </tbody>
        </table>

      </div>
    </div>
    <div class="wp-inline-create-button">
      <a class="budget-add-row wp-inline-create--add-link"
         role="button"
         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/material_budget_item",
                 object: template_object,
                 locals: { templated: true } %>
    </table>
  </fieldset>
<% end %>