app/controllers/records_controller.rb
# Collects individual records grouped by SeasonType (classified as 'generic').
#
# Dual-phase action:
# - Phase 1: GET => renders search form
# - Phase 2: XHR GET => renders AJAX grid with result, expects parameter:
#            - params[:season_type][:id] => the season_types.id for the filtering
#
Collects individual records grouped by SeasonType (classified as 'generic').
Collects individual records grouped by SeasonType ( classified as ' generic ' ) .
def for_season_type
    if request.xhr?
      @highlight_swimmer = Swimmer.find_by_id( params[:highlight_swimmer_id] ) if params[:highlight_swimmer_id]
      season_type = SeasonType.find_by_id( params[:season_type][:id] ) if params[:season_type] && params[:season_type][:id]
      @title = I18n.t('records.season_type_title') + (season_type ? " (#{season_type.short_name})" : '')
      collector = if season_type
        records = IndividualRecord.for_season_type( season_type.id )
        RecordCollector.new( list: records, record_type_code: 'FOR', season_type: season_type, swimmer: @highlight_swimmer )
      else
        RecordCollector.new( record_type_code: 'FOR' )
      end
      @grid_builder = RecordGridBuilder.new( collector, 'FOR' )
    else
      @title = I18n.t('records.season_type_search_title')
    end
    respond_to do |format|
      format.html
      format.js
    end
  end
def for_season_type if request . xhr? @highlight_swimmer = Swimmer . find_by_id ( params [ :highlight_swimmer_id ] ) if params [ :highlight_swimmer_id ] season_type = SeasonType . find_by_id ( params [ :season_type ] [ :id ] ) if params [ :season_type ] && params [ :season_type ] [ :id ] @title = I18n . t ( 'records.season_type_title' ) + ( season_type ? " (#{season_type.short_name})" : '' ) collector = if season_type records = IndividualRecord . for_season_type ( season_type . id ) RecordCollector . new ( list : records , record_type_code : 'FOR' , season_type : season_type , swimmer : @highlight_swimmer ) else RecordCollector . new ( record_type_code : 'FOR' ) end @grid_builder = RecordGridBuilder . new ( collector , 'FOR' ) else @title = I18n . t ( 'records.season_type_search_title' ) end respond_to do | format | format . html format . js end end
Collects individual records grouped by SeasonType (classified as 'generic').
Collects individual records grouped by SeasonType ( classified as ' generic ' ) .
# DEBUG #    logger.debug "\r\n\r\n!! ------ #{self.class.name} -----" #    logger.debug "> #{params.inspect}" #    logger.debug "> #{request.inspect}\r\n\r\n=====================================================\r\n\r\n" # AJAX call? Parse parameter and retrieve records range: # Check if we have also a possibile swimmer parameter to highlight his/her results: # (This is used by the swimmers_controller#radio tab, to show an highlighted swimmer #  among the Team records) # [Steve, 20140723] 'Must always specify the filtering type for the RecordCollector, # especially when we pre-load the list of records: # Respond according to requested format (GET request => .html, AJAX request => .js)