class Settings::PlansController

Public Instance Methods

show() click to toggle source
# File app/controllers/settings/plans_controller.rb, line 6
def show
  respond_to do |format|
    format.html
    format.partial
    format.json { render json: settings_json }
  end
end
update() click to toggle source
# File app/controllers/settings/plans_controller.rb, line 14
def update

  export_params = params[:export].try(:deep_symbolize_keys)

  settings = plan.super_settings(:export).tap do |s|
    if params[:commit] == 'Reset'
      s.formatting = nil
      s.fields = nil
    else
      s.formatting = export_params[:formatting]
      s.fields = export_params[:fields]
      s.title  = export_params[:title]
    end
  end

  if settings.save
    respond_to do |format|
      format.html { redirect_to(export_project_path(plan.project)) }
      format.json { render json: settings_json }
    end
  else
    settings.formatting = nil
    @export_settings = settings
    render(action: :show)
  end
end

Private Instance Methods

get_settings() click to toggle source
# File app/controllers/settings/plans_controller.rb, line 43
def get_settings
  @export_settings = plan.settings(:export)
end
plan() click to toggle source
# File app/controllers/settings/plans_controller.rb, line 51
def plan
  @plan ||= Plan.find(params[:id])
end
settings_json() click to toggle source
# File app/controllers/settings/plans_controller.rb, line 47
def settings_json
  @settings_json ||= { export: @export_settings }.to_json
end