From 2098401dcebb493fcf07009360a6a67f0014da5e Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Wed, 4 Sep 2019 13:54:52 +0200 Subject: [PATCH] Use copy_params_if_present in vm_common, manager_controller_mixin Issue: https://github.com/ManageIQ/manageiq-ui-classic/issues/6105 Use the new method also in miq_request_methods.rb --- app/controllers/application_controller/miq_request_methods.rb | 3 +-- app/controllers/mixins/manager_controller_mixin.rb | 4 +--- app/controllers/vm_common.rb | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller/miq_request_methods.rb b/app/controllers/application_controller/miq_request_methods.rb index b264d5d8895..2906ab161ef 100644 --- a/app/controllers/application_controller/miq_request_methods.rb +++ b/app/controllers/application_controller/miq_request_methods.rb @@ -663,9 +663,8 @@ def prov_get_form_vars id = params[:ou_id].gsub(/_-_/, ",") if params[:ou_id] @edit[:new][:ldap_ous] = id.match(/(.*)\,(.*)/)[1..2] if id # ou selected in a tree + copy_params_if_present(@edit[:new], params, %i[start_hour start_min]) @edit[:new][:start_date] = params[:miq_date_1] if params[:miq_date_1] - @edit[:new][:start_hour] = params[:start_hour] if params[:start_hour] - @edit[:new][:start_min] = params[:start_min] if params[:start_min] @edit[:new][:schedule_time] = Time.zone.parse("#{@edit[:new][:start_date]} #{@edit[:new][:start_hour]}:#{@edit[:new][:start_min]}") params.each do |key, _value| diff --git a/app/controllers/mixins/manager_controller_mixin.rb b/app/controllers/mixins/manager_controller_mixin.rb index 6130b74a188..b09a31c2826 100644 --- a/app/controllers/mixins/manager_controller_mixin.rb +++ b/app/controllers/mixins/manager_controller_mixin.rb @@ -138,10 +138,8 @@ def change_tab end def cs_edit_get_form_vars - @edit[:new][:name] = params[:name] if params[:name] - @edit[:new][:description] = params[:description] if params[:description] + copy_params_if_present(@edit[:new], params, %i[name description dialog_name]) @edit[:new][:draft] = params[:draft] == "true" if params[:draft] - @edit[:new][:dialog_name] = params[:dialog_name] if params[:dialog_name] end def cs_form_field_changed diff --git a/app/controllers/vm_common.rb b/app/controllers/vm_common.rb index 0b20246c291..44fe4000e5c 100644 --- a/app/controllers/vm_common.rb +++ b/app/controllers/vm_common.rb @@ -1589,9 +1589,7 @@ def get_vm_child_selection # Get variables from edit form def get_form_vars @record = VmOrTemplate.find_by(:id => @edit[:vm_id]) - @edit[:new][:custom_1] = params[:custom_1] if params[:custom_1] - @edit[:new][:description] = params[:description] if params[:description] - @edit[:new][:name] = params[:name] if params[:name] + copy_params_if_present(@edit[:new], params, %i[custom_1 description name]) @edit[:new][:parent] = params[:chosen_parent].to_i if params[:chosen_parent] # if coming from explorer get_vm_child_selection if %w[allright left right].include?(params[:button])