{{ define "content" }}

<div class="container">

  {{if .Options.Get "update"}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">Dipartimento</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiorna il dipartimento</a></li>
    </ol>
  </nav>
  {{else}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/departments?{{query "tpl_layout" "base" "tpl_content" "departments"}}">Dipartimento</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiungi</a></li>
    </ol>
  </nav>
  {{end}}

 {{if .Options.Get "update"}}
  <div class="karmen-info-header">
    <div class="row">
      <div class="col-md-8">
	<h1>Aggiorna il dipartimento</h1>
      </div>
    </div>
  </div>
  
  {{else}}
  <h1 class="karmen-info-header">Crea nuovo dipartimento</h1>
  {{end}}

  {{if .Options.Get "update"}}
  <form id="form_departments_add_update" action="/departments/{{.Data.Department.ID}}/update" method="POST" role="form" class="needs-validation">
  {{else}}
  <form id="form_departments_add_update" action="/departments/add/" method="POST" role="form" class="needs-validation">
  {{end}}

    <div class="form-group">
      <label class="control-label" for="department_name">Nome</label>
      <input type="text" name="Name" class="form-control" id="department_name" placeholder="Nome" {{if .Options.Get "update"}} value="{{.Data.Department.Name}}" {{end}} required>
    </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_departments_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">
      <button type="submit" class="btn btn-primary">Salva</button>
      {{if .Options.Get "update"}}
      <a href="/departments/{{.Data.Department.ID}}?{{query "tpl_layout" "base" "tpl_content" "departments_show"}}" class="btn btn-default">Annulla</a>
      {{else}}
      <a href="/departments/?{{query "tpl_layout" "base" "tpl_content" "departments"}}" class="btn btn-default">Annulla</a>
      {{end}}
    </div>
    
  </form>

</div>

{{ end }}
