OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Update costlog form and controller to accept entity_id and entity_type properly
Klaus Zanders72d4db2aecfd
diff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rbindex 7589f4c8b4a..9ca6d5d4421 100644--- a/modules/costs/app/controllers/costlog_controller.rb+++ b/modules/costs/app/controllers/costlog_controller.rb@@ -73,7 +73,7 @@ class CostlogController < ApplicationControllerelsif @cost_entry.saveflash[:notice] = t(:notice_successful_update)- redirect_back fallback_location: work_package_path(@cost_entry.entity)+ redirect_back fallback_location: polymorphic_path(@cost_entry.entity)elserender action: "edit"@@ -90,7 +90,7 @@ class CostlogController < ApplicationControllerif request.referer.include?("cost_reports")redirect_to controller: "/cost_reports", action: :indexelse- redirect_back fallback_location: work_package_path(@cost_entry.entity)+ redirect_back fallback_location: polymorphic_path(@cost_entry.entity)endend@@ -162,14 +162,6 @@ class CostlogController < ApplicationControllerenddef cost_entry_params- params- .require(:cost_entry)- .permit(:entity_id, :entity_type, :spent_on, :user_id,- :cost_type_id, :units, :comments).tap do |permitted_params|- if params[:cost_entry][:work_package_id]- permitted_params[:entity_id] = params[:cost_entry][:work_package_id]- permitted_params[:entity_type] = "WorkPackage"- end- end+ params.expect(cost_entry: %i[user_id entity_id entity_type spent_on cost_type_id units comments])endenddiff --git a/modules/costs/app/views/costlog/edit.html.erb b/modules/costs/app/views/costlog/edit.html.erbindex cd78f17c244..5cf6545441b 100644--- a/modules/costs/app/views/costlog/edit.html.erb+++ b/modules/costs/app/views/costlog/edit.html.erb@@ -48,7 +48,8 @@ See COPYRIGHT and LICENSE files for more details.<%= f.hidden_field :element_id, value: "cost_entry", class: "remote-field--input", data: { "remote-field-key": "element_id" } %><div class="form--field -required">- <%= f.text_field :work_package_id,+ <%= f.hidden_field :entity_type, value: "WorkPackage" %>+ <%= f.text_field :entity_id,size: 6,required: true,autofocus: true,