diff --git a/backend/pdfrender/pagination.go b/backend/pdfrender/pagination.go
index 8fd12df..9b7b440 100644
--- a/backend/pdfrender/pagination.go
+++ b/backend/pdfrender/pagination.go
@@ -120,46 +120,55 @@ func (p *Paginator) PaginateMultiList(dataMap map[string]interface{}, templateNa
// Track by "listType:filter" to avoid duplicates
listTrackers := make(map[string]*listTracker)
+ // Scan both base template and continuation template to find all unique listType:filter combinations
+ templatesToScan := []*TemplateMetadata{template}
+ continuationName := GenerateContinuationTemplateName(templateName, 2)
+ if contTemplate := p.findTemplate(continuationName); contTemplate != nil {
+ templatesToScan = append(templatesToScan, contTemplate)
+ }
+
// First pass: create filtered lists for each unique listType+filter combination
- for _, block := range template.Blocks {
- // Get the source data based on block's ListType
- var sourceData interface{}
- switch block.ListType {
- case "skills":
- sourceData = dataMap["skills"]
- case "weapons":
- sourceData = dataMap["weapons"]
- case "spells":
- sourceData = dataMap["spells"]
- case "equipment":
- sourceData = dataMap["equipment"]
- case "magicItems":
- sourceData = dataMap["magicItems"]
- default:
- continue
- }
+ for _, tmpl := range templatesToScan {
+ for _, block := range tmpl.Blocks {
+ // Get the source data based on block's ListType
+ var sourceData interface{}
+ switch block.ListType {
+ case "skills":
+ sourceData = dataMap["skills"]
+ case "weapons":
+ sourceData = dataMap["weapons"]
+ case "spells":
+ sourceData = dataMap["spells"]
+ case "equipment":
+ sourceData = dataMap["equipment"]
+ case "magicItems":
+ sourceData = dataMap["magicItems"]
+ default:
+ continue
+ }
- if sourceData == nil {
- continue
- }
+ if sourceData == nil {
+ continue
+ }
- // Create unique key for this list type + filter combination
- trackerKey := block.ListType
- if block.Filter != "" {
- trackerKey += ":" + block.Filter
- }
+ // Create unique key for this list type + filter combination
+ trackerKey := block.ListType
+ if block.Filter != "" {
+ trackerKey += ":" + block.Filter
+ }
- // Only create tracker once per unique combination
- if _, exists := listTrackers[trackerKey]; !exists {
- // Apply filter if specified
- filteredItems := p.applyFilter(sourceData, block.Filter)
- itemCount := p.getItemCount(filteredItems)
+ // Only create tracker once per unique combination
+ if _, exists := listTrackers[trackerKey]; !exists {
+ // Apply filter if specified
+ filteredItems := p.applyFilter(sourceData, block.Filter)
+ itemCount := p.getItemCount(filteredItems)
- if itemCount > 0 {
- listTrackers[trackerKey] = &listTracker{
- items: filteredItems,
- currentIdx: 0,
- totalCount: itemCount,
+ if itemCount > 0 {
+ listTrackers[trackerKey] = &listTracker{
+ items: filteredItems,
+ currentIdx: 0,
+ totalCount: itemCount,
+ }
}
}
}
@@ -188,11 +197,21 @@ func (p *Paginator) PaginateMultiList(dataMap map[string]interface{}, templateNa
break
}
+ // Determine template name for this page
+ pageTemplateName := GenerateContinuationTemplateName(templateName, pageNum)
+
+ // Load the correct template metadata for this page
+ // Fall back to base template if continuation template doesn't exist
+ currentTemplate := p.findTemplate(pageTemplateName)
+ if currentTemplate == nil {
+ currentTemplate = template
+ }
+
// Create page data
pageData := make(map[string]interface{})
// Distribute items to each block for this page
- for _, block := range template.Blocks {
+ for _, block := range currentTemplate.Blocks {
// Get tracker for this block's list type + filter
trackerKey := block.ListType
if block.Filter != "" {
@@ -221,7 +240,11 @@ func (p *Paginator) PaginateMultiList(dataMap map[string]interface{}, templateNa
if block.NoEmpty && itemsToTake == 0 {
continue
}
-
+ // For regular blocks with no items remaining, fill with empty rows
+ if itemsToTake == 0 {
+ pageData[block.Name] = p.createEmptySliceWithCapacity(block.ListType, block.MaxItems)
+ continue
+ }
// Extract slice for this block
blockItems := p.extractSlice(tracker.items, tracker.currentIdx, itemsToTake)
@@ -232,9 +255,7 @@ func (p *Paginator) PaginateMultiList(dataMap map[string]interface{}, templateNa
tracker.currentIdx += itemsToTake
}
- // Determine template name - use continuation naming for pages 2+
- pageTemplateName := GenerateContinuationTemplateName(templateName, pageNum)
-
+ // Template name was already determined at the start of the loop
distributions = append(distributions, PageDistribution{
TemplateName: pageTemplateName,
PageNumber: pageNum,
diff --git a/backend/pdfrender/render_with_continuation.go b/backend/pdfrender/render_with_continuation.go
index d646e86..b91d0cb 100644
--- a/backend/pdfrender/render_with_continuation.go
+++ b/backend/pdfrender/render_with_continuation.go
@@ -116,6 +116,14 @@ func populatePageDataFromDistribution(pageData *PageData, dist PageDistribution)
if skills, ok := data.([]SkillViewModel); ok {
pageData.SkillsLearned = skills
}
+ case "skills_learned_1":
+ if skills, ok := data.([]SkillViewModel); ok {
+ pageData.SkillsLearned1 = skills
+ }
+ case "skills_learned_2":
+ if skills, ok := data.([]SkillViewModel); ok {
+ pageData.SkillsLearned2 = skills
+ }
case "skills_unlearned":
if skills, ok := data.([]SkillViewModel); ok {
// Add to general Skills list for template compatibility
diff --git a/backend/pdfrender/template_metadata.go b/backend/pdfrender/template_metadata.go
index a876180..57cc7f8 100644
--- a/backend/pdfrender/template_metadata.go
+++ b/backend/pdfrender/template_metadata.go
@@ -51,9 +51,13 @@ func LoadTemplateSetFromFiles(templateDir string) (TemplateSet, error) {
description string
}{
{"page_1.html", "stats", "Statistikseite mit Grundwerten"},
+ {"page_1.2.html", "stats", "Fortsetzung Statistikseite"},
{"page_2.html", "play", "Spielbogen mit gelernten Fertigkeiten und Waffen"},
+ {"page_2.2.html", "play", "Fortsetzung Spielbogen"},
{"page_3.html", "spell", "Zauberseite mit Zauberliste"},
+ {"page_3.2.html", "spell", "Fortsetzung Zauberseite"},
{"page_4.html", "equip", "Ausrüstungsseite"},
+ {"page_4.2.html", "equip", "Fortsetzung Ausrüstungsseite"},
}
// Load each template file and parse its metadata
diff --git a/backend/pdfrender/viewmodel.go b/backend/pdfrender/viewmodel.go
index c0444df..7078613 100644
--- a/backend/pdfrender/viewmodel.go
+++ b/backend/pdfrender/viewmodel.go
@@ -191,6 +191,8 @@ type PageData struct {
SkillsColumn3 []SkillViewModel // For continuation pages (page_1.2)
SkillsColumn4 []SkillViewModel // For continuation pages (page_1.2)
SkillsLearned []SkillViewModel // Filtered learned skills (page_2)
+ SkillsLearned1 []SkillViewModel // First block of learned skills (page_2.2)
+ SkillsLearned2 []SkillViewModel // Second block of learned skills (page_2.2)
SkillsLanguage []SkillViewModel // Filtered language skills (page_2)
Weapons []WeaponViewModel
Spells []SpellViewModel
diff --git a/backend/templates/Default_A4_Quer/page_2.2.html b/backend/templates/Default_A4_Quer/page_2.2.html
index 411bdaf..bcc5d09 100644
--- a/backend/templates/Default_A4_Quer/page_2.2.html
+++ b/backend/templates/Default_A4_Quer/page_2.2.html
@@ -26,19 +26,19 @@
-
+
| Fertigkeit |
EW |
PP |
- {{range .SkillsLearned}}
+ {{range .SkillsLearned1}}
| {{.Name}}{{if .Bemerkung}}:{{.Bemerkung}}{{end}} | {{if .Value}}+ {{.Value}}{{else}} {{end}} | {{if .PracticePoints}}{{.PracticePoints}}{{end}} |
{{end}}
-
+
{{if .SkillsLanguage}}{{if (index .SkillsLanguage 0).Name}}
@@ -51,14 +51,14 @@
{{end}}
{{end}}{{end}}
-
+
| Fertigkeit |
EW |
PP |
- {{range .SkillsLearned}}
+ {{range .SkillsLearned2}}
| {{.Name}}{{if .Bemerkung}}:{{.Bemerkung}}{{end}} | {{if .Value}}+ {{.Value}}{{else}} {{end}} | {{if .PracticePoints}}{{.PracticePoints}}{{end}} |
{{end}}
@@ -69,7 +69,7 @@
-
+
| Waffe |
diff --git a/backend/templates/Default_A4_Quer/page_3.2.html b/backend/templates/Default_A4_Quer/page_3.2.html
index 91ed1cb..df050b2 100644
--- a/backend/templates/Default_A4_Quer/page_3.2.html
+++ b/backend/templates/Default_A4_Quer/page_3.2.html
@@ -26,7 +26,7 @@
-
+
AP Prozess * |
@@ -51,7 +51,7 @@