app/controllers/miq_policy_controller/alert_profiles.rb
# Build the assign objects selection tree
Build the assign objects selection tree
Build the assign objects selection tree
def alert_profile_build_obj_tree
    tree = nil
    unless @objects.empty?               
      if @assign[:new][:assign_to] == "ems_folder"
        tree = build_belongsto_tree(@assign[:new][:objects].collect { |f| "EmsFolder_#{f}" }, true, false)
      elsif @assign[:new][:assign_to] == "resource_pool"
        tree = build_belongsto_tree(@assign[:new][:objects].collect { |f| "ResourcePool_#{f}" }, false, false, true)
      else
        root_node = TreeNodeBuilder.generic_tree_node(
          "OBJROOT",
          @assign[:new][:assign_to].ends_with?("-tags") ? "Tags" : ui_lookup(:tables => @assign[:new][:assign_to]),
          "folder_open.png",
          "",
          :style_class  => "cfme-no-cursor-node",
          :expand       => true,
          :hideCheckbox => true
        )
        root_node[:children] = []
        @objects.sort_by { |o| (o[:name] || o[:description]).downcase }.each do |o|
          if @assign[:new][:assign_to].ends_with?("-tags")
            icon = "tag.png"
          else
            if @assign[:new][:assign_to] == "ext_management_system"
              icon = "vendor-#{o.image_name}.png"
            elsif @assign[:new][:assign_to] == "resource_pool"
              icon = o.vapp ? "vapp.png" : "resource_pool.png"
            else
              icon = "#{@assign[:new][:assign_to]}.png"
            end
          end
          node = TreeNodeBuilder.generic_tree_node(
            o.id,
            o[:name] || o[:description],
            icon,
            "",
            :select => @assign[:new][:objects].include?(o.id) 
          )
          root_node[:children].push(node)
        end
        tree = root_node.to_json
      end
    end
    tree
  end
def alert_profile_build_obj_tree tree = nil unless @objects . empty? if @assign [ :new ] [ :assign_to ] == "ems_folder" tree = build_belongsto_tree ( @assign [ :new ] [ :objects ] . collect { | f | "EmsFolder_#{f}" } , true , false ) elsif @assign [ :new ] [ :assign_to ] == "resource_pool" tree = build_belongsto_tree ( @assign [ :new ] [ :objects ] . collect { | f | "ResourcePool_#{f}" } , false , false , true ) else root_node = TreeNodeBuilder . generic_tree_node ( "OBJROOT" , @assign [ :new ] [ :assign_to ] . ends_with? ( "-tags" ) ? "Tags" : ui_lookup ( :tables => @assign [ :new ] [ :assign_to ] ) , "folder_open.png" , "" , :style_class => "cfme-no-cursor-node" , :expand => true , :hideCheckbox => true ) root_node [ :children ] = [ ] @objects . sort_by { | o | ( o [ :name ] || o [ :description ] ) . downcase } . each do | o | if @assign [ :new ] [ :assign_to ] . ends_with? ( "-tags" ) icon = "tag.png" else if @assign [ :new ] [ :assign_to ] == "ext_management_system" icon = "vendor-#{o.image_name}.png" elsif @assign [ :new ] [ :assign_to ] == "resource_pool" icon = o . vapp ? "vapp.png" : "resource_pool.png" else icon = "#{@assign[:new][:assign_to]}.png" end end node = TreeNodeBuilder . generic_tree_node ( o . id , o [ :name ] || o [ :description ] , icon , "" , :select => @assign [ :new ] [ :objects ] . include? ( o . id ) ) root_node [ :children ] . push ( node ) end tree = root_node . to_json end end tree end
Build the assign objects selection tree
Build the assign objects selection tree
# Build object tree # Check if tag is assigned