Now it seems Skill distribution works as expected
This commit is contained in:
@@ -120,8 +120,16 @@ 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 {
|
||||
for _, tmpl := range templatesToScan {
|
||||
for _, block := range tmpl.Blocks {
|
||||
// Get the source data based on block's ListType
|
||||
var sourceData interface{}
|
||||
switch block.ListType {
|
||||
@@ -164,6 +172,7 @@ func (p *Paginator) PaginateMultiList(dataMap map[string]interface{}, templateNa
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If all lists are empty, return empty result
|
||||
if len(listTrackers) == 0 {
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
<div class="left-section">
|
||||
<!-- Skills tables -->
|
||||
<div class="skills-row">
|
||||
<!-- BLOCK: skills_learned, TYPE: skills, MAX: 7, FILTER: learned -->
|
||||
<!-- BLOCK: skills_learned_1, TYPE: skills, MAX: 31, FILTER: learned -->
|
||||
<table class="skills-table">
|
||||
<tr>
|
||||
<th>Fertigkeit</th>
|
||||
<th>EW</th>
|
||||
<th>PP</th>
|
||||
</tr>
|
||||
{{range .SkillsLearned}}
|
||||
{{range .SkillsLearned1}}
|
||||
<tr><td>{{.Name}}{{if .Bemerkung}}:<span style="font-size: smaller;">{{.Bemerkung}}</span>{{end}}</td><td>{{if .Value}}+ {{.Value}}{{else}} {{end}}</td><td>{{if .PracticePoints}}{{.PracticePoints}}{{end}}</td></tr>
|
||||
{{end}}
|
||||
</table>
|
||||
<div class="skills-stack">
|
||||
<!-- BLOCK: skills_languages, TYPE: skills, MAX: 6, FILTER: language, NOEMPTY -->
|
||||
<!-- BLOCK: skills_languages, TYPE: skills, MAX: 14, FILTER: language, NOEMPTY -->
|
||||
{{if .SkillsLanguage}}{{if (index .SkillsLanguage 0).Name}}
|
||||
<table class="skills-table" style="width: 100%; height: unset;">
|
||||
<tr>
|
||||
@@ -51,14 +51,14 @@
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}{{end}}
|
||||
<!-- BLOCK: skills_learned, TYPE: skills, MAX: 10, FILTER: learned -->
|
||||
<!-- BLOCK: skills_learned_2, TYPE: skills, MAX: 16, FILTER: learned -->
|
||||
<table class="skills-table" style="width: 100%; height: unset;">
|
||||
<tr>
|
||||
<th>Fertigkeit</th>
|
||||
<th>EW</th>
|
||||
<th>PP</th>
|
||||
</tr>
|
||||
{{range .SkillsLearned}}
|
||||
{{range .SkillsLearned2}}
|
||||
<tr><td>{{.Name}}{{if .Bemerkung}}:<span style="font-size: smaller;">{{.Bemerkung}}</span>{{end}}</td><td>{{if .Value}}+ {{.Value}}{{else}} {{end}}</td><td>{{if .PracticePoints}}{{.PracticePoints}}{{end}}</td></tr>
|
||||
{{end}}
|
||||
</table>
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="right-section">
|
||||
<!-- Weapons table -->
|
||||
<div class="margin-bottom-3">
|
||||
<!-- BLOCK: weapons_main, TYPE: weapons, MAX: 3 -->
|
||||
<!-- BLOCK: weapons_main, TYPE: weapons, MAX: 29 -->
|
||||
<table class="weapons-table">
|
||||
<tr>
|
||||
<th>Waffe</th>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="flex main-content">
|
||||
<!-- Left spell table -->
|
||||
<div class="left-section">
|
||||
<!-- BLOCK: spells_column1, TYPE: spells, MAX: 5 -->
|
||||
<!-- BLOCK: spells_column1, TYPE: spells, MAX: 15 -->
|
||||
<table class="spells-table">
|
||||
<tr>
|
||||
<th>AP<hr>Prozess *</th>
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<!-- Right spell table -->
|
||||
<div class="right-section">
|
||||
<!-- BLOCK: spells_column2, TYPE: spells, MAX: 2 -->
|
||||
<!-- BLOCK: spells_column2, TYPE: spells, MAX: 10 -->
|
||||
<table class="spells-table">
|
||||
<tr>
|
||||
<th>AP<br>Prozess *</th>
|
||||
|
||||
Reference in New Issue
Block a user