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

  UI for manually editing the result for a match.
*/}}
{{define "title"}}Edit Match Results{{end}}
{{define "body"}}
<div class="row">
  <div class="well">
    <form class="form-horizontal" method="POST">
      <fieldset>
        <legend>Edit Match {{.Match.DisplayName}} Results</legend>
        <div class="col-lg-6" id="redScore"></div>
        <div class="col-lg-6" id="blueScore"></div>
        <div class="row form-group">
          <div class="text-center col-lg-12">
            <a href="/match_review"><button type="button" class="btn btn-default">Cancel</button></a>
            <button type="submit" class="btn btn-info">Save</button>
          </div>
        </div>
      </fieldset>
    </form>
  </div>
</div>
<div id="scoreTemplate" style="display: none;">
  <div class="well well-{{"{{alliance}}"}}">
    <div class="form-group">
      <label>Autonomous</label>
      <input name="{{"{{alliance}}"}}AutoPoints" class="form-control"/>
    </div>
    <div class="form-group">
      <label>Teleoperated</label>
      <input name="{{"{{alliance}}"}}TeleopPoints" class="form-control"/>
    </div>
    <div class="form-group">
      <label>Endgame</label>
      <input name="{{"{{alliance}}"}}EndgamePoints" class="form-control"/>
    </div>
  </div>
</div>
{{end}}
{{define "script"}}
<script src="/static/js/match_review.js"></script>
<script>
  var matchId = {{.Match.Id}};
  matchResult = jQuery.parseJSON('{{.MatchResultJson}}');
  allianceResults["red"] = {alliance: "red", team1: {{.Match.Red1}}, team2: {{.Match.Red2}},
      team3: {{.Match.Red3}}, score: matchResult.RedScore};
  allianceResults["blue"] = {alliance: "blue", team1: {{.Match.Blue1}}, team2: {{.Match.Blue2}},
      team3: {{.Match.Blue3}}, score: matchResult.BlueScore};
  renderResults("red");
  renderResults("blue");
</script>
{{end}}
