Merge pull request #256 from ulferts/fix/invalid_user_inputs_on_rates

Fix/invalid user inputs on rates
pull/6827/head
ulferts 8 years ago committed by GitHub
commit 47fd820217
  1. 5
      app/controllers/hourly_rates_controller.rb
  2. 12
      app/views/cost_types/_rate.html.erb
  3. 11
      app/views/hourly_rates/_rate.html.erb

@ -105,7 +105,10 @@ class HourlyRatesController < ApplicationController
@rates = @user.default_rates
@rates << @user.default_rates.build(valid_from: Date.today) if @rates.empty?
else
@rates = @user.rates.select { |r| r.project_id == @project.id }.sort { |a, b| b.valid_from <=> a.valid_from }
@rates = @user
.rates
.select { |r| r.project_id == @project.id }
.sort { |a, b| b.valid_from || Date.today <=> a.valid_from || Date.today }
@rates << @user.rates.build(valid_from: Date.today, project: @project) if @rates.empty?
end
render action: 'edit', layout: !request.xhr?

@ -41,12 +41,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<tr class="subform-row <%= classes %>" id="<%= id_prefix %>">
<td>
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_valid_from" %>"><%= Rate.human_attribute_name(:valid_from) %></label>
<%= rate_form.text_field :valid_from, :size => 10, :class => 'date', :index => id_or_index %><%= calendar_for("#{id_prefix}_valid_from") %>
<%= rate_form.text_field :valid_from,
class: 'date',
index: id_or_index,
required: true %>
<%= calendar_for("#{id_prefix}_valid_from") %>
</td>
<td class="currency">
<span class="inline-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) : "" %>
<%= rate_form.text_field :rate,
size: 7,
index: id_or_index,
value: rate.rate ? rate.rate.round(2) : "",
required: true %>
<span class="form-label">
<%= Setting.plugin_openproject_costs['costs_currency'] %>
</span>

@ -34,12 +34,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<tr class="subform-row <%= classes %>" id="<%= id_prefix %>">
<td>
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_valid_from" %>"><%= Rate.human_attribute_name(:valid_from) %></label>
<%= rate_form.text_field :valid_from, :size => 10, :class => 'date', :index => id_or_index %><%= calendar_for("#{id_prefix}_valid_from") %>
<%= rate_form.text_field :valid_from,
class: 'date',
index: id_or_index,
required: true %>
<%= calendar_for("#{id_prefix}_valid_from") %>
</td>
<td class="currency">
<span class="inline-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) : "" %>
<%= rate_form.text_field :rate,
index: id_or_index,
value: rate.rate ? rate.rate.round(2) : "",
required: true %>
<span class="form-label">
<%= Setting.plugin_openproject_costs['costs_currency'] %>
</span>

Loading…
Cancel
Save