Enable initial target pane toggle

This commit is contained in:
DonVoo 2026-07-06 15:01:47 +02:00
parent 771e1a6fc0
commit d2f0383796
2 changed files with 35 additions and 4 deletions

View file

@ -88,6 +88,17 @@ func targetMessageHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, renderTargetPane(account, folder, targetAccount, index, raw, ""))
}
func targetSelectHandler(w http.ResponseWriter, r *http.Request) {
targetAccount := r.URL.Query().Get("target_account")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, renderInitialTargetSelectPane(targetAccount))
}
func sourceSelectHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, renderInitialSourceSelectPane(`<div class="ef-empty">Nachricht waehlen.</div>`))
}
func forwardHandler(w http.ResponseWriter, r *http.Request) {
// TODO Codex: GET = Weiterleiten-Formular (An/Betreff/Text), POST =
// ForwardMessage() aufrufen. NUR hier kommt SMTP zum Einsatz -- der Umzug
@ -259,15 +270,19 @@ func renderTargetMatch(b *strings.Builder, match forwardedMatch) {
}
func renderInitialTargetPane() string {
return `<div class="pane-head mode-head"><div class="mode-switch"><button class="btn compact active" type="button">Quelle</button><button class="btn secondary compact" type="button">Ziel</button></div><div></div></div><div class="read-body"><div class="ef-empty">Nachricht waehlen.</div></div>`
return renderInitialSourceSelectPane(`<div class="ef-empty">Nachricht waehlen.</div>`)
}
func renderInitialReadPane(body string) string {
if strings.TrimSpace(body) == "" {
body = `<div class="ef-empty">Nachricht waehlen.</div>`
}
return renderInitialSourceSelectPane(body)
}
func renderInitialSourceSelectPane(body string) string {
var b strings.Builder
b.WriteString(`<div class="pane-head mode-head"><div class="mode-switch"><button class="btn compact active" type="button">Quelle</button><button class="btn secondary compact" type="button">Ziel</button></div><form class="target-select-form"><select id="source-account-select" name="source" class="target-select">`)
b.WriteString(`<div class="pane-head mode-head"><div class="mode-switch"><button class="btn compact active" type="button">Quelle</button><button class="btn secondary compact" type="button" hx-get="/view/target/select" hx-target="#read" hx-swap="innerHTML">Ziel</button></div><form class="target-select-form"><select id="source-account-select" name="source" class="target-select">`)
for _, opt := range sourceAccountOptions() {
fmt.Fprintf(&b, `<option value="%s">%s</option>`, html.EscapeString(opt.Value), html.EscapeString(opt.Label))
}
@ -277,6 +292,20 @@ func renderInitialReadPane(body string) string {
return b.String()
}
func renderInitialTargetSelectPane(selected string) string {
var b strings.Builder
b.WriteString(`<div class="pane-head mode-head"><div class="mode-switch"><button class="btn secondary compact" type="button" hx-get="/view/source/select" hx-target="#read" hx-swap="innerHTML">Quelle</button><button class="btn compact active" type="button">Ziel</button></div><form class="target-select-form"><select id="target-account-select" name="target_account" class="target-select"><option value="">Automatisch</option>`)
for _, opt := range targetAccountOptions() {
attr := ""
if opt.Value == selected {
attr = ` selected`
}
fmt.Fprintf(&b, `<option value="%s"%s>%s</option>`, html.EscapeString(opt.Value), attr, html.EscapeString(opt.Label))
}
b.WriteString(`</select></form></div><div class="read-body"><div class="ef-empty">Nachricht waehlen.</div></div>`)
return b.String()
}
func renderReadContent(w io.Writer, subject, from, date, body string) {
if subject == "" {
subject = "(ohne Betreff)"