Merge pull request #29 from finnlabs/feature/fix-rate-form-enter-keypress

Feature/fix rate form enter keypress
pull/6827/head
sschu 12 years ago
commit 9e32a4420d
  1. 51
      app/assets/javascripts/costs/rates.js
  2. 4
      app/views/cost_types/_list_deleted.html.erb
  3. 4
      app/views/cost_types/_rate.html.erb
  4. 1
      app/views/cost_types/edit.html.erb
  5. 4
      app/views/hourly_rates/_rate.html.erb
  6. 1
      app/views/hourly_rates/edit.html.erb

@ -1,30 +1,29 @@
function addRate(date_field) { function addRate(date_field){
var my_date = date_field.value; RatesForm.add_on_top();
var date_elements = $(RatesForm.parentElement).select('input.date');
var highest_date = null; var newRateRow = $(RatesForm.parentElement).down("tr");
for (var e in date_elements) { var validFromField = newRateRow.down('input.date')
if (e.value > my_date) { validFromField.value = jQuery.datepicker.formatDate('yy-mm-dd', new Date());
highest_date = e; newRateRow.down('td.currency').down('input').select();
} else { }
break;
}
}
switch (highest_date) { function disableEnterKey(event){
case null: if (event.keyCode == 13) event.preventDefault();
RatesForm.add_on_top() }
var e = $(RatesForm.parentElement).down("tr");
break;
default:
var after = highest_date.up('tr');
RatesForm.add_after(after);
var e = after.next();
break;
}
var new_date_field = e.down('input.date') function deleteRow(image){
new_date_field.value = date_field.value; var row = image.up("tr")
date_field.value = ""; var parent=row.up();
e.down('td.currency').down('input').select(); row.remove();
recalculate_even_odd(parent);
} }
jQuery(function(jQuery){
jQuery(document).on("keydown", "body.action-edit input", function(event){
disableEnterKey(event);
});
jQuery(document).on("click", "body.action-edit img.delete", function(){
deleteRow(this);
});
});

@ -6,8 +6,8 @@
<table class="list cost_types deleted_cost_types"> <table class="list cost_types deleted_cost_types">
<thead><tr> <thead><tr>
<%= sort_header_tag "name", :caption => CostType.model_name.human %> <%= sort_header_tag "name", :caption => CostType.model_name.human %>
<%= sort_header_tag "unit", :caption => l(:caption_cost_type_unit_name) %> <%= sort_header_tag "unit", :caption => CostType.human_attribute_name(:unit) %>
<%= sort_header_tag "unit_plural", :caption => l(:caption_cost_type_unit_name_plural) %> <%= sort_header_tag "unit_plural", :caption => CostType.human_attribute_name(:unit_plural) %>
<th><%= CostType.human_attribute_name(:current_rate) %></th> <th><%= CostType.human_attribute_name(:current_rate) %></th>
<th><%= l(:caption_locked_on) %></th> <th><%= l(:caption_locked_on) %></th>
<th></th> <th></th>

@ -21,8 +21,8 @@
</td> </td>
<td class="currency"> <td class="currency">
<label class="hidden-for-sighted", for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label> <label class="hidden-for-sighted", for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label>
<%= rate_form.text_field :rate, :size => 7, :index => id_or_index, :value => rate.rate ? rate.rate.round(2) : "" %> <%= Setting.plugin_openproject_costs['costs_currency'] %> <%= rate_form.text_field :rate, :size => 7, :index => id_or_index, :value => rate.rate ? rate.rate.round(2) : "" %> <%= Setting.plugin_openproject_costs['costs_currency'] %>
</td> </td>
<td><%= image_to_function 'delete.png', "var e = $('#{id_prefix}');parent=e.up();e.remove();recalculate_even_odd(parent)", {:alt => l(:button_delete), :title => l(:button_delete)}%></td> <td><%= image_tag 'delete.png', :alt => l(:button_delete), :title => l(:button_delete), :class => 'delete' %></td>
</tr> </tr>
<% end %> <% end %>

@ -42,7 +42,6 @@
<div> <div>
<div> <div>
<label class="hidden-for-sighted", for="add_rate_date" %>"><%= l(:description_date_for_new_rate) %></label> <label class="hidden-for-sighted", for="add_rate_date" %>"><%= l(:description_date_for_new_rate) %></label>
<%= text_field_tag :add_rate_date, "", :size => 10, :value => Date.today %><%= calendar_for("add_rate_date") %>
<%= link_to_function l(:button_add_rate), "addRate($('add_rate_date'))", {:class => "icon icon-add"} %> <%= link_to_function l(:button_add_rate), "addRate($('add_rate_date'))", {:class => "icon icon-add"} %>
</div> </div>
<div><%= submit_tag l(:button_save) %></div> <div><%= submit_tag l(:button_save) %></div>

@ -21,8 +21,8 @@
</td> </td>
<td class="currency"> <td class="currency">
<label class="hidden-for-sighted", for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label> <label class="hidden-for-sighted", for="<%= "#{id_prefix}_rate" %>"><%= Rate.model_name.human %></label>
<%= rate_form.text_field :rate, :size => 7, :index => id_or_index, :value => rate.rate ? rate.rate.round(2) : "" %> <%= Setting.plugin_openproject_costs['costs_currency'] %> <%= rate_form.text_field :rate, :size => 7, :index => id_or_index, :value => rate.rate ? rate.rate.round(2) : "" %> <%= Setting.plugin_openproject_costs['costs_currency'] %>
</td> </td>
<td><%= image_to_function 'delete.png', "var e = $('#{id_prefix}');parent=e.up();e.remove();recalculate_even_odd(parent)", :alt => l(:button_delete) %></td> <td><%= image_tag 'delete.png', :alt => l(:button_delete), :title => l(:button_delete), :class => "delete" %></td>
</tr> </tr>
<% end %> <% end %>

@ -28,7 +28,6 @@
<div> <div>
<div> <div>
<label class="hidden-for-sighted", for="add_rate_date" %>"><%= l(:description_date_for_new_rate) %></label> <label class="hidden-for-sighted", for="add_rate_date" %>"><%= l(:description_date_for_new_rate) %></label>
<%= text_field_tag :add_rate_date, "", :size => 10, :value => Date.today %><%= calendar_for("add_rate_date") %>
<%= link_to_function l(:button_add_rate), "addRate($('add_rate_date'))", {:class => "icon icon-add"} %> <%= link_to_function l(:button_add_rate), "addRate($('add_rate_date'))", {:class => "icon icon-add"} %>
</div> </div>
<div><%= submit_tag l(:button_save) %></div> <div><%= submit_tag l(:button_save) %></div>

Loading…
Cancel
Save