<% remote_form_for :work, :url => {:action => :update_row, :id => @work.id, :next_field => :description}, :html => {:id => "work_#{@work.id}_form"} do |f|%> <%=f.select :work_account_id, @work_accounts.map {|wa| [wa.name, wa.id]}, {}, :id => "work_#{@work.id}_work_account_id", :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?next_field=customer_id', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)})"%> <% end %> <% field = 'description' %> <% next_field = 'start_time' %> <% previous_row_id = previous_row_id %> <% remote_form_for :work, :url => {:action => :update_row, :id => @work.id, :field=>field, :next_field => next_field} do |f|%> <%=text_field :work, field, :id => "work_#{@work.id}_#{field}", :class => ('task_time' if field=~/_time$/), :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?field=#{field}&next_field=#{next_field}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)});", :onkeypress => " if(event.ctrlKey && event.keyCode == 40) { // CTRL-Down-arrow $('work#{"_#{@work.id}"}_notes_div').style.visibility = 'visible'; e = $('work_#{@work.id}_notes'); e.focus(); // e.select(); } else if(event.keyCode == 40) { // Down-arrow e = $('work#{"_#{next_row_id}" if next_row_id}_#{field}'); e.focus(); e.select(); } else if(event.keyCode == 38) { // Up-arrow e = $('work#{"_#{previous_row_id}" if previous_row_id}_#{field}'); e.focus(); e.select(); }", :value => (field=~/_time$/ ? @work.send(field) && @work.send(field).strftime('%H:%M') : @work.send(field) ) %> <% field = 'notes' %> <% next_field = 'description' %> <% end %> <%=render :partial => 'row_field', :locals => {:field => 'start_time', :next_field => 'completed_at_time', :next_row_id => next_row_id, :previous_row_id => previous_row_id} %> <%=render :partial => 'row_field', :locals => {:field => 'completed_at_time', :next_field => 'hours_time', :next_row_id => next_row_id, :previous_row_id => previous_row_id} %> <% remote_form_for :work, :url => {:action => :update_row, :id => @work.id, :next_field => :task_id} do |f|%> <%=f.text_field :hours_time, :value => (@work.hours && @work.hours > 0 ? t(@work.hours) : ''), :id => "work_#{@work.id}_hours_time", :class => 'task_hours', :onkeypress => " if(event.keyCode == 40) { e = $('work#{"_#{next_row_id}" if next_row_id}_hours_time'); e.focus(); e.select(); } else if(event.keyCode == 38) { e = $('work#{"_#{previous_row_id}" if previous_row_id}_hours_time'); e.focus(); e.select(); }", :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?next_field=task_id', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)})"%> <% end %> <% remote_form_for :work, :url => {:action => :update_row, :id => @work.id, :next_field => :invoice} do |f|%> <%=text_field_with_auto_complete "work_#{@work.id}", :task_id, {:name => "work[task_id]", :value => @work.task_id, :class => :task_id, :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?next_field=invoice', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)})"}, {:url => url_for(:action => :auto_complete_for_work_task_id), :with => "'work[task_id]=' + $('work_#{@work.id}_task_id').value"} %> <% if @work.task_id %> <%=image_detour_to('task.png', "#{l :task}: #{@work.task.description}", {:controller => 'tasks', :action => :edit, :id => @work.task.id})%> <% end %> <% end %> <% remote_form_for :work, :url => {:action => :update_row, :id => @work.id} do |f|%> <%=f.check_box :invoice, :id => "work_#{@work.id}_invoice", :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?next_field=invoice', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)})"%> <% end %> <% remote_form_for :work, :url => {:action => :update_row, :id => @work.id, :next_field => :description} do |f|%> <%=f.select :customer_id, [['', '']] + @customers.map {|cu| [cu.name, cu.id]}, {}, :id => "work_#{@work.id}_customer_id", :onchange => "new Ajax.Request('/works/update_row/#{@work.id}?next_field=description', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)})"%> <% end %> <%=image_detour_to('delete.png', l(:delete), {:controller => 'works', :action => :destroy, :id => @work, :confirm => true}, nil, true)%> <% if @work.task %> <%=l :task%>: <%=h @work.task.description_with_parents if @work.task%> <% end %>