app/controllers/report_controller/widgets.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 widget_form_field_changed
    return unless load_edit("widget_edit__#{params[:id]}", "replace_cell__explorer")
    widget_get_form_vars
    render :update do |page|                    
      if params[:filter_typ]
        @edit[:new][:subfilter] = nil
        @edit[:new][:repfilter] = @reps = nil
        @replace_filter_div = true
      elsif params[:subfilter_typ]
        @edit[:new][:repfilter] = nil
        @replace_filter_div = true
      elsif params[:repfilter_typ] || params[:chosen_pivot1] || params[:chosen_pivot2] || params[:chosen_pivot3] ||
            params[:feed_type] || params[:rss_url]
        @replace_filter_div = true
      end
      if @replace_filter_div
        page.replace("form_filter_div", :partial => "widget_form_filter")
        page << "miqInitDashboardCols();"
      end
      if params[:visibility_typ]
        page.replace("form_role_visibility", :partial => "layouts/role_visibility", :locals => {:rec_id => "#{@widget.id || "new"}", :action => "widget_form_field_changed"})
      end
      javascript_for_timer_type(params[:timer_typ]).each { |js| page << js }
      if params[:time_zone]
        page << "ManageIQ.calendar.calDateFrom = new Date(#{(Time.zone.now - 1.month).in_time_zone(@edit[:tz]).strftime("%Y,%m,%d")});"
        page << "miqBuildCalendar();"
        page << "$('#miq_date_1').val('#{@edit[:new][:start_date]}');"
        page << "$('#start_hour').val('#{@edit[:new][:start_hour].to_i}');"
        page << "$('#start_min').val('#{@edit[:new][:start_min].to_i}');"
        page.replace_html("tz_span", @timezone_abbr)
      end
      changed = (@edit[:new] != @edit[:current])
      page << javascript_for_miq_button_visibility(changed)
      page << "miqSparkle(false);"
    end
  end
def widget_form_field_changed return unless load_edit ( "widget_edit__#{params[:id]}" , "replace_cell__explorer" ) widget_get_form_vars render :update do | page | if params [ :filter_typ ] @edit [ :new ] [ :subfilter ] = nil @edit [ :new ] [ :repfilter ] = @reps = nil @replace_filter_div = true elsif params [ :subfilter_typ ] @edit [ :new ] [ :repfilter ] = nil @replace_filter_div = true elsif params [ :repfilter_typ ] || params [ :chosen_pivot1 ] || params [ :chosen_pivot2 ] || params [ :chosen_pivot3 ] || params [ :feed_type ] || params [ :rss_url ] @replace_filter_div = true end if @replace_filter_div page . replace ( "form_filter_div" , :partial => "widget_form_filter" ) page << "miqInitDashboardCols();" end if params [ :visibility_typ ] page . replace ( "form_role_visibility" , :partial => "layouts/role_visibility" , :locals => { :rec_id => "#{@widget.id || "new"}" , :action => "widget_form_field_changed" } ) end javascript_for_timer_type ( params [ :timer_typ ] ) . each { | js | page << js } if params [ :time_zone ] page << "ManageIQ.calendar.calDateFrom = new Date(#{(Time.zone.now - 1.month).in_time_zone(@edit[:tz]).strftime("%Y,%m,%d")});" page << "miqBuildCalendar();" page << "$('#miq_date_1').val('#{@edit[:new][:start_date]}');" page << "$('#start_hour').val('#{@edit[:new][:start_hour].to_i}');" page << "$('#start_min').val('#{@edit[:new][:start_min].to_i}');" page . replace_html ( "tz_span" , @timezone_abbr ) end changed = ( @edit [ :new ] != @edit [ :current ] ) page << javascript_for_miq_button_visibility ( changed ) page << "miqSparkle(false);" 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
# Use JS to update the display