app/controllers/resource_pool_controller.rb
# handle buttons pressed on the button bar
handle buttons pressed on the button bar
handle buttons pressed on the button bar
def button
    @edit = session[:edit]                                  
    params[:display] = @display if ["all_vms", "vms", "resource_pools"].include?(@display)  
    if ["all_vms", "vms", "resource_pools"].include?(@display)                  
      if params[:pressed].starts_with?("vm_", 
                                       "miq_template_",
                                       "guest_")
        pfx = pfx_for_vm_button_pressed(params[:pressed])
        process_vm_buttons(pfx)
        return if ["#{pfx}_policy_sim", "#{pfx}_compare", "#{pfx}_tag", "#{pfx}_protect",
                   "#{pfx}_retire", "#{pfx}_right_size", "#{pfx}_ownership",
                   "#{pfx}_reconfigure"].include?(params[:pressed]) &&
                  @flash_array.nil?   
        unless ["#{pfx}_edit", "#{pfx}_miq_request_new", "#{pfx}_clone",
                "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed])
          @refresh_div = "main_div"
          @refresh_partial = "layouts/gtl"
          show
        end
      end
    else
      @refresh_div = "main_div" 
      tag(ResourcePool) if params[:pressed] == "resource_pool_tag"
      deleteresourcepools if params[:pressed] == "resource_pool_delete"
      assign_policies(ResourcePool) if params[:pressed] == "resource_pool_protect"
    end
    return if ["resource_pool_tag", "resource_pool_protect"].include?(params[:pressed]) && @flash_array.nil?   
    if !@flash_array && !@refresh_partial 
      add_flash(_("Button not yet implemented"), :error)
      @refresh_partial = "layouts/flash_msg"
      @refresh_div     = "flash_msg_div"
    elsif @flash_array && @lastaction == "show"
      @record = identify_record(params[:id])
      @refresh_partial = "layouts/flash_msg"
      @refresh_div     = "flash_msg_div"
    end
    if !@flash_array.nil? && params[:pressed] == "resource_pool_delete" && @single_delete
      render :update do |page|
        page.redirect_to :action => 'show_list', :flash_msg => @flash_array[0][:message]  
      end
    elsif ["#{pfx}_miq_request_new", "#{pfx}_migrate", "#{pfx}_clone",
           "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed])
      render_or_redirect_partial(pfx)
    else
      if @refresh_div == "main_div" && @lastaction == "show_list"
        replace_gtl_main_div
      else
        render_flash
      end
    end
  end
def button @edit = session [ :edit ] params [ :display ] = @display if [ "all_vms" , "vms" , "resource_pools" ] . include? ( @display ) if [ "all_vms" , "vms" , "resource_pools" ] . include? ( @display ) if params [ :pressed ] . starts_with? ( "vm_" , "miq_template_" , "guest_" ) pfx = pfx_for_vm_button_pressed ( params [ :pressed ] ) process_vm_buttons ( pfx ) return if [ "#{pfx}_policy_sim" , "#{pfx}_compare" , "#{pfx}_tag" , "#{pfx}_protect" , "#{pfx}_retire" , "#{pfx}_right_size" , "#{pfx}_ownership" , "#{pfx}_reconfigure" ] . include? ( params [ :pressed ] ) && @flash_array . nil? unless [ "#{pfx}_edit" , "#{pfx}_miq_request_new" , "#{pfx}_clone" , "#{pfx}_migrate" , "#{pfx}_publish" ] . include? ( params [ :pressed ] ) @refresh_div = "main_div" @refresh_partial = "layouts/gtl" show end end else @refresh_div = "main_div" tag ( ResourcePool ) if params [ :pressed ] == "resource_pool_tag" deleteresourcepools if params [ :pressed ] == "resource_pool_delete" assign_policies ( ResourcePool ) if params [ :pressed ] == "resource_pool_protect" end return if [ "resource_pool_tag" , "resource_pool_protect" ] . include? ( params [ :pressed ] ) && @flash_array . nil? if ! @flash_array && ! @refresh_partial add_flash ( _ ( "Button not yet implemented" ) , :error ) @refresh_partial = "layouts/flash_msg" @refresh_div = "flash_msg_div" elsif @flash_array && @lastaction == "show" @record = identify_record ( params [ :id ] ) @refresh_partial = "layouts/flash_msg" @refresh_div = "flash_msg_div" end if ! @flash_array . nil? && params [ :pressed ] == "resource_pool_delete" && @single_delete render :update do | page | page . redirect_to :action => 'show_list' , :flash_msg => @flash_array [ 0 ] [ :message ] end elsif [ "#{pfx}_miq_request_new" , "#{pfx}_migrate" , "#{pfx}_clone" , "#{pfx}_migrate" , "#{pfx}_publish" ] . include? ( params [ :pressed ] ) render_or_redirect_partial ( pfx ) else if @refresh_div == "main_div" && @lastaction == "show_list" replace_gtl_main_div else render_flash end end end
handle buttons pressed on the button bar
handle buttons pressed on the button bar
# Restore @edit for adv search box # Were we displaying sub-items # Need to check, since RPs contain RPs # Handle buttons from sub-items screen # Some other screen is showing, so return # Default div for button.rjs to refresh # Tag screen showing, so return # if no button handler ran, show not implemented msg # redirect to build the retire screen