Skip to content

Commit

Permalink
Merge pull request #3462 from himdel/policy-footer-bz1530971
Browse files Browse the repository at this point in the history
MiqPolicy - remove form buttons when cancelling a form or sucessfully saving/adding
(cherry picked from commit 27a3e2a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1553317
  • Loading branch information
mzazrivec authored and simaishi committed Mar 8, 2018
1 parent 0a7ffb0 commit dcf761e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
4 changes: 3 additions & 1 deletion app/controllers/miq_policy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,11 @@ def replace_right_cell(options = {})
else
# Added so buttons can be turned off even tho div is not being displayed it still pops up
# Abandon changes box when trying to change a node on tree after saving a record
presenter.hide(:button_on).show(:toolbar).hide(:paging_div)
presenter.hide(:buttons_on).show(:toolbar).hide(:paging_div)
end

presenter.hide(:form_buttons_div) if options[:remove_form_buttons]

# Replace the searchbox
presenter.replace(:adv_searchbox_div, r[:partial => 'layouts/x_adv_searchbox', :locals => {:nameonly => true}])

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/miq_policy_controller/alert_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def alert_profile_edit_cancel
add_flash(_("Edit of Alert Profile \"%{name}\" was cancelled by the user") % {:name => @alert_profile.description})
end
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
end

def alert_profile_edit_reset
Expand Down Expand Up @@ -61,7 +61,7 @@ def alert_profile_edit_save_add
@edit = nil
self.x_node = @new_alert_profile_node = "xx-#{alert_profile.mode}_ap-#{to_cid(alert_profile.id)}"
get_node_info(@new_alert_profile_node)
replace_right_cell(:nodetype => "ap", :replace_trees => [:alert_profile])
replace_right_cell(:nodetype => "ap", :replace_trees => %i(alert_profile), :remove_form_buttons => true)
end

def alert_profile_edit_move
Expand Down Expand Up @@ -142,7 +142,7 @@ def alert_profile_delete
nodes.pop
self.x_node = nodes.join("_")
get_node_info(x_node)
replace_right_cell(:nodetype => "xx", :replace_trees => [:alert_profile])
replace_right_cell(:nodetype => "xx", :replace_trees => %i(alert_profile))
end

def alert_profile_field_changed
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/miq_policy_controller/alerts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def alert_edit_cancel
add_flash(_("Edit of Alert \"%{name}\" was cancelled by the user") % {:name => @alert.description})
end
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
end

def alert_edit_save_add
Expand All @@ -35,7 +35,7 @@ def alert_edit_save_add
@edit = nil
@nodetype = "al"
@new_alert_node = "al-#{to_cid(alert.id)}"
replace_right_cell(:nodetype => "al", :replace_trees => [:alert_profile, :alert])
replace_right_cell(:nodetype => "al", :replace_trees => %i(alert_profile alert), :remove_form_buttons => true)
end

def alert_edit_reset
Expand Down Expand Up @@ -77,7 +77,7 @@ def alert_delete
process_alerts(alerts, "destroy") unless alerts.empty?
@new_alert_node = self.x_node = "root"
get_node_info(x_node)
replace_right_cell(:nodetype => "root", :replace_trees => [:alert_profile, :alert])
replace_right_cell(:nodetype => "root", :replace_trees => %i(alert_profile alert))
end

def alert_field_changed
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/miq_policy_controller/conditions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def condition_edit
end
@edit = nil
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
return
when "reset", nil # Reset or first time in
condition_build_edit_screen
Expand Down Expand Up @@ -68,19 +68,19 @@ def condition_edit
case x_active_tree
when :condition_tree
@new_condition_node = "xx-#{condition.towhat.downcase}_co-#{to_cid(condition.id)}"
replace_right_cell(:nodetype => "co", :replace_trees => [:condition])
replace_right_cell(:nodetype => "co", :replace_trees => %i(condition), :remove_form_buttons => true)
when :policy_tree
node_ids = @sb[:node_ids][x_active_tree] # Get the selected node ids
@new_policy_node = "xx-#{policy.mode.downcase}_xx-#{policy.mode.downcase}-#{policy.towhat.downcase}_p-#{node_ids["p"]}_co-#{to_cid(condition.id)}"
replace_right_cell(:nodetype => "co", :replace_trees => [:policy_profile, :policy, :condition])
replace_right_cell(:nodetype => "co", :replace_trees => %i(policy_profile policy condition), :remove_form_buttons => true)
when :policy_profile_tree
node_ids = @sb[:node_ids][x_active_tree] # Get the selected node ids
@new_profile_node = "pp-#{node_ids["pp"]}_p-#{node_ids["p"]}_co-#{to_cid(condition.id)}"
replace_right_cell(:nodetype => "co", :replace_trees => [:policy_profile, :policy, :condition])
replace_right_cell(:nodetype => "co", :replace_trees => %i(policy_profile policy condition), :remove_form_buttons => true)
end
else
condition_get_info(Condition.find(condition.id))
replace_right_cell(:nodetype => "co", :replace_trees => [:policy_profile, :policy, :condition])
replace_right_cell(:nodetype => "co", :replace_trees => %i(policy_profile policy condition), :remove_form_buttons => true)
end
else
condition.errors.each do |field, msg|
Expand Down Expand Up @@ -116,7 +116,7 @@ def condition_remove
nodes = x_node.split("_")
nodes.pop
@new_policy_node = self.x_node = nodes.join("_")
replace_right_cell(:nodetype => "p", :replace_trees => [:policy_profile, :policy])
replace_right_cell(:nodetype => "p", :replace_trees => %i(policy_profile policy))
end

def condition_delete
Expand All @@ -132,7 +132,7 @@ def condition_delete
end
process_conditions(conditions, "destroy") unless conditions.empty?
get_node_info(@new_condition_node)
replace_right_cell(:nodetype => "xx", :replace_trees => [:condition])
replace_right_cell(:nodetype => "xx", :replace_trees => %i(condition))
end

def condition_field_changed
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/miq_policy_controller/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def event_edit
@edit = nil
add_flash(_("Edit Event cancelled by user"))
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
return
when "reset", nil # Reset or first time in
event_build_edit_screen
Expand Down Expand Up @@ -44,7 +44,7 @@ def event_edit
@nodetype = "ev"
event_get_info(MiqEventDefinition.find(event.id))
@edit = nil
replace_right_cell(:nodetype => "ev", :replace_trees => [:policy_profile, :policy])
replace_right_cell(:nodetype => "ev", :replace_trees => %i(policy_profile policy), :remove_form_buttons => true)
when "true_right", "true_left", "true_allleft", "true_up", "true_down", "true_sync", "true_async"
handle_selection_buttons(:actions_true, :members_chosen_true, :choices_true, :choices_chosen_true)
session[:changed] = (@edit[:new] != @edit[:current])
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/miq_policy_controller/miq_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def action_edit
end
@sb[:action] = nil
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
return
when "reset", nil # Reset or first time in
action_build_edit_screen
Expand Down Expand Up @@ -51,7 +51,7 @@ def action_edit
@edit = nil
@nodetype = "a"
@new_action_node = "a-#{to_cid(action.id)}"
replace_right_cell(:nodetype => "a", :replace_trees => params[:button] == "save" ? [:policy_profile, :policy, :action] : [:action])
replace_right_cell(:nodetype => "a", :replace_trees => params[:button] == "save" ? %i(policy_profile policy action) : %i(action), :remove_form_buttons => true)
@sb[:action] = nil
else
action.errors.each do |field, msg|
Expand All @@ -78,7 +78,7 @@ def action_delete
process_actions(actions, "destroy") unless actions.empty?
@new_action_node = self.x_node = "root"
get_node_info(x_node)
replace_right_cell(:nodetype => "root", :replace_trees => [:action])
replace_right_cell(:nodetype => "root", :replace_trees => %i(action))
end

def action_field_changed
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/miq_policy_controller/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def policy_edit_cancel
end
@edit = nil
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
end

def policy_edit_reset
Expand Down Expand Up @@ -74,14 +74,14 @@ def policy_edit_save

case x_active_tree
when :policy_profile_tree
replace_right_cell(:nodetype => "p", :replace_trees => [:policy_profile, :policy])
replace_right_cell(:nodetype => "p", :replace_trees => %i(policy_profile policy), :remove_form_buttons => true)
when :policy_tree
@nodetype = "p"
if params[:button] == "add"
self.x_node = @new_policy_node = policy_node(policy)
get_node_info(@new_policy_node)
end
replace_right_cell(:nodetype => "p", :replace_trees => params[:button] == "save" ? [:policy_profile, :policy] : [:policy])
replace_right_cell(:nodetype => "p", :replace_trees => params[:button] == "save" ? %i(policy_profile policy) : %i(policy), :remove_form_buttons => true)
end
end

Expand Down Expand Up @@ -132,7 +132,7 @@ def policy_copy
add_flash(_("Policy \"%{name}\" was added") % {:name => new_desc})
@new_policy_node = policy_node(policy)
get_node_info(@new_policy_node)
replace_right_cell(:nodetype => "p", :replace_trees => [:policy])
replace_right_cell(:nodetype => "p", :replace_trees => %i(policy))
end
end

Expand All @@ -154,7 +154,7 @@ def policy_delete
process_policies(policies, "destroy") unless policies.empty?
add_flash(_("The selected Policies were deleted")) if @flash_array.nil?
get_node_info(@new_policy_node)
replace_right_cell(:nodetype => "xx", :replace_trees => [:policy, :policy_profile])
replace_right_cell(:nodetype => "xx", :replace_trees => %i(policy policy_profile))
end

def policy_field_changed
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/miq_policy_controller/policy_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def profile_edit
add_flash(_("Edit of Policy Profile \"%{name}\" was cancelled by the user") % {:name => @profile.description})
end
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
replace_right_cell(:nodetype => @nodetype, :remove_form_buttons => true)
return
when "reset", nil # Reset or first time in
profile_build_edit_screen
Expand Down Expand Up @@ -58,7 +58,7 @@ def profile_edit
@edit = nil
@nodetype = "pp"
@new_profile_node = "pp-#{to_cid(profile.id)}"
replace_right_cell(:nodetype => "pp", :replace_trees => [:policy_profile])
replace_right_cell(:nodetype => "pp", :replace_trees => %i(policy_profile), :remove_form_buttons => true)
else
profile.errors.each do |field, msg|
add_flash("#{field.to_s.capitalize} #{msg}", :error)
Expand All @@ -85,7 +85,7 @@ def profile_delete
add_flash(_("The selected Policy Profile was deleted")) if @flash_array.nil?
self.x_node = @new_profile_node = 'root'
get_node_info('root')
replace_right_cell(:nodetype => 'root', :replace_trees => [:policy_profile])
replace_right_cell(:nodetype => 'root', :replace_trees => %i(policy_profile))
end

def profile_field_changed
Expand Down

0 comments on commit dcf761e

Please sign in to comment.