Recent list: initial the first name, keep timestamp from wrapping
Abbreviate "First Last" → "F. Last" in the recent list and nowrap the upload timestamp, so rows fit on narrow phone screens instead of wrapping. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
2a3077fa26
commit
b92787be7a
2 changed files with 14 additions and 2 deletions
|
|
@ -91,7 +91,7 @@ ul.recent .amt { font-weight: 600; }
|
|||
ul.recent .meta { color: #333; }
|
||||
ul.recent .atts { margin-left: .15rem; }
|
||||
ul.recent .atts a { text-decoration: none; }
|
||||
ul.recent .when { color: #999; font-size: .8rem; margin-left: .35rem; }
|
||||
ul.recent .when { color: #999; font-size: .8rem; margin-left: .35rem; white-space: nowrap; }
|
||||
p.pager { margin-top: 1rem; }
|
||||
|
||||
.err {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"maisym.com/hsa/internal/receipt"
|
||||
|
|
@ -129,7 +130,7 @@ func (s *Server) renderRecent(w http.ResponseWriter, r *http.Request, orderBy, t
|
|||
Date: row.ReceiptDate.Format(dateLayout),
|
||||
Amount: dollars(row.AmountCents),
|
||||
Category: row.Category,
|
||||
Who: row.Who,
|
||||
Who: shortWho(row.Who),
|
||||
When: row.UploadedAt.Local().Format("2006-01-02 15:04"),
|
||||
Filename: row.OriginalFilename,
|
||||
Attachments: links,
|
||||
|
|
@ -224,6 +225,17 @@ func (s *Server) handleAttachmentFile(w http.ResponseWriter, r *http.Request) {
|
|||
http.ServeContent(w, r, a.OriginalFilename, a.UploadedAt, bytes.NewReader(a.ImageData))
|
||||
}
|
||||
|
||||
// shortWho abbreviates a "First Last" person label to "F. Last" to keep the recent
|
||||
// list compact on narrow screens. Single-word or empty labels are left as-is.
|
||||
func shortWho(label string) string {
|
||||
fields := strings.Fields(label)
|
||||
if len(fields) < 2 {
|
||||
return label
|
||||
}
|
||||
first := []rune(fields[0])
|
||||
return string(first[0]) + ". " + fields[len(fields)-1]
|
||||
}
|
||||
|
||||
// dollars formats integer cents as a plain dollar string, e.g. 1234 -> "12.34".
|
||||
func dollars(cents int64) string {
|
||||
if cents < 0 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue