app/controllers/ops_controller/settings.rb
# AJAX driven routine to add/update a classification entry
AJAX driven routine to add/update a classification entry
AJAX driven routine to add / update a classification entry
def forest_accept
    forest_get_form_vars
    no_changes = true
    if @ldap_info[:ldaphost] == ""
      add_flash(_("LDAP Host is required"), :error)
      no_changes = false
    elsif @edit[:new][:authentication][:user_proxies].blank? || @edit[:new][:authentication][:user_proxies][0].blank? 
      @edit[:new][:authentication][:user_proxies].delete_at(0)
    else
      @edit[:new][:authentication][:user_proxies].each do |f|
        next unless f[:ldaphost] == @ldap_info[:ldaphost] && session[:entry] == 'new'
        no_changes = false
        add_flash(_("LDAP Host should be unique"), :error)
        break
      end
    end
    if no_changes
      if session[:entry] == "new"
        @edit[:new][:authentication][:user_proxies].push(@ldap_info)
      else
        @edit[:new][:authentication][:user_proxies].each_with_index do |f, i|
          @edit[:new][:authentication][:user_proxies][i] = @ldap_info if f[:ldaphost] == session[:entry][:ldaphost]
        end
      end
    end
    @changed = (@edit[:new] != @edit[:current])
    render :update do |page|
      page << javascript_prologue
      page << javascript_for_miq_button_visibility(@changed)
      page.replace("flash_msg_div", :partial => "layouts/flash_msg")
      page.replace("forest_entries_div", :partial => "ldap_forest_entries", :locals => {:entry => nil, :edit => false}) if no_changes
    end
  end
def forest_accept forest_get_form_vars no_changes = true if @ldap_info [ :ldaphost ] == "" add_flash ( _ ( "LDAP Host is required" ) , :error ) no_changes = false elsif @edit [ :new ] [ :authentication ] [ :user_proxies ] . blank? || @edit [ :new ] [ :authentication ] [ :user_proxies ] [ 0 ] . blank? @edit [ :new ] [ :authentication ] [ :user_proxies ] . delete_at ( 0 ) else @edit [ :new ] [ :authentication ] [ :user_proxies ] . each do | f | next unless f [ :ldaphost ] == @ldap_info [ :ldaphost ] && session [ :entry ] == 'new' no_changes = false add_flash ( _ ( "LDAP Host should be unique" ) , :error ) break end end if no_changes if session [ :entry ] == "new" @edit [ :new ] [ :authentication ] [ :user_proxies ] . push ( @ldap_info ) else @edit [ :new ] [ :authentication ] [ :user_proxies ] . each_with_index do | f , i | @edit [ :new ] [ :authentication ] [ :user_proxies ] [ i ] = @ldap_info if f [ :ldaphost ] == session [ :entry ] [ :ldaphost ] end end end @changed = ( @edit [ :new ] != @edit [ :current ] ) render :update do | page | page << javascript_prologue page << javascript_for_miq_button_visibility ( @changed ) page . replace ( "flash_msg_div" , :partial => "layouts/flash_msg" ) page . replace ( "forest_entries_div" , :partial => "ldap_forest_entries" , :locals => { :entry => nil , :edit => false } ) if no_changes end end
AJAX driven routine to add/update a classification entry
AJAX driven routine to add / update a classification entry
# if adding forest first time, delete a blank record # check to make sure ldaphost already doesn't exist and ignore if existing record is being edited.