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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user