app/controllers/records_controller.rb
# Collects individual records/best results for a specified Team (classified as 'for teams').
#
# Dual-phase action:
# - Phase 1: GET => renders search form
# - Phase 2: XHR GET => renders AJAX grid with result, expects parameter:
#            - params[:team][:id] => the teams.id for the filtering
#
Collects individual records/best results for a specified Team (classified as 'for teams').
Collects individual records / best results for a specified Team ( classified as ' for teams ' ) .
def for_team
    if request.xhr? && params['team'] && params['team']['id']
      @highlight_swimmer = Swimmer.find_by_id( params['highlight_swimmer_id'] ) if params['highlight_swimmer_id']
      team = Team.find_by_id( params['team']['id'] )
      logger.debug "> @highlight_swimmer: #{@highlight_swimmer.inspect}"
      logger.debug "> team: #{team.inspect}"
      @title = team ? "#{ I18n.t('records.team_title') } (#{team.decorate.get_linked_name})".html_safe : I18n.t('records.team_title')
      collector = if team
        records = IndividualRecord.for_team( team.id )
        RecordCollector.new( list: records, record_type_code: 'TTB', team: team, swimmer: @highlight_swimmer )
      else
        RecordCollector.new( record_type_code: 'TTB' )
      end
      @grid_builder = RecordGridBuilder.new( collector, 'TTB' )
    else
      @title = I18n.t('records.team_search_title')
    end
    respond_to do |format|
      format.html
      format.js
    end
  end
def for_team if request . xhr? && params [ 'team' ] && params [ 'team' ] [ 'id' ] @highlight_swimmer = Swimmer . find_by_id ( params [ 'highlight_swimmer_id' ] ) if params [ 'highlight_swimmer_id' ] team = Team . find_by_id ( params [ 'team' ] [ 'id' ] ) logger . debug "> @highlight_swimmer: #{@highlight_swimmer.inspect}" logger . debug "> team: #{team.inspect}" @title = team ? "#{ I18n.t('records.team_title') } (#{team.decorate.get_linked_name})" . html_safe : I18n . t ( 'records.team_title' ) collector = if team records = IndividualRecord . for_team ( team . id ) RecordCollector . new ( list : records , record_type_code : 'TTB' , team : team , swimmer : @highlight_swimmer ) else RecordCollector . new ( record_type_code : 'TTB' ) end @grid_builder = RecordGridBuilder . new ( collector , 'TTB' ) else @title = I18n . t ( 'records.team_search_title' ) end respond_to do | format | format . html format . js end end
Collects individual records/best results for a specified Team (classified as 'for teams').
Collects individual records / best results for a specified Team ( classified as ' for teams ' ) .
# DEBUG #    logger.debug "\r\n\r\n!! ------ #{self.class.name} -----" #    logger.debug "> #{params.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) # DEBUG #        logger.debug "> Tot. records found: #{records.size}\r\n\r\n" # [Steve, 20140723] 'Must always specify the filtering type for the RecordCollector, # especially when we pre-load the list of records: # DEBUG #        logger.debug "> NO TEAM!\r\n\r\n" # Respond according to requested format (GET request => .html, AJAX request => .js)