Remove unused method
This commit is contained in:
@@ -144,55 +144,6 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// expandAndCollectProcs is like expand() but also populates SearchText and allProclamations.
|
||||
// Used only during Init to build the initial fully-expanded tree.
|
||||
func (p *ProclamationOptions) expandAndCollectProcs(index int, procContentMap map[string]string) {
|
||||
parent := p.allItems[index]
|
||||
parentID, _ := strconv.Atoi(parent.ID)
|
||||
var newItems []*FlatItem
|
||||
|
||||
var cats []db.ProclamationCategory
|
||||
p.Context.DbPtr.Where("parent_id = ?", parentID).Find(&cats)
|
||||
for _, c := range cats {
|
||||
fi := p.createFlatItem(c.Name, fmt.Sprint(c.ID), true, parent.Depth+1)
|
||||
fi.Expanded = true
|
||||
newItems = append(newItems, fi)
|
||||
}
|
||||
|
||||
var procs []db.Proclamation
|
||||
p.Context.DbPtr.Where("category_id = ?", parentID).Find(&procs)
|
||||
for _, pr := range procs {
|
||||
fi := p.createFlatItem(pr.Name, pr.ID, false, parent.Depth+1)
|
||||
fi.SearchText = strings.ToLower(pr.Name + " " + pr.Content)
|
||||
newItems = append(newItems, fi)
|
||||
}
|
||||
|
||||
tail := append([]*FlatItem{}, p.allItems[index+1:]...)
|
||||
p.allItems = append(p.allItems[:index+1], append(newItems, tail...)...)
|
||||
|
||||
// Recurse into subcategories and collect their proclamations too
|
||||
i := index + 1
|
||||
for i < len(p.allItems) && p.allItems[i].Depth > parent.Depth {
|
||||
item := p.allItems[i]
|
||||
if item.IsCategory {
|
||||
p.expandAndCollectProcs(i, procContentMap)
|
||||
} else {
|
||||
// It's a leaf — add to pool if not already present
|
||||
alreadyIn := false
|
||||
for _, existing := range p.allProclamations {
|
||||
if existing.ID == item.ID {
|
||||
alreadyIn = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !alreadyIn {
|
||||
p.allProclamations = append(p.allProclamations, item)
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProclamationOptions) createFlatItem(name, id string, isCat bool, depth int) *FlatItem {
|
||||
text := name
|
||||
if isCat && depth == 0 {
|
||||
|
||||
Reference in New Issue
Block a user