mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 10:35:30 +00:00
Alphbetical Alm-Nav
This commit is contained in:
@@ -80,8 +80,10 @@ func (p *AlmanachEditPage) GET(engine *templating.Engine, app core.App) HandleFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AlmanachEditResult struct {
|
type AlmanachEditResult struct {
|
||||||
Next *dbmodels.Entry
|
NextByID *dbmodels.Entry
|
||||||
Prev *dbmodels.Entry
|
PrevByID *dbmodels.Entry
|
||||||
|
NextByTitle *dbmodels.Entry
|
||||||
|
PrevByTitle *dbmodels.Entry
|
||||||
User *dbmodels.User
|
User *dbmodels.User
|
||||||
AlmanachResult
|
AlmanachResult
|
||||||
}
|
}
|
||||||
@@ -102,17 +104,49 @@ func NewAlmanachEditResult(app core.App, id string, filters BeitraegeFilterParam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next := result.Entry.Next(app)
|
prevByID := result.Entry.Prev(app)
|
||||||
prev := result.Entry.Prev(app)
|
nextByID := result.Entry.Next(app)
|
||||||
|
prevByTitle, nextByTitle, err := entryNeighborsByPreferredTitle(app, result.Entry.Id)
|
||||||
|
if err != nil {
|
||||||
|
app.Logger().Error("Failed to load entry neighbors", "entry", result.Entry.Id, "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
return &AlmanachEditResult{
|
return &AlmanachEditResult{
|
||||||
User: user,
|
User: user,
|
||||||
AlmanachResult: *result,
|
AlmanachResult: *result,
|
||||||
Next: next,
|
NextByID: nextByID,
|
||||||
Prev: prev,
|
PrevByID: prevByID,
|
||||||
|
NextByTitle: nextByTitle,
|
||||||
|
PrevByTitle: prevByTitle,
|
||||||
}, nil
|
}, 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 {
|
func (p *AlmanachEditPage) POSTSave(engine *templating.Engine, app core.App) HandleFunc {
|
||||||
return func(e *core.RequestEvent) error {
|
return func(e *core.RequestEvent) error {
|
||||||
id := e.Request.PathValue("id")
|
id := e.Request.PathValue("id")
|
||||||
|
|||||||
@@ -69,8 +69,10 @@ func (p *AlmanachNewPage) GET(engine *templating.Engine, app core.App) HandleFun
|
|||||||
Types: []string{},
|
Types: []string{},
|
||||||
HasScans: false,
|
HasScans: false,
|
||||||
},
|
},
|
||||||
Prev: nil,
|
PrevByID: nil,
|
||||||
Next: nil,
|
NextByID: nil,
|
||||||
|
PrevByTitle: nil,
|
||||||
|
NextByTitle: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
data["result"] = result
|
data["result"] = result
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ type AlmanachResult struct {
|
|||||||
</div>
|
</div>
|
||||||
·
|
·
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
{{- if $model.result.Prev -}}
|
{{- if $model.result.PrevByID -}}
|
||||||
<div>
|
<div>
|
||||||
<a href="/almanach/{{ $model.result.Prev.MusenalmID }}/edit" class="text-gray-700 hover:text-slate-950 no-underline block ">
|
<a href="/almanach/{{ $model.result.PrevByID.MusenalmID }}/edit" class="text-gray-700 hover:text-slate-950 no-underline block ">
|
||||||
<i class="ri-arrow-left-s-line"></i>
|
<i class="ri-arrow-left-s-line"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -58,9 +58,9 @@ type AlmanachResult struct {
|
|||||||
<i class="ri-information-line"></i>
|
<i class="ri-information-line"></i>
|
||||||
</tool-tip>
|
</tool-tip>
|
||||||
</div>
|
</div>
|
||||||
{{- if $model.result.Next -}}
|
{{- if $model.result.NextByID -}}
|
||||||
<div>
|
<div>
|
||||||
<a href="/almanach/{{ $model.result.Next.MusenalmID }}/edit" class="text-gray-700 hover:text-slate-950 block no-underline"><i class="ri-arrow-right-s-line"></i></a>
|
<a href="/almanach/{{ $model.result.NextByID.MusenalmID }}/edit" class="text-gray-700 hover:text-slate-950 block no-underline"><i class="ri-arrow-right-s-line"></i></a>
|
||||||
</div>
|
</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
@@ -88,6 +88,38 @@ type AlmanachResult struct {
|
|||||||
<div class="">{{ $model.result.Entry.Id }}</div>
|
<div class="">{{ $model.result.Entry.Id }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col justify-end gap-y-6 pr-6">
|
||||||
|
<div class="">
|
||||||
|
<div class="font-bold text-sm">
|
||||||
|
<i class="ri-navigation-line"></i> Navigation
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
{{- if $model.result.PrevByTitle -}}
|
||||||
|
<tool-tip position="top" class="!inline">
|
||||||
|
<div class="data-tip">{{ $model.result.PrevByTitle.PreferredTitle }}</div>
|
||||||
|
<a
|
||||||
|
href="/almanach/{{ $model.result.PrevByTitle.MusenalmID }}/edit"
|
||||||
|
class="text-gray-700 hover:text-slate-950 no-underline">
|
||||||
|
<i class="ri-arrow-left-s-line"></i>
|
||||||
|
</a>
|
||||||
|
</tool-tip>
|
||||||
|
{{- end -}}
|
||||||
|
<span class="text-gray-800 font-bold no-underline">
|
||||||
|
A - Z
|
||||||
|
</span>
|
||||||
|
{{- if $model.result.NextByTitle -}}
|
||||||
|
<tool-tip position="top" class="!inline">
|
||||||
|
<div class="data-tip">{{ $model.result.NextByTitle.PreferredTitle }}</div>
|
||||||
|
<a
|
||||||
|
href="/almanach/{{ $model.result.NextByTitle.MusenalmID }}/edit"
|
||||||
|
class="text-gray-700 hover:text-slate-950 no-underline">
|
||||||
|
<i class="ri-arrow-right-s-line"></i>
|
||||||
|
</a>
|
||||||
|
</tool-tip>
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="flex flex-col justify-end gap-y-6 pr-4">
|
<div class="flex flex-col justify-end gap-y-6 pr-4">
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="font-bold text-sm mb-1"><i class="ri-calendar-line"></i> Zuletzt bearbeitet</div>
|
<div class="font-bold text-sm mb-1"><i class="ri-calendar-line"></i> Zuletzt bearbeitet</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user