oef/templates/contests_add_update.html.tpl

73 lines
3.6 KiB
Smarty

{{ define "content" }}
<div class="container">
{{$update := .Options.Get "update"}}
{{if $update}}
{{template "breadcrumb" toSlice "Gare" (all "Contest") (.Data|string) (.Data.ID|show "Contest") "Aggiorna" "current"}}
{{else}}
{{template "breadcrumb" toSlice "Gare" (all "Contest") "Aggiungi" "current"}}
{{end}}
{{template "add_update_header" dict "update" $update "addTitle" "Crea nuova gara" "updateTitle" (printf "Aggiorna gara %s" (.Data|string))}}
{{$form := "form_add_update"}}
<form
class="needs-validation"
action="{{if $update}}{{.Data.ID|update "Contest"}}{{else}}{{create "Contest"}}{{end}}"
method="POST"
role="form"
id={{$form}}>
{{$options := ` { name: "Name",id: "contest_name",label: "Nome della gara",placeholder: "Inserire il nome della gara",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Name") "update" $update}}
{{$options := ` { name: "Description",id: "contest_description",label: "Descrizione della gara",placeholder: "Inserire una breve descrizione della gara",type: "text",required: "true"} `}}
{{template "textarea" dict "options" ($options|yaml) "value" (.Data|field "Description") "update" $update}}
<div class="form-row">
<div class="col">
{{$options := ` { name: "Date",id: "contest_date",label: "La gara si svolgerà il giorno",type: "date" } `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Date"|convertDate) "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "StartTime",id: "contest_start_time",label: "Dalle ore",type: "time" } `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "StartTime"|convertTime) "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "EndTime",id: "contest_end_time",label: "Alle ore",type: "time" } `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "EndTime"|convertTime) "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "Duration",id: "contest_duration",label: "Durata",type: "number" } `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Duration") "update" $update}}
</div>
</div>
<div class="form-row">
<div class="col">
{{$options := ` { name: "NumQuestions",id: "contest_num_questions",label: "Numero totale delle domande presenti nella gara",placeholder: "Inserire il numero delle domande",type: "number",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "NumQuestions") "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "NumAnswersPerQuestion",id: "contest_num_answers_per_question",label: "Numero delle risposte per domanda",placeholder: "Inserire il numero delle risposte per domanda",type: "number",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "NumAnswersPerQuestion") "update" $update}}
</div>
</div>
{{if $update}}
<div class="form-row">
<div class="col">
{{$options := ` { name: "ResetStartTime",id: "contest_reset_start_time",label: "Resetta la prima eventuale visualizzazione dei partecipanti",formClass: "form-check form-check-inline" } `}}
{{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "ResetStartTime") "update" $update}}
</div>
</div>
{{end}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Contest" }`}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
</form>
</div>
{{ end }}