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"] 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 return nil, err
} }

View file

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

View file

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

View file

@ -97,7 +97,7 @@
icon: "fa fa-hourglass-start" 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}} {{template "relation_list" dict "options" ($options|yaml) "data" .Data.Responses "noElements" $noElements}}
</div> </div>

View file

@ -12,8 +12,6 @@
{{- end -}} {{- end -}}
{{- if $isAdmin -}} {{- if $isAdmin -}}
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna %s" (.Data|string))}} {{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 -}} {{- end -}}
{{- $form := "form_add_update" -}} {{- $form := "form_add_update" -}}
<div class="row"> <div class="row">
@ -66,13 +64,15 @@
<div class="sticky-top sticky-offset"> <div class="sticky-top sticky-offset">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
Informazioni sulla gara Informazioni sulla prova
</div> </div>
<div class="card-body"> <div class="card-body">
<dl> <dl>
<dt>Gara</dt><dd>{{.Data.Contest}}</dd> <dt>Gara</dt><dd>{{.Data.Contest}}</dd>
<dt>Partecipante</dt><dd>{{.Data.Participant}}</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> </dl>
<button type="submit" class="btn btn-primary" form="{{$form}}">Salva</button> <button type="submit" class="btn btn-primary" form="{{$form}}">Salva</button>
</div> </div>

View file

@ -23,7 +23,7 @@
<dd class="col-sm-9"> <dd class="col-sm-9">
{{if not (.Data.Contest.Date|zeroTime)}} {{if not (.Data.Contest.Date|zeroTime)}}
Giorno {{.Data.Contest.Date|prettyDate}} dalle ore {{.Data.Contest.StartTime|convertTime}} alle ore {{.Data.Contest.EndTime|convertTime}} 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}} {{else}}
La gara è sempre attiva. La gara è sempre attiva.
{{end}} {{end}}