Allow empty places in rankings; rebuild the list editor
Entries now sit at places 1…max with gaps allowed (#28, nothing at #29, #30). Moving onto an empty place just puts the entry there; onto a taken place, the entries in between shift one step, stopping at the first empty place, so lists without gaps reorder exactly as before. Inserts push down only to the next gap; deleting can close up or leave the place empty. New endpoint POST /api/lists/{id}/places inserts or removes empty places or closes every gap; move and delete reply with every entry's place. The podium shows an empty step for an empty #2 or #3, and a list can't shrink below its last used place. The editor loads every entry (no paging) and applies edits instantly with the same rules (places.js mirrors places.go), queueing saves in the background and reconciling with the server's reply. Type a place and press Enter (↑/↓ move between boxes, Alt+↑/↓ moves the entry), drag, or use the row menu. Empty runs show as rows with Add here and Remove, and a toolbar shows the gap count, Close gaps and a Go to # box. Clicking an entry opens it for editing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf915c04db
commit
88373176f2
15 files changed
+1090
-233
No files matched your search
@@ -108,6 +108,30 @@ var funcs = template.FuncMap{
|
||||
// everything below them.
|
||||
"first": func(n int, items []ItemView) []ItemView { return items[:min(n, len(items))] },
|
||||
"after": func(n int, items []ItemView) []ItemView { return items[min(n, len(items)):] },
|
||||
// podium returns places 1–3 for the podium, nil for an empty one, up to
|
||||
// the last of them that's taken.
|
||||
"podium": func(items []ItemView) []*ItemView {
|
||||
spots := make([]*ItemView, 0, 3)
|
||||
for i := range items {
|
||||
if items[i].Rank > 3 {
|
||||
break
|
||||
}
|
||||
for len(spots) < items[i].Rank-1 {
|
||||
spots = append(spots, nil)
|
||||
}
|
||||
spots = append(spots, &items[i])
|
||||
}
|
||||
return spots
|
||||
},
|
||||
// belowPlace returns the entries placed after #n.
|
||||
"belowPlace": func(n int, items []ItemView) []ItemView {
|
||||
for i, it := range items {
|
||||
if it.Rank > n {
|
||||
return items[i:]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
// flatLayout is how a style shows entries that aren't featured.
|
||||
"flatLayout": func(style string) string {
|
||||
if style == "grid" {
|
||||
|
||||
Reference in new issue
Block a user