Organize proclamations alphabetically
This commit is contained in:
@@ -2,6 +2,7 @@ package page
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -135,11 +136,6 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error {
|
||||
|
||||
for _, pr := range allProcs {
|
||||
fi := p.createFlatItem(pr.Name, pr.ID, false, 0)
|
||||
// Searching the name AND the content is returning too many options
|
||||
// I am removing this, for now, to narrow the search results.
|
||||
// I think a tag system should be implemented and search based on tags
|
||||
// and names, but not necessarily content.
|
||||
// fi.SearchText = strings.ToLower(pr.Name + " " + pr.Content)
|
||||
fi.SearchText = strings.ToLower(pr.Name)
|
||||
p.allProclamations = append(p.allProclamations, fi)
|
||||
}
|
||||
@@ -251,9 +247,15 @@ func (p *ProclamationOptions) expand(index int) {
|
||||
newItems = append(newItems, fi)
|
||||
}
|
||||
|
||||
// Load proclamations
|
||||
// Load proclamations for this category
|
||||
var procs []db.Proclamation
|
||||
p.Context.DbPtr.Where("category_id = ?", parentID).Where("ID != ?", defaultProclamationID).Find(&procs)
|
||||
|
||||
// Sort proclamations alphabetically by name
|
||||
sort.Slice(procs, func(i, j int) bool {
|
||||
return strings.ToLower(procs[i].Name) < strings.ToLower(procs[j].Name)
|
||||
})
|
||||
|
||||
for _, pr := range procs {
|
||||
var fi *FlatItem
|
||||
// Reuse existing proclamation from allProclamations if available
|
||||
|
||||
Reference in New Issue
Block a user