Start places overhaul

This commit is contained in:
Simon Martens
2025-09-28 03:53:03 +02:00
parent 2a3d2c2323
commit adc45f2212
13 changed files with 683 additions and 42 deletions

View File

@@ -13,6 +13,7 @@ type PlacesListView struct {
Search string
AvailableLetters []string
Places map[string]xmlmodels.Place
PlacePieceCounts map[string]int
Sorted []string
SelectedPlace *PlaceDetailView
TotalPiecesWithPlaces int
@@ -26,17 +27,23 @@ type PlaceDetailView struct {
// PlacesView returns places data for the overview page
func PlacesView(placeID string, lib *xmlmodels.Library) *PlacesListView {
res := PlacesListView{Search: placeID, Places: make(map[string]xmlmodels.Place)}
res := PlacesListView{
Search: placeID,
Places: make(map[string]xmlmodels.Place),
PlacePieceCounts: make(map[string]int),
}
av := make(map[string]bool)
// Get all places that are referenced in pieces and count total pieces with places
referencedPlaces := make(map[string]bool)
placePieceCounts := make(map[string]int)
totalPiecesWithPlaces := 0
for _, piece := range lib.Pieces.Array {
hasPlace := false
for _, placeRef := range piece.PlaceRefs {
referencedPlaces[placeRef.Ref] = true
placePieceCounts[placeRef.Ref]++
hasPlace = true
}
if hasPlace {
@@ -54,6 +61,9 @@ func PlacesView(placeID string, lib *xmlmodels.Library) *PlacesListView {
}
}
// Set the piece counts
res.PlacePieceCounts = placePieceCounts
// If a specific place is requested, get its details
if placeID != "" && len(placeID) > 1 {
if place, exists := res.Places[placeID]; exists {