{{/*
  Copyright 2014 Team 254. All Rights Reserved.
  Author: pat@patfairbank.com (Patrick Fairbank)

  UI for listing matches and their results.
*/}}
{{define "title"}}Match Review{{end}}
{{define "body"}}
<div class="row">
  <ul class="nav nav-tabs" style="margin-bottom: 15px;">
    <li{{if eq .CurrentMatchType "practice" }} class="active"{{end}}>
      <a href="#practice" data-toggle="tab">Practice</a>
    </li>
    <li{{if eq .CurrentMatchType "qualification" }} class="active"{{end}}>
      <a href="#qualification" data-toggle="tab">Qualification</a>
    </li>
    <li{{if eq .CurrentMatchType "elimination" }} class="active"{{end}}>
      <a href="#elimination" data-toggle="tab">Playoff</a>
    </li>
  </ul>
  <div class="tab-content">
    {{range $type, $matches := .MatchesByType}}
      <div class="tab-pane {{if eq $.CurrentMatchType $type }} active{{end}}" id="{{$type}}">
        <table class="table table-striped table-hover ">
          <thead>
            <tr>
              <th>Match</th>
              <th>Time</th>
              <th class="text-center">Red Alliance</th>
              <th class="text-center">Blue Alliance</th>
              <th class="text-center">Red Score</th>
              <th class="text-center">Blue Score</th>
              <th class="text-center">Action</th>
            </tr>
          </thead>
          <tbody>
            {{range $match := $matches}}
              <tr class="{{$match.ColorClass}}">
                <td>{{$match.DisplayName}}</td>
                <td>{{$match.Time}}</td>
                <td class="text-center red-text">
                  {{index $match.RedTeams 0}}, {{index $match.RedTeams 1}}, {{index $match.RedTeams 2}}
                </td>
                <td class="text-center blue-text">
                  {{index $match.BlueTeams 0}}, {{index $match.BlueTeams 1}}, {{index $match.BlueTeams 2}}
                </td>
                <td class="text-center red-text">{{$match.RedScore}}</td>
                <td class="text-center blue-text">{{$match.BlueScore}}</td>
                <td class="text-center nowrap">
                  <a href="/match_review/{{$match.Id}}/edit"><b class="btn btn-info btn-xs">Edit</b></a>
                </td>
              </tr>
            {{end}}
          </tbody>
        </table>
      </div>
    {{end}}
  </div>
</div>
{{end}}
{{define "script"}}
{{end}}
