From 3abfe6253c489e8b87d0af913ce57fddf755d5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 30 Nov 2015 13:58:22 +0100 Subject: [PATCH] Use correct form helpers for cost types --- app/views/costlog/edit.html.erb | 45 +++++++++++++++------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/app/views/costlog/edit.html.erb b/app/views/costlog/edit.html.erb index fe552d04af..34de40ed1d 100644 --- a/app/views/costlog/edit.html.erb +++ b/app/views/costlog/edit.html.erb @@ -18,24 +18,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++#%> -<%= render :partial => 'shared/costs_header' %> +<%= render partial: 'shared/costs_header' %>

<%= l(:label_log_costs) %>

<% url = @cost_entry.new_record? ? - { :action => 'create', :project_id => @project.id } : - { :action => 'update', :id => @cost_entry } %> + { action: 'create', project_id: @project.id } : + { action: 'update', id: @cost_entry } %> <% method = @cost_entry.new_record? ? :post : :put %> -<%= labelled_tabular_form_for @cost_entry, :url => url, :html => { :method => method } do |f| %> +<%= labelled_tabular_form_for @cost_entry, url: url, html: { method: method } do |f| %> <%= error_messages_for 'cost_entry' %> <%= back_url_hidden_field_tag %>
- <%= f.text_field :work_package_id, :size => 6, :required => true %> + <%= f.text_field :work_package_id, size: 6, required: true %> <% if @cost_entry.work_package %>
@@ -44,35 +44,32 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <% end %>
- <%= f.text_field :spent_on, :size => 10, :required => true %> + <%= f.text_field :spent_on, size: 10, required: true %> <%= calendar_for('cost_entry_spent_on') %>
<% if User.current.allowed_to? :log_costs, @project %>
- <%= f.select :user_id, user_collection_for_select_options, :required => true %> + <%= f.select :user_id, user_collection_for_select_options, required: true %>
<% else %> - <%= f.hidden_field :user_id, :value => User.current.id %> + <%= f.hidden_field :user_id, value: User.current.id %> <% end %>
- <%= f.select :cost_type_id, cost_types_collection_for_select_options, :required => true %>

+ <%= f.select :cost_type_id, cost_types_collection_for_select_options, required: true %>

- <%= f.label :units, class: "form--label -required" %> - <% suffix = @cost_entry.cost_type.nil? ? '' : (@cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural) %> - - <%= f.text_field :units, size: 6, required: true, no_label: true %> - <% if @cost_entry.cost_type %> - - <%= h(@cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural) %> - + <% if @cost_entry.cost_type.nil? %> + <%= f.text_field :units, size: 6, required: true %> + <% else %> + <% suffix = @cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural %> + <%= f.text_field :units, + size: 6, + required: true, + suffix: h(suffix) %> <% end %> - - - - <%= observe_field( "cost_entry_cost_type_id", :url => {:controller => :cost_objects, :action => :update_material_budget_item, :project_id => @cost_entry.project}, :with => "'cost_type_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('cost_entry_units').value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_entry_spent_on').value) + '&element_id=cost_entry'") %> - <%= observe_field( "cost_entry_units", :frequency => 1, :url => {:controller => :cost_objects, :action => :update_material_budget_item, :project_id => @cost_entry.project}, :with => "'cost_type_id=' + encodeURIComponent(document.getElementById('cost_entry_cost_type_id').value) + '&units=' + encodeURIComponent(value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_entry_spent_on').value) + '&element_id=cost_entry'") %> - <%= observe_field( "cost_entry_spent_on", :frequency => 1, :url => {:controller => :cost_objects, :action => :update_material_budget_item, :project_id => @cost_entry.project}, :with => "'cost_type_id=' + encodeURIComponent(document.getElementById('cost_entry_cost_type_id').value) + '&units=' + encodeURIComponent(document.getElementById('cost_entry_units').value) + '&fixed_date=' + encodeURIComponent(value) + '&element_id=cost_entry'") %> + <%= observe_field( "cost_entry_cost_type_id", url: {controller: :cost_objects, action: :update_material_budget_item, project_id: @cost_entry.project}, with: "'cost_type_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('cost_entry_units').value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_entry_spent_on').value) + '&element_id=cost_entry'") %> + <%= observe_field( "cost_entry_units", frequency: 1, url: {controller: :cost_objects, action: :update_material_budget_item, project_id: @cost_entry.project}, with: "'cost_type_id=' + encodeURIComponent(document.getElementById('cost_entry_cost_type_id').value) + '&units=' + encodeURIComponent(value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_entry_spent_on').value) + '&element_id=cost_entry'") %> + <%= observe_field( "cost_entry_spent_on", frequency: 1, url: {controller: :cost_objects, action: :update_material_budget_item, project_id: @cost_entry.project}, with: "'cost_type_id=' + encodeURIComponent(document.getElementById('cost_entry_cost_type_id').value) + '&units=' + encodeURIComponent(document.getElementById('cost_entry_units').value) + '&fixed_date=' + encodeURIComponent(value) + '&element_id=cost_entry'") %>
@@ -88,7 +85,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. end %> <% else %> - " size="7" name="cost_entry[overridden_costs]" id="cost_entry_costs_edit"/> <%= Setting.plugin_openproject_costs['costs_currency'] %> + " size="7" name="cost_entry[overridden_costs]" id="cost_entry_costs_edit"/> <%= Setting.plugin_openproject_costs['costs_currency'] %>
<%= l(:help_override_rate) %> <% end %>