Improve response UI

This commit is contained in:
Andrea Fazzi 2020-02-03 12:52:56 +01:00
parent 007d25d7c4
commit 368de33447
8 changed files with 30 additions and 17 deletions

10
dist/main.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -132,7 +132,12 @@ func (model *Response) Read(db *Database, args map[string]string, w http.Respons
id := args["id"]
if err := db._db.Preload("Contest").Preload("Participant").First(&response, id).Error; err != nil {
if err := db._db.
Preload("Contest").
Preload("Participant").
Preload("Creator").
Preload("Updater").
First(&response, id).Error; err != nil {
return nil, err
}

View file

@ -33,7 +33,7 @@ var (
"prettyTime": prettyTime,
"prettyDateTime": prettyDateTime,
"zeroTime": zeroTime,
"minutes": minutes,
"seconds": seconds,
"modelPath": modelPath,
"dict": dict,
"yaml": yaml,
@ -50,7 +50,7 @@ var (
"mod2": mod2,
"toLower": toLower,
"anchor": anchor,
"alertLink": alertLink,
"alertLink": alertLink,
"html": html,
"field": field,
"modelName": modelName,
@ -329,8 +329,8 @@ func zeroTime(t *time.Time) bool {
return *t == time.Time{}
}
func minutes(d time.Duration) int {
return int(d.Minutes())
func seconds(d time.Duration) int {
return int(d.Seconds())
}
func modelPath(model string, action string, id uint) string {

View file

@ -4,9 +4,13 @@ $(function () {
setInterval(function() {
var timeleft = parseInt($("#timeleft").html());
timeleft--;
if (timeleft > 0) {
timeleft--;
} else {
timeleft = 0;
}
$("#timeleft").html(timeleft)
}, 1000*60);
}, 1000);
$("#myInput").on("keyup", function(eventObject) {

View file

@ -97,7 +97,7 @@
icon: "fa fa-hourglass-start"
`}}
{{$noElements := "Al partecipante non è associata alcuna risposta."}}
{{$noElements := "Al partecipante non è associata alcuna prova."}}
{{template "relation_list" dict "options" ($options|yaml) "data" .Data.Responses "noElements" $noElements}}
</div>

View file

@ -12,8 +12,6 @@
{{- end -}}
{{- if $isAdmin -}}
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna %s" (.Data|string))}}
{{- else -}}
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (.Data|string)}}
{{- end -}}
{{- $form := "form_add_update" -}}
<div class="row">
@ -66,13 +64,15 @@
<div class="sticky-top sticky-offset">
<div class="card">
<div class="card-header">
Informazioni sulla gara
Informazioni sulla prova
</div>
<div class="card-body">
<dl>
<dt>Gara</dt><dd>{{.Data.Contest}}</dd>
<dt>Partecipante</dt><dd>{{.Data.Participant}}</dd>
<dt>Tempo rimanente</dt>{{if and $isParticipant .Data.TimeLeft}}<dd><span id="timeleft">{{.Data.TimeLeft.Minutes|toInt}}</span> minuti rimanenti</dd>{{else}}<dd>La gara è sempre attiva</dd>{{end}}
{{- if $isParticipant -}}
<dt>Tempo rimanente</dt>{{if .Data.TimeLeft}}<dd><span id="timeleft">{{.Data.TimeLeft.Seconds|toInt}}</span> secondi rimanenti</dd>{{else}}<dd>La gara è sempre attiva</dd>{{end}}
{{- end -}}
</dl>
<button type="submit" class="btn btn-primary" form="{{$form}}">Salva</button>
</div>

View file

@ -23,7 +23,7 @@
<dd class="col-sm-9">
{{if not (.Data.Contest.Date|zeroTime)}}
Giorno {{.Data.Contest.Date|prettyDate}} dalle ore {{.Data.Contest.StartTime|convertTime}} alle ore {{.Data.Contest.EndTime|convertTime}}
{{- if not .Data.IsActive -}}<strong> [Scaduta]</strong>{{- end -}}
{{- if not .Data.IsActive -}}<strong> [Scaduta o non ancora attiva]</strong>{{- end -}}
{{else}}
La gara è sempre attiva.
{{end}}