app/views/works/_row.rhtml in backlog-0.26.0 vs app/views/works/_row.rhtml in backlog-0.28.0
- old
+ new
@@ -3,11 +3,61 @@
<% 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 %>
</td>
<td>
- <%=render :partial => 'row_field', :locals => {:field => 'description',
- :next_field => 'start_time', :next_row_id => next_row_id, :previous_row_id => previous_row_id} %>
+ <% 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' %>
+ <div id="work_<%=@work.id%>_notes_div" style="visibility: hidden; position: absolute; opacity: .8">
+ <%=text_area :work, :notes, :id => "work_#{@work.id}_#{field}",
+ :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 == 38) { // CTRL-UP-arrow
+ e = $('work_#{@work.id}_description');
+ e.focus();
+ //e.select();
+ } else if(event.keyCode == 38) { // Up-arrow
+ notes_field = $('work_#{@work.id}_#{field}');
+ if (notes_field.selectionStart == 0 || notes_field.value.indexOf('\\n') == -1 || notes_field.value.indexOf('\\n') > notes_field.selectionStart) {
+ description_field = $('work_#{@work.id}_description');
+ description_field.focus();
+ //description_field.select();
+ return false;
+ }
+ }",
+ :onBlur => "
+ $('work#{"_#{@work.id}"}_notes_div').style.visibility = 'hidden';
+ ",
+ :value => @work.send(field),
+ :cols => 80
+ %>
+ </div>
+ <% end %>
+
</span>
<td align="right">
<%=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} %>
</td>