<%- index ||= "INDEX" new_or_existing = deliverable_hour.new_record? ? 'new' : 'existing' id_or_index = deliverable_hour.new_record? ? index : deliverable_hour.id prefix = "deliverable[#{new_or_existing}_deliverable_hour_attributes][]" id_prefix = "deliverable_#{new_or_existing}_deliverable_hour_attributes_#{id_or_index}" name_prefix = "deliverable[#{new_or_existing}_deliverable_hour_attributes][#{id_or_index}]" classes ||= "" @deliverable_hour = deliverable_hour error_messages = error_messages_for 'deliverable_hour' -%> <%if error_messages %><%= error_messages %><% end %> <% fields_for prefix, deliverable_hour do |cost_form| %> <%= cost_form.text_field :hours, :index => id_or_index, :size => 3 %> <%= cost_form.select :user_id, @project.assignable_users.sort.select{|u| u.rate_at(@deliverable.fixed_date, @project)}.collect{|u| [u.name, u.id]}, {:prompt => true}, {:index => id_or_index} %> <%= cost_form.text_field :comments, :index => id_or_index, :size => 40 %> "><%= number_to_currency(deliverable_hour.calculated_costs) if deliverable_hour.can_view_costs?(User.current, @project) %> <%= update_page_tag do |page| page << "makeEditable('#{id_prefix}_costs', '#{name_prefix}[budget]');" page << "edit($('#{id_prefix}_costs'), '#{name_prefix}[budget]', '#{number_to_currency(deliverable_hour.budget)}');" if deliverable_hour.budget end %> <%= observe_field( "#{id_prefix}_user_id", :url => {:action => :update_deliverable_hour}, :with => "'user_id=' + encodeURIComponent(value) + '&hours=' + encodeURIComponent(document.getElementById('#{id_prefix}_hours').value) + '&fixed_date=' + encodeURIComponent(document.getElementById('deliverable_fixed_date').value) + '&element_id=#{id_prefix}'") %> <%= observe_field( "#{id_prefix}_hours", :frequency => 1, :url => {:action => :update_deliverable_hour}, :with => "'user_id=' + encodeURIComponent(document.getElementById('#{id_prefix}_user_id').value) + '&hours=' + encodeURIComponent(value) + '&fixed_date=' + encodeURIComponent(document.getElementById('deliverable_fixed_date').value) + '&element_id=#{id_prefix}'") %> <%= image_to_function 'delete.png', "deleteDeliverableHour('#{id_prefix}')" %> <% end %>