mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 02:25:30 +00:00
+a-z nav on alma pages
This commit is contained in:
@@ -67,6 +67,9 @@ type AlmanachResult struct {
|
||||
|
||||
Types []string
|
||||
HasScans bool
|
||||
|
||||
PrevByTitle *dbmodels.Entry
|
||||
NextByTitle *dbmodels.Entry
|
||||
}
|
||||
|
||||
func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters) (*AlmanachResult, error) {
|
||||
@@ -167,6 +170,11 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
|
||||
agentsMap[a.Id] = a
|
||||
}
|
||||
|
||||
prevByTitle, nextByTitle, err := entryNeighborsByPreferredTitle(app, entry.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := &AlmanachResult{
|
||||
Entry: entry,
|
||||
Places: places,
|
||||
@@ -179,6 +187,8 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
|
||||
ContentsAgents: caMap,
|
||||
Types: types,
|
||||
HasScans: hs,
|
||||
PrevByTitle: prevByTitle,
|
||||
NextByTitle: nextByTitle,
|
||||
}
|
||||
|
||||
ret.Collections()
|
||||
@@ -186,6 +196,32 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
|
||||
|
||||
}
|
||||
|
||||
func entryNeighborsByPreferredTitle(app core.App, entryID string) (*dbmodels.Entry, *dbmodels.Entry, error) {
|
||||
entries := []*dbmodels.Entry{}
|
||||
if err := app.RecordQuery(dbmodels.ENTRIES_TABLE).All(&entries); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
return nil, nil, nil
|
||||
}
|
||||
dbmodels.Sort_Entries_Title_Year(entries)
|
||||
for index, item := range entries {
|
||||
if item.Id != entryID {
|
||||
continue
|
||||
}
|
||||
var prev *dbmodels.Entry
|
||||
var next *dbmodels.Entry
|
||||
if index > 0 {
|
||||
prev = entries[index-1]
|
||||
}
|
||||
if index+1 < len(entries) {
|
||||
next = entries[index+1]
|
||||
}
|
||||
return prev, next, nil
|
||||
}
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (r *AlmanachResult) Collections() {
|
||||
ids := []int{}
|
||||
collections := []*dbmodels.Content{}
|
||||
|
||||
@@ -116,32 +116,6 @@ func NewAlmanachEditResult(app core.App, id string, filters BeitraegeFilterParam
|
||||
}, nil
|
||||
}
|
||||
|
||||
func entryNeighborsByPreferredTitle(app core.App, entryID string) (*dbmodels.Entry, *dbmodels.Entry, error) {
|
||||
entries := []*dbmodels.Entry{}
|
||||
if err := app.RecordQuery(dbmodels.ENTRIES_TABLE).All(&entries); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
return nil, nil, nil
|
||||
}
|
||||
dbmodels.Sort_Entries_Title_Year(entries)
|
||||
for index, item := range entries {
|
||||
if item.Id != entryID {
|
||||
continue
|
||||
}
|
||||
var prev *dbmodels.Entry
|
||||
var next *dbmodels.Entry
|
||||
if index > 0 {
|
||||
prev = entries[index-1]
|
||||
}
|
||||
if index+1 < len(entries) {
|
||||
next = entries[index+1]
|
||||
}
|
||||
return prev, next, nil
|
||||
}
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (p *AlmanachEditPage) POSTSave(engine *templating.Engine, app core.App) HandleFunc {
|
||||
return func(e *core.RequestEvent) error {
|
||||
id := e.Request.PathValue("id")
|
||||
|
||||
Reference in New Issue
Block a user