app/controllers/ops_controller/ops_rbac.rb
# AJAX driven routine to check for changes in ANY field on the form
AJAX driven routine to check for changes in ANY field on the form
AJAX driven routine to check for changes in ANY field on the form
def rbac_field_changed(rec_type)
    id = params[:id].split('__').first    
    id = from_cid(id) unless id == "new" || id == "seq" 
    return unless load_edit("rbac_#{rec_type}_edit__#{id}", "replace_cell__explorer")
    case rec_type
    when "user"  then rbac_user_get_form_vars
    when "group" then tree_name = rbac_group_get_form_vars
    when "role"  then rbac_role_get_form_vars
    end
    changed = (@edit[:new] != @edit[:current])
    bad = false
    if rec_type == "group"
      bad ||= @edit[:new][:role].blank?
      bad ||= @edit[:new][:group_tenant].blank?
    end
    render :update do |page|              
      if %w(up down).include?(params[:button])
        page.replace("flash_msg_div", :partial => "layouts/flash_msg") unless @refresh_div && @refresh_div != "column_lists"
        page.replace(@refresh_div, :partial => @refresh_partial) if @refresh_div
        bad = false
      else
        if x_node.split("-").first == "g" || x_node == "xx-g"
          page.replace(@refresh_div,
                       :partial => @refresh_partial,
                       :locals  => {:type => "classifications", :action_url => 'rbac_group_field_changed'}) if @refresh_div
          page << "$('#description').val('#{j_str(@edit[:new][:description])}');" if params[:ldap_groups_user]
          page << javascript_for_tree_checkbox_clicked(tree_name) if params[:check] && tree_name
          page << set_element_visible('group_lookup', @edit[:new][:lookup]) unless params[:check]
        end
      end
      page << javascript_for_miq_button_visibility(changed && !bad)
    end
  end
def rbac_field_changed ( rec_type ) id = params [ :id ] . split ( '__' ) . first id = from_cid ( id ) unless id == "new" || id == "seq" return unless load_edit ( "rbac_#{rec_type}_edit__#{id}" , "replace_cell__explorer" ) case rec_type when "user" then rbac_user_get_form_vars when "group" then tree_name = rbac_group_get_form_vars when "role" then rbac_role_get_form_vars end changed = ( @edit [ :new ] != @edit [ :current ] ) bad = false if rec_type == "group" bad ||= @edit [ :new ] [ :role ] . blank? bad ||= @edit [ :new ] [ :group_tenant ] . blank? end render :update do | page | if %w( up down ) . include? ( params [ :button ] ) page . replace ( "flash_msg_div" , :partial => "layouts/flash_msg" ) unless @refresh_div && @refresh_div != "column_lists" page . replace ( @refresh_div , :partial => @refresh_partial ) if @refresh_div bad = false else if x_node . split ( "-" ) . first == "g" || x_node == "xx-g" page . replace ( @refresh_div , :partial => @refresh_partial , :locals => { :type => "classifications" , :action_url => 'rbac_group_field_changed' } ) if @refresh_div page << "$('#description').val('#{j_str(@edit[:new][:description])}');" if params [ :ldap_groups_user ] page << javascript_for_tree_checkbox_clicked ( tree_name ) if params [ :check ] && tree_name page << set_element_visible ( 'group_lookup' , @edit [ :new ] [ :lookup ] ) unless params [ :check ] end end page << javascript_for_miq_button_visibility ( changed && ! bad ) end end
AJAX driven routine to check for changes in ANY field on the form
AJAX driven routine to check for changes in ANY field on the form
# Get the record id # Decompress id if not "new" # Use JS to update the display # only do following for groups # Only update description field value if ldap group user field was selected # don't do anything to lookup box when checkboxes on the right side are checked
rec_type
<not_specific>