app/controllers/management/page_steps_controller.rb
def build_current_dashboard_setting
    db_params = {}
    db_params = page_params.to_h[:dashboard_setting] if params[:site_page] && page_params&.to_h[:dashboard_setting]

    @dashboard_setting = nil
    return unless [ContentType::DASHBOARD_V2].include?(@page.content_type)
    if db_params[:id]
      @dashboard_setting = DashboardSetting.find(db_params[:id])
    elsif @page.dashboard_setting
      @dashboard_setting = @page.dashboard_setting
    else
      @dashboard_setting = DashboardSetting.new
      @page.dashboard_setting = @dashboard_setting
    end

    @dashboard_setting.assign_attributes session[:dashboard_setting]["#{@page_id}"] if session[:dashboard_setting]["#{@page_id}"]

    if ds_id = db_params[:dataset_id]
      # If the user changed the id of the dataset, the entity is reset
      if @dashboard_setting.dataset_id && @dashboard_setting.dataset_id != ds_id
        delete_session_key(:dashboard_setting, @page_id)
        session[:invalid_steps][@page_id] = %w[type dashboard_widget preview]
        @dashboard_setting.widget_id = nil
      end
    end

    @dashboard_setting.assign_attributes db_params
  end
# Builds the current dashboard setting based on the database, session and params
Builds the current dashboard setting based on the database, session and params
Builds the current dashboard setting based on the database session and params
def build_current_dashboard_setting
    db_params = {}
    db_params = page_params.to_h[:dashboard_setting] if params[:site_page] && page_params&.to_h[:dashboard_setting]
    @dashboard_setting = nil
    return unless [ContentType::DASHBOARD_V2].include?(@page.content_type)
    if db_params[:id]
      @dashboard_setting = DashboardSetting.find(db_params[:id])
    elsif @page.dashboard_setting
      @dashboard_setting = @page.dashboard_setting
    else
      @dashboard_setting = DashboardSetting.new
      @page.dashboard_setting = @dashboard_setting
    end
    @dashboard_setting.assign_attributes session[:dashboard_setting]["#{@page_id}"] if session[:dashboard_setting]["#{@page_id}"]
    if ds_id = db_params[:dataset_id]
      if @dashboard_setting.dataset_id && @dashboard_setting.dataset_id != ds_id
        delete_session_key(:dashboard_setting, @page_id)
        session[:invalid_steps][@page_id] = %w[type dashboard_widget preview]
        @dashboard_setting.widget_id = nil
      end
    end
    @dashboard_setting.assign_attributes db_params
  end
def build_current_dashboard_setting db_params = { } db_params = page_params . to_h [ :dashboard_setting ] if params [ :site_page ] && page_params &. to_h [ :dashboard_setting ] @dashboard_setting = nil return unless [ ContentType :: DASHBOARD_V2 ] . include? ( @page . content_type ) if db_params [ :id ] @dashboard_setting = DashboardSetting . find ( db_params [ :id ] ) elsif @page . dashboard_setting @dashboard_setting = @page . dashboard_setting else @dashboard_setting = DashboardSetting . new @page . dashboard_setting = @dashboard_setting end @dashboard_setting . assign_attributes session [ :dashboard_setting ] [ "#{@page_id}" ] if session [ :dashboard_setting ] [ "#{@page_id}" ] if ds_id = db_params [ :dataset_id ] if @dashboard_setting . dataset_id && @dashboard_setting . dataset_id != ds_id delete_session_key ( :dashboard_setting , @page_id ) session [ :invalid_steps ] [ @page_id ] = %w[ type dashboard_widget preview ] @dashboard_setting . widget_id = nil end end @dashboard_setting . assign_attributes db_params end
Builds the current dashboard setting based on the database, session and params
Builds the current dashboard setting based on the database session and params
# If the user changed the id of the dataset, the entity is reset