Skip to content

Commit

Permalink
Merge pull request #233 from jovandeginste/fix-legacy-keys
Browse files Browse the repository at this point in the history
fix: add function to get filename of workout
  • Loading branch information
jovandeginste authored Aug 4, 2024
2 parents e8ce84f + cb75c02 commit a47a8de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pkg/database/workouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ type GPXData struct {
Filename string // The filename of the file
}

func (w *Workout) Filename() string {
if !w.HasFile() {
return w.Name + ".txt"
}

return w.GPX.Filename
}

func (w *Workout) HasFile() bool {
if w.GPX == nil {
return false
Expand Down
4 changes: 3 additions & 1 deletion views/workouts/workouts_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
{{ with .workout }}
<div class="gap-4">
<h2 class="{{ IconFor .Type.String }}">
{{ .Name }} {{ with .Filename }}({{ . }}){{ end }}
{{ .Name }} {{ if .HasFile }}(<span class="{{ IconFor `file` }}"
>{{ .Filename }}</span
>) {{ end }}
</h2>
</div>
<div class="sm:flex sm:flex-wrap">
Expand Down
4 changes: 3 additions & 1 deletion views/workouts/workouts_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
{{ end }}

<h2 class="{{ IconFor .Type.String }}">
{{ .Name }} {{ with .Filename }}({{ . }}){{ end }}
{{ .Name }} {{ if .HasFile }}(<span class="{{ IconFor `file` }}"
>{{ .Filename }}</span
>) {{ end }}
</h2>
</div>
<div class="lg:flex lg:flex-wrap print:block">
Expand Down

0 comments on commit a47a8de

Please sign in to comment.