oef/templates/schools_add_update.html.tpl

115 lines
4.8 KiB
Smarty

{{ define "content" }}
<div class="container">
{{$isAdmin := .Claims|isAdmin}}
{{$isSubscriber := .Claims|isSubscriber}}
{{$isSchool := .Claims|isSchool}}
{{$update := .Options.Get "update"}}
{{if not $isSubscriber}}
{{if $update}}
{{if $isSchool}}
{{template "breadcrumb" toSlice (.Data|string) (.Data.ID|show "School") "Aggiorna" "current"}}
{{else}}
{{template "breadcrumb" toSlice "Scuole" (all "School") (.Data|string) (.Data.ID|show "School") "Aggiorna" "current"}}
{{end}}
{{else}}
{{template "breadcrumb" toSlice "Scuole" (all "School") "Aggiungi" "current"}}
{{end}}
{{end}}
{{if $isSubscriber}}
{{template "add_update_header" dict "update" $update "addTitle" "Iscrivi la scuola" "updateTitle" (printf "Aggiorna scuola %s" (.Data|string))}}
{{else}}
{{template "add_update_header" dict "update" $update "addTitle" "Crea nuova scuola" "updateTitle" (printf "Aggiorna scuola %s" (.Data|string))}}
{{end}}
{{$form := "form_add_update"}}
<form
class="needs-validation"
action="{{if $update}}{{.Data.ID|update "School"}}{{else}}{{create "School"}}{{end}}"
method="POST"
role="form"
id={{$form}}>
{{$options := ` { name: "Name",id: "school_name",label: "Denominazione dell'istituto",placeholder: "Inserire la denominazione",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Name") "update" $update}}
{{$codeOptions := ""}}
{{if or $isAdmin $isSubscriber}}
{{$codeOptions = `
name: "Code"
id: "school_code"
label: "Codice meccanografico"
placeholder: "Inserire il codice meccanografico"
type: "text"
inputClass: "form-control uppercase"
otherAttrs: "maxlength=10 minlength=10"
required: "true"
`}}
{{end}}
{{if $isSchool}}
{{$codeOptions = `
name: "Code"
id: "school_code"
label: "Codice meccanografico"
type: "text"
inputClass: "form-control-plaintext"
otherAttrs: "readonly"
`}}
{{end}}
{{template "input" dict "options" ($codeOptions|yaml) "value" (.Data|field "Code") "update" $update}}
{{$options := ` { name: "Address",id: "school_address",label: "Indirizzo dell'istituto",placeholder: "Inserire via, numero civico e città",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Address") "update" $update}}
{{$options := `
name: "region_id"
id: "region_id"
label: "Regione"
title: "Seleziona la regione"
required: "true"
`}}
{{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllRegions") "selected" (.Data|field "SelectedRegion") "update" $update "form" $form}}
{{$options := ` { name: "Email",id: "school_email",label: "Indirizzo email",placeholder: "Inserire l'indirizzo di posta istituzionale",type: "email",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Email") "update" $update}}
<div class="form-row">
<div class="col">
{{$options := ` { name: "SchoolContactPersonFirstname",id: "school_contact_person_firstname",label: "Nome del referente di sede",placeholder: "Inserire il nome del referente di sede",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "SchoolContactPersonFirstname") "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "SchoolContactPersonLastname",id: "school_contact_person_lastname",label: "Cognome del referente di sede",placeholder: "Inserire il cognome del referente di sede",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "SchoolContactPersonLastname") "update" $update}}
</div>
</div>
<div class="form-row">
<div class="col">
{{$options := ` { name: "ContestDirectorFirstname",id: "school_contest_director_firstname",label: "Nome del responsabile di gara",placeholder: "Inserire il nome del responsabile di gara",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "ContestDirectorFirstname") "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "ContestDirectorLastname",id: "school_contest_director_lastname",label: "Cognome del responsabile di gara",placeholder: "Inserire il cognome del responsabile di gara",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "ContestDirectorLastname") "update" $update}}
</div>
</div>
{{if .Claims|isSubscriber}}
{{$options := ` { saveTitle: "Invia iscrizione", model: "School" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
{{else}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "School" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
{{end}}
</form>
</div>
{{ end }}