{{ define "content" }}

<div class="container">

  {{if .Options.Get "update"}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/classes">Classi</a></li>
      <li class="breadcrumb-item"><a href="/classes/{{.Data.Class.ID}}?{{query "tpl_layout" "base" "tpl_content" "classes"}}">{{.Data.Class.Name}}</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiorna la classe</a></li>
    </ol>
  </nav>
  {{else}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/classes/?{{query "tpl_layout" "base" "tpl_content" "classes"}}">Classi</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiungi</a></li>
    </ol>
  </nav>
  {{end}}

  {{if .Options.Get "update"}}
  <h1 class="karmen-info-header">Aggiorna la classe "{{.Data.Class.Name}}"</h1>
  {{else}}
  <h1 class="karmen-info-header">Crea una nuova classe</h1>
  {{end}}

  {{if .Options.Get "update"}}
  <form id="form_classes_add_update" action="/classes/{{.Data.Class.ID}}/update" method="POST" role="form" class="needs-validation">
  {{else}}
  <form id="form_classes_add_update" action="/classes/add/" method="POST" role="form" class="needs-validation">
  {{end}}  
    
    <div class="form-group">
      <label class="control-label" for="class_name">Nome</label>
      <input type="text" name="Name" class="form-control" id="class_name" placeholder="Nome" {{if .Options.Get "update"}} value="{{.Data.Class.Name}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="class_year">Anno</label>
      <input type="number" min="1" name="Year" class="form-control" id="class_year" placeholder="Annualità" {{if .Options.Get "update"}} value="{{.Data.Class.Year}}" {{end}} required>
    </div>
    
    <div class="form-group">
      <label class="control-label" for="class_name">Sezione</label>
      <input type="text" name="Section" class="form-control" id="class_section" placeholder="Sezione" {{if .Options.Get "update"}} value="{{.Data.Class.Section}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="class_field">Indirizzo</label>
      <input type="text" name="Field" class="form-control" id="class_field" placeholder="Indirizzo" {{if .Options.Get "update"}} value="{{.Data.Class.Field}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="class_alias">Nome alternativo</label>
      <input type="text" name="Alias" class="form-control" id="class_alias" placeholder="Nome alternativo" {{if .Options.Get "update"}} value="{{.Data.Class.Alias}}" {{end}}>
    </div>

    <div class="form-group">
      <label class="control-label" for="coordinator_id">Coordinatore</label>
      <select name="coordinator_id" class="form-control selectpicker" id="coordinator_id" placeholder="Coordinatore" data-live-search="true" form="form_classes_add_update" title="Seleziona il nome del coordinatore" data-dropup-auto="false">
	<option value="0"></option>
  	{{range $teacher := .Data.AllTeachers}}
	{{if $.Options.Get "update"}}
  	<option
	   value="{{$teacher.ID}}"
	   {{index $.Data.SelectedCoordinator $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
	</option>
	{{else}}
  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    
    <div class="form-group">
      <label class="control-label" for="minuter_id">Verbalizzante</label>
      <select name="minuter_id" class="form-control selectpicker" id="minuter_id" placeholder="Verbalizzante" data-live-search="true" form="form_classes_add_update" title="Seleziona il nome del verbalizzante" data-dropup-auto="false">
	<option value="0"></option>
  	{{range $teacher := .Data.AllTeachers}}
	{{if $.Options.Get "update"}}
  	<option
	   value="{{$teacher.ID}}"
	   {{index $.Data.SelectedMinuter $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
	</option>
	{{else}}
  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    <div class="form-group">
      <button type="submit" class="btn btn-primary">Salva</button>
      {{if .Options.Get "update"}}
      <a href="/classes/{{.Data.Class.ID}}?{{query "tpl_layout" "base" "tpl_content" "classes_show"}}" class="btn btn-default">Annulla</a>
      {{else}}
      <a href="/classes/?{{query "tpl_layout" "base" "tpl_content" "classes"}}" class="btn btn-default">Annulla</a>
      {{end}}
    </div>
    
  </form>

</div>

{{ end }}
