app/controllers/ops_controller/ops_rbac.rb
# Set form variables for user add/edit
Set form variables for user add/edit
Set form variables for user add / edit
def rbac_group_set_form_vars
    @assigned_filters = []
    @edit = {}
    @group = @record
    @edit[:group_id] = @record.id
    @edit[:new] = {}
    @edit[:key] = "rbac_group_edit__#{@edit[:group_id] || "new"}"
    @edit[:new][:filters] = {}
    @edit[:new][:belongsto] = {}
    @edit[:ldap_groups_by_user] = []
    @edit[:new][:description] = @group.description
    [@group.get_managed_filters].flatten.each do |f|
      @edit[:new][:filters][f.split("/")[-2] + "-" + f.split("/")[-1]] = f
    end
    @group.get_belongsto_filters.each do |b|            
      bobj = MiqFilter.belongsto2object(b)            
      next unless bobj
      @edit[:new][:belongsto][bobj.class.to_s + "_" + bobj.id.to_s] = b 
    end
    all_roles = MiqUserRole.all
    @edit[:roles] = {}
    @edit[:roles]["<Choose a Role>"] = nil if @record.id.nil?
    all_roles.each do |r|
      @edit[:roles][r.name] = r.id
    end
    if @group.miq_user_role.nil?              
      @edit[:new][:role] = @edit[:roles][@edit[:roles].keys.sort[0]]
    else
      @edit[:new][:role] = @group.miq_user_role.id
    end
    @edit[:projects_tenants] = []
    all_tenants, all_projects = Tenant.tenant_and_project_names
    @edit[:projects_tenants].push(["", [["<Choose a Project/Tentant>", :selected => "<Choose a Project/Tentant>", :disabled => "<Choose a Project/Tentant>", :style => 'display:none']]])
    @edit[:projects_tenants].push(["Projects", all_projects]) unless all_projects.blank?
    @edit[:projects_tenants].push(["Tenants", all_tenants]) unless all_tenants.blank?
    @edit[:new][:group_tenant] = @group.tenant_id
    @edit[:current] = copy_hash(@edit[:new])
    rbac_build_myco_tree                              
    build_belongsto_tree(@edit[:new][:belongsto].keys)  
    build_belongsto_tree(@edit[:new][:belongsto].keys, true)  
  end
def rbac_group_set_form_vars @assigned_filters = [ ] @edit = { } @group = @record @edit [ :group_id ] = @record . id @edit [ :new ] = { } @edit [ :key ] = "rbac_group_edit__#{@edit[:group_id] || "new"}" @edit [ :new ] [ :filters ] = { } @edit [ :new ] [ :belongsto ] = { } @edit [ :ldap_groups_by_user ] = [ ] @edit [ :new ] [ :description ] = @group . description [ @group . get_managed_filters ] . flatten . each do | f | @edit [ :new ] [ :filters ] [ f . split ( "/" ) [ - 2 ] + "-" + f . split ( "/" ) [ - 1 ] ] = f end @group . get_belongsto_filters . each do | b | bobj = MiqFilter . belongsto2object ( b ) next unless bobj @edit [ :new ] [ :belongsto ] [ bobj . class . to_s + "_" + bobj . id . to_s ] = b end all_roles = MiqUserRole . all @edit [ :roles ] = { } @edit [ :roles ] [ "<Choose a Role>" ] = nil if @record . id . nil? all_roles . each do | r | @edit [ :roles ] [ r . name ] = r . id end if @group . miq_user_role . nil? @edit [ :new ] [ :role ] = @edit [ :roles ] [ @edit [ :roles ] . keys . sort [ 0 ] ] else @edit [ :new ] [ :role ] = @group . miq_user_role . id end @edit [ :projects_tenants ] = [ ] all_tenants , all_projects = Tenant . tenant_and_project_names @edit [ :projects_tenants ] . push ( [ "" , [ [ "<Choose a Project/Tentant>" , :selected => "<Choose a Project/Tentant>" , :disabled => "<Choose a Project/Tentant>" , :style => 'display:none' ] ] ] ) @edit [ :projects_tenants ] . push ( [ "Projects" , all_projects ] ) unless all_projects . blank? @edit [ :projects_tenants ] . push ( [ "Tenants" , all_tenants ] ) unless all_tenants . blank? @edit [ :new ] [ :group_tenant ] = @group . tenant_id @edit [ :current ] = copy_hash ( @edit [ :new ] ) rbac_build_myco_tree build_belongsto_tree ( @edit [ :new ] [ :belongsto ] . keys ) build_belongsto_tree ( @edit [ :new ] [ :belongsto ] . keys , true ) end
Set form variables for user add/edit
Set form variables for user add / edit
#   @edit[:new][:role] = @group.miq_user_role.id # Build the managed filters hash # Build the belongsto filters hash # Go thru the belongsto tags # Convert to an object # Store in hash as <class>_<id> string #   user_build_myco_tree                              # Build the MyCompanyTags tree for this user #   user_build_belongsto_tree                         # Build the Hosts & Clusters tree for this user #   user_build_belongsto_tree(true)                   # Build the VMs & Templates tree for this user # If adding, set to first role # Build the MyCompanyTags tree for this user # Build the Hosts & Clusters tree for this user # Build the VMs & Templates tree for this user