<%- 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}" @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.current_rate(@project.id)}.collect{|u| [u.name, u.id]}, {:prompt => true}, {:index => id_or_index} %> <%= cost_form.hidden_field :rate_id, :index => id_or_index %> <% if User.current.allowed_to?(:view_all_rates, @project) || User.current.allowed_to?(:view_own_rate, @project) %> "><%= number_to_currency(deliverable_hour.costs) if deliverable_hour.can_view_costs?(User.current, @project) %> <%= observe_field( "#{id_prefix}_user_id", :url => {:action => :update_deliverable_hour}, :with => "'user_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('#{id_prefix}_hours').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) + '&element_id=#{id_prefix}'") %> <% end %> <%= image_to_function 'delete.png', "deleteDeliverableHour('#{id_prefix}')" %> <% end %>