UI verbessert
This commit is contained in:
1 parent
cc2e85c111
commit
a5d4251868
10 files changed
+136
-83
No files matched your search
+6
-17
@@ -440,7 +440,6 @@ func CandidateSuggestions(
|
||||
rangeAssignments []Assignment,
|
||||
services []ServiceOccurrence,
|
||||
serviceAssignments []Assignment,
|
||||
ignorePreferredWeekdays bool,
|
||||
liturgicalDay *LiturgicalDay,
|
||||
) []CandidateSuggestion {
|
||||
monthKey := MonthKey(service.Date)
|
||||
@@ -505,24 +504,14 @@ func CandidateSuggestions(
|
||||
}
|
||||
weekdayMatch := person.MatchesWeekdayPreference(weekday, service.TimeMinutes, highFeast)
|
||||
if !weekdayMatch {
|
||||
switch {
|
||||
case ignorePreferredWeekdays:
|
||||
beyond = true
|
||||
case person.AllowBeyondPreferences:
|
||||
beyond = true
|
||||
default:
|
||||
warnings = append(warnings, "Einsatztag oder Uhrzeit passt nicht")
|
||||
blocked = true
|
||||
}
|
||||
// Manual assignments may always override preferences, but the UI
|
||||
// asks for confirmation before doing so.
|
||||
warnings = append(warnings, "Einsatztag oder Uhrzeit passt nicht")
|
||||
beyond = true
|
||||
}
|
||||
if person.MaxPerMonth > 0 && monthlyCounts[person.ID+"|"+monthKey] >= person.MaxPerMonth {
|
||||
if person.AllowBeyondPreferences {
|
||||
warnings = append(warnings, "Monatslimit")
|
||||
beyond = true
|
||||
} else {
|
||||
warnings = append(warnings, "Monatslimit")
|
||||
blocked = true
|
||||
}
|
||||
warnings = append(warnings, "Monatslimit")
|
||||
beyond = true
|
||||
}
|
||||
used := dayServices[person.ID+"|"+service.DateKey()]
|
||||
if len(used) > 0 && !subsetOfSingle(used, service.ID) {
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestPlannerTreatsHighFeastAsSunday(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidateSuggestionsMarkBeyondPreferences(t *testing.T) {
|
||||
func TestCandidateSuggestionsAllowPreferenceOverrides(t *testing.T) {
|
||||
service := ServiceOccurrence{
|
||||
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
|
||||
@@ -140,14 +140,17 @@ func TestCandidateSuggestionsMarkBeyondPreferences(t *testing.T) {
|
||||
PreferredWeekdays: []int{1}, Active: true, MaxPerMonth: 6,
|
||||
}
|
||||
suggestions := CandidateSuggestions(service, RoleLector,
|
||||
[]Person{sundayOnly}, nil, nil, []ServiceOccurrence{service}, nil, false, nil)
|
||||
if len(suggestions) != 1 || !suggestions[0].Blocked || suggestions[0].BeyondPreferences {
|
||||
t.Fatalf("person without permission should be blocked, got %#v", suggestions)
|
||||
[]Person{sundayOnly}, nil, nil, []ServiceOccurrence{service}, nil, nil)
|
||||
if len(suggestions) != 1 || suggestions[0].Blocked || !suggestions[0].BeyondPreferences {
|
||||
t.Fatalf("manual suggestions should allow preference overrides with a warning, got %#v", suggestions)
|
||||
}
|
||||
if len(suggestions[0].Warnings) == 0 {
|
||||
t.Fatal("preference override should carry a warning")
|
||||
}
|
||||
|
||||
sundayOnly.AllowBeyondPreferences = true
|
||||
suggestions = CandidateSuggestions(service, RoleLector,
|
||||
[]Person{sundayOnly}, nil, nil, []ServiceOccurrence{service}, nil, false, nil)
|
||||
[]Person{sundayOnly}, nil, nil, []ServiceOccurrence{service}, nil, nil)
|
||||
if len(suggestions) != 1 || suggestions[0].Blocked || !suggestions[0].BeyondPreferences {
|
||||
t.Fatalf("flagged person should be suggested beyond preferences, got %#v", suggestions)
|
||||
}
|
||||
@@ -155,3 +158,23 @@ func TestCandidateSuggestionsMarkBeyondPreferences(t *testing.T) {
|
||||
t.Fatal("unexpected preference note")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidateSuggestionsBlockAbsences(t *testing.T) {
|
||||
service := ServiceOccurrence{
|
||||
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
|
||||
}
|
||||
person := Person{
|
||||
ID: "p1", FirstName: "Anna", LastName: "Berg", Roles: []Role{RoleLector},
|
||||
PreferredWeekdays: []int{1}, Active: true, MaxPerMonth: 6,
|
||||
}
|
||||
absences := []Absence{{
|
||||
ID: "a1", PersonID: person.ID,
|
||||
Start: MustDate("2026-11-16"), End: MustDate("2026-11-16"),
|
||||
}}
|
||||
suggestions := CandidateSuggestions(service, RoleLector,
|
||||
[]Person{person}, absences, nil, []ServiceOccurrence{service}, nil, nil)
|
||||
if len(suggestions) != 1 || !suggestions[0].Blocked {
|
||||
t.Fatalf("absence must remain a hard block, got %#v", suggestions)
|
||||
}
|
||||
}
|
||||
+6
-13
@@ -623,7 +623,7 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
contentTop := margin + headerH + colH + 2
|
||||
contentBottom := pageHeight - margin - footerH
|
||||
|
||||
drawHeader := func(continuation bool) {
|
||||
drawHeader := func() {
|
||||
setColor(pdf, colors.accent)
|
||||
pdf.SetFont("Helvetica", "B", 6.2)
|
||||
pdf.SetXY(margin, margin)
|
||||
@@ -631,12 +631,8 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
|
||||
setColor(pdf, colors.ink)
|
||||
pdf.SetFont("Times", "B", 17)
|
||||
title := "Gottesdienstliste"
|
||||
if continuation {
|
||||
title = "Gottesdienstliste · Fortsetzung"
|
||||
}
|
||||
pdf.SetXY(margin, margin+4.4)
|
||||
pdf.CellFormat(130, 6.5, tr(title), "", 0, "L", false, 0, "")
|
||||
pdf.CellFormat(130, 6.5, tr("Gottesdienstliste"), "", 0, "L", false, 0, "")
|
||||
|
||||
setColor(pdf, colors.secondary)
|
||||
pdf.SetFont("Helvetica", "", 7.8)
|
||||
@@ -645,13 +641,10 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
|
||||
rightX := pageWidth - margin - 62
|
||||
setColor(pdf, colors.tertiary)
|
||||
pdf.SetFont("Helvetica", "B", 6.4)
|
||||
pdf.SetXY(rightX, margin)
|
||||
pdf.CellFormat(62, 3.2, tr("A4 hoch · kompakte Liste"), "", 0, "R", false, 0, "")
|
||||
pdf.SetFont("Helvetica", "", 6.4)
|
||||
pdf.SetXY(rightX, margin+4.5)
|
||||
pdf.SetXY(rightX, margin)
|
||||
pdf.CellFormat(62, 3.2, tr("Erstellt am "+domain.MediumString(opts.generated())), "", 0, "R", false, 0, "")
|
||||
pdf.SetXY(rightX, margin+9)
|
||||
pdf.SetXY(rightX, margin+4.5)
|
||||
pdf.CellFormat(62, 3.2, tr("Daten von www.eucharistiefeier.de"), "", 0, "R", false, 0, "")
|
||||
|
||||
setDraw(pdf, colors.line)
|
||||
@@ -714,7 +707,7 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
}
|
||||
|
||||
pdf.AddPage()
|
||||
drawHeader(false)
|
||||
drawHeader()
|
||||
drawColumnHeader()
|
||||
page := 1
|
||||
y := contentTop
|
||||
@@ -744,7 +737,7 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
drawFooter(page)
|
||||
page++
|
||||
pdf.AddPage()
|
||||
drawHeader(true)
|
||||
drawHeader()
|
||||
drawColumnHeader()
|
||||
y = contentTop
|
||||
}
|
||||
|
||||
@@ -279,3 +279,32 @@ func TestCompactPlan(t *testing.T) {
|
||||
t.Fatalf("unexpected PDF output (%d bytes)", buf.Len())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompactPlanPaginatesWithoutContinuationTitle(t *testing.T) {
|
||||
r, rows, _, people := multiPageRows()
|
||||
var buf bytes.Buffer
|
||||
if err := CompactPlan(&buf, r, rows, people, Options{TenantName: "Bad Godesberg"}); err != nil {
|
||||
t.Fatalf("render: %v", err)
|
||||
}
|
||||
content := string(pdfContentStreams(t, buf.Bytes()))
|
||||
if strings.Contains(content, "Fortsetzung") {
|
||||
t.Fatal("continuation title must not appear on later pages")
|
||||
}
|
||||
if strings.Contains(content, "A4 hoch") {
|
||||
t.Fatal("paper hint must not appear in the compact header")
|
||||
}
|
||||
match := regexp.MustCompile(`Seite 1 von (\d+)`).FindStringSubmatch(content)
|
||||
if match == nil {
|
||||
t.Fatalf("first page footer is missing the total page count:\n%s", content)
|
||||
}
|
||||
total, err := strconv.Atoi(match[1])
|
||||
if err != nil || total < 2 {
|
||||
t.Fatalf("total pages = %q, want at least 2", match[1])
|
||||
}
|
||||
if !strings.Contains(content, fmt.Sprintf("Seite %d von %d", total, total)) {
|
||||
t.Fatalf("last page footer is missing: want Seite %d von %d", total, total)
|
||||
}
|
||||
if got := strings.Count(content, "Seite "); got != total {
|
||||
t.Fatalf("footer count = %d, want %d", got, total)
|
||||
}
|
||||
}
|
||||
@@ -229,11 +229,11 @@ func (s *Server) handleServiceDetail(w http.ResponseWriter, r *http.Request, use
|
||||
}
|
||||
if detail.LectorOpen > 0 {
|
||||
detail.LectorCandidates = domain.CandidateSuggestions(*service, domain.RoleLector, people, absences,
|
||||
rangeAssignments, rangeServices, assignments, false, s.liturgicalDay(r, service.Date))
|
||||
rangeAssignments, rangeServices, assignments, s.liturgicalDay(r, service.Date))
|
||||
}
|
||||
if detail.HelperOpen > 0 {
|
||||
detail.HelperCandidates = domain.CandidateSuggestions(*service, domain.RoleHelper, people, absences,
|
||||
rangeAssignments, rangeServices, assignments, false, s.liturgicalDay(r, service.Date))
|
||||
rangeAssignments, rangeServices, assignments, s.liturgicalDay(r, service.Date))
|
||||
}
|
||||
data.Data = detail
|
||||
s.renderPage(w, r, "service", data)
|
||||
@@ -288,6 +288,15 @@ func (s *Server) handleAssign(w http.ResponseWriter, r *http.Request, user *stor
|
||||
s.redirectBack(w, r, "/services/"+service.ID)
|
||||
return
|
||||
}
|
||||
if absences, err := s.store.AbsencesForPerson(r.Context(), tenant.ID, person.ID); err == nil {
|
||||
for _, absence := range absences {
|
||||
if absence.Overlaps(service.Date) {
|
||||
s.setFlash(w, person.FullName()+" ist an diesem Tag als abwesend eingetragen und kann nicht eingeteilt werden.", "error")
|
||||
s.redirectBack(w, r, "/services/"+service.ID)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
assignments, _ := s.store.AssignmentsForServices(r.Context(), tenant.ID, []string{service.ID})
|
||||
filled := 0
|
||||
for _, assignment := range assignments {
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<section class="beyond-prompt card">
|
||||
<div>
|
||||
<span class="eyebrow">Rückfrage zur Planung</span>
|
||||
<h3>{{.Data.BeyondOpen}} {{plural .Data.BeyondOpen "Dienst bleibt" "Dienste bleiben"}} offen</h3>
|
||||
<h3>{{plural .Data.BeyondOpen "Dienst bleibt" "Dienste bleiben"}} offen</h3>
|
||||
<p>Es gibt Personen, die ausdrücklich bereit sind, auch über ihre Präferenzen hinaus eingeplant zu werden. Sollen sie für die verbleibenden Dienste eingesetzt werden? Die Einsätze werden im Plan besonders gekennzeichnet.</p>
|
||||
</div>
|
||||
<form method="post" action="/plan/auto" class="inline-form">
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
{{if .Preferred}}<span class="badge badge-green">Präferenz</span>{{end}}
|
||||
{{range .Warnings}}<span class="badge badge-burgundy">{{.}}</span>{{end}}
|
||||
</div>
|
||||
<form method="post" action="/services/{{$service.ID}}/assign" class="candidate-form">
|
||||
<form method="post" action="/services/{{$service.ID}}/assign" class="candidate-form"{{if .BeyondPreferences}} data-confirm="Diese Person ist bereit, auch über ihre Präferenzen oder ihr Monatslimit hinaus eingeplant zu werden. Trotzdem einteilen?"{{end}}>
|
||||
<input type="hidden" name="csrf" value="{{$.CSRF}}">
|
||||
<input type="hidden" name="role" value="lector">
|
||||
<input type="hidden" name="person_id" value="{{.Person.ID}}">
|
||||
@@ -141,7 +141,7 @@
|
||||
{{if .Preferred}}<span class="badge badge-green">Präferenz</span>{{end}}
|
||||
{{range .Warnings}}<span class="badge badge-burgundy">{{.}}</span>{{end}}
|
||||
</div>
|
||||
<form method="post" action="/services/{{$service.ID}}/assign" class="candidate-form">
|
||||
<form method="post" action="/services/{{$service.ID}}/assign" class="candidate-form"{{if .BeyondPreferences}} data-confirm="Diese Person ist bereit, auch über ihre Präferenzen oder ihr Monatslimit hinaus eingeplant zu werden. Trotzdem einteilen?"{{end}}>
|
||||
<input type="hidden" name="csrf" value="{{$.CSRF}}">
|
||||
<input type="hidden" name="role" value="helper">
|
||||
<input type="hidden" name="person_id" value="{{.Person.ID}}">
|
||||
|
||||
Reference in new issue
Block a user