OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/views/deliverables/_deliverable_cost.rhtml

38 lines
2.1 KiB

<%-
index ||= "INDEX"
new_or_existing = deliverable_cost.new_record? ? 'new' : 'existing'
id_or_index = deliverable_cost.new_record? ? index : deliverable_cost.id
prefix = "deliverable[#{new_or_existing}_deliverable_cost_attributes][]"
id_prefix = "deliverable_#{new_or_existing}_deliverable_cost_attributes_#{id_or_index}"
classes ||= ""
@deliverable_cost = deliverable_cost
error_messages = error_messages_for 'deliverable_cost'
-%>
<% unless error_messages.blank? %><tr><td colspan="4"><%= error_messages %></td></tr><% end %>
<% fields_for prefix, deliverable_cost do |cost_form| %>
<tr class="cost_entry <%= classes %>" id="<%= id_prefix %>">
<td class="cost_units">
<%= cost_form.text_field :units, :index => id_or_index, :size => 3 %>
<span id="<%= "#{id_prefix}_unit_name" %>">
<%=h deliverable_cost.cost_type.unit_plural %>
</span>
</td>
<td class="cost_type">
<%= cost_form.select :cost_type_id, cost_types_collection_for_select_options, {}, {:index => id_or_index} %>
<%= observe_field( "#{id_prefix}_cost_type_id", :url => {:action => :update_deliverable_cost}, :with => "'cost_type_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('#{id_prefix}_units').value) + '&fixed_date=' + encodeURIComponent(document.getElementById('deliverable_fixed_date').value) + '&element_id=#{id_prefix}'") %>
<%= observe_field( "#{id_prefix}_units", :frequency => 1, :url => {:action => :update_deliverable_cost}, :with => "'cost_type_id=' + encodeURIComponent(document.getElementById('#{id_prefix}_cost_type_id').value) + '&units=' + encodeURIComponent(value) + '&fixed_date=' + encodeURIComponent(document.getElementById('deliverable_fixed_date').value) + '&element_id=#{id_prefix}'") %>
</td>
<td class="comment">
<%= cost_form.text_field :comments, :index => id_or_index, :size => 40 %>
</td>
<td class="currency">
<span id="<%= "#{id_prefix}_costs" %>"><%= number_to_currency(deliverable_cost.costs) %></span>
</td>
<td class="delete">
<%= image_to_function 'delete.png', "deleteDeliverableCost('#{id_prefix}')" %>
</td>
</tr>
<% end %>