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 {
|
||||
Next *dbmodels.Entry
|
||||
Prev *dbmodels.Entry
|
||||
NextByID *dbmodels.Entry
|
||||
PrevByID *dbmodels.Entry
|
||||
NextByTitle *dbmodels.Entry
|
||||
PrevByTitle *dbmodels.Entry
|
||||
User *dbmodels.User
|
||||
AlmanachResult
|
||||
}
|
||||
@@ -102,17 +104,49 @@ func NewAlmanachEditResult(app core.App, id string, filters BeitraegeFilterParam
|
||||
}
|
||||
}
|
||||
|
||||
next := result.Entry.Next(app)
|
||||
prev := result.Entry.Prev(app)
|
||||
prevByID := 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{
|
||||
User: user,
|
||||
AlmanachResult: *result,
|
||||
Next: next,
|
||||
Prev: prev,
|
||||
NextByID: nextByID,
|
||||
PrevByID: prevByID,
|
||||
NextByTitle: nextByTitle,
|
||||
PrevByTitle: prevByTitle,
|
||||
}, 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")
|
||||
|
||||
@@ -69,8 +69,10 @@ func (p *AlmanachNewPage) GET(engine *templating.Engine, app core.App) HandleFun
|
||||
Types: []string{},
|
||||
HasScans: false,
|
||||
},
|
||||
Prev: nil,
|
||||
Next: nil,
|
||||
PrevByID: nil,
|
||||
NextByID: nil,
|
||||
PrevByTitle: nil,
|
||||
NextByTitle: nil,
|
||||
}
|
||||
|
||||
data["result"] = result
|
||||
|
||||
@@ -44,9 +44,9 @@ type AlmanachResult struct {
|
||||
</div>
|
||||
·
|
||||
<div class="flex flex-row">
|
||||
{{- if $model.result.Prev -}}
|
||||
{{- if $model.result.PrevByID -}}
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
@@ -58,9 +58,9 @@ type AlmanachResult struct {
|
||||
<i class="ri-information-line"></i>
|
||||
</tool-tip>
|
||||
</div>
|
||||
{{- if $model.result.Next -}}
|
||||
{{- if $model.result.NextByID -}}
|
||||
<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>
|
||||
{{- end -}}
|
||||
</div>
|
||||
@@ -88,6 +88,38 @@ type AlmanachResult struct {
|
||||
<div class="">{{ $model.result.Entry.Id }}</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="">
|
||||
<div class="font-bold text-sm mb-1"><i class="ri-calendar-line"></i> Zuletzt bearbeitet</div>
|
||||
|
||||
Reference in New Issue
Block a user