UI verbessert
This commit is contained in:
1 parent
cc2e85c111
commit
a5d4251868
10 files changed
+136
-83
No files matched your search
@@ -87,13 +87,13 @@ enum CompactPlanPDFRenderer {
|
||||
pageIndex += 1
|
||||
}
|
||||
|
||||
func startPage(continuation: Bool) {
|
||||
func startPage() {
|
||||
beginPage()
|
||||
drawHeader(range: range, generatedAt: generatedAt, continuation: continuation)
|
||||
drawHeader(range: range, generatedAt: generatedAt)
|
||||
drawColumnHeader()
|
||||
}
|
||||
|
||||
startPage(continuation: false)
|
||||
startPage()
|
||||
var cursorY = contentTop
|
||||
|
||||
for day in days {
|
||||
@@ -108,7 +108,7 @@ enum CompactPlanPDFRenderer {
|
||||
let height = rowHeight(service: service, people: people)
|
||||
if cursorY + height > contentBottom {
|
||||
endPage()
|
||||
startPage(continuation: true)
|
||||
startPage()
|
||||
cursorY = contentTop
|
||||
}
|
||||
drawServiceRow(
|
||||
@@ -149,7 +149,7 @@ enum CompactPlanPDFRenderer {
|
||||
|
||||
// MARK: - Page furniture
|
||||
|
||||
private static func drawHeader(range: DayRange, generatedAt: Date, continuation: Bool) {
|
||||
private static func drawHeader(range: DayRange, generatedAt: Date) {
|
||||
let top = margin
|
||||
|
||||
drawText(
|
||||
@@ -159,7 +159,7 @@ enum CompactPlanPDFRenderer {
|
||||
color: accent
|
||||
)
|
||||
drawText(
|
||||
continuation ? "Gottesdienstliste · Fortsetzung" : "Gottesdienstliste",
|
||||
"Gottesdienstliste",
|
||||
in: CGRect(x: margin, y: top + 12, width: 340, height: 23),
|
||||
font: serif(19, bold: true),
|
||||
color: ink
|
||||
@@ -172,23 +172,16 @@ enum CompactPlanPDFRenderer {
|
||||
)
|
||||
|
||||
let rightX = pageWidth - margin - 170
|
||||
drawText(
|
||||
"A4 hoch · kompakte Liste",
|
||||
in: CGRect(x: rightX, y: top, width: 170, height: 11),
|
||||
font: sans(7.5, weight: .semibold),
|
||||
color: tertiaryInk,
|
||||
alignment: .right
|
||||
)
|
||||
drawText(
|
||||
"Erstellt am \(DayMath.mediumString(generatedAt))",
|
||||
in: CGRect(x: rightX, y: top + 14, width: 170, height: 11),
|
||||
in: CGRect(x: rightX, y: top, width: 170, height: 11),
|
||||
font: sans(7.5),
|
||||
color: tertiaryInk,
|
||||
alignment: .right
|
||||
)
|
||||
drawText(
|
||||
"Daten von www.eucharistiefeier.de",
|
||||
in: CGRect(x: rightX, y: top + 27, width: 170, height: 11),
|
||||
in: CGRect(x: rightX, y: top + 13, width: 170, height: 11),
|
||||
font: sans(7),
|
||||
color: tertiaryInk,
|
||||
alignment: .right
|
||||
|
||||
@@ -450,7 +450,11 @@ final class PlanModel: ObservableObject {
|
||||
existingAssignments: existing.filter { $0.serviceID == serviceID },
|
||||
churches: churches,
|
||||
liturgicalDays: Array(liturgicalDays.values),
|
||||
options: PlannerOptions(replaceExisting: false, respectPreferredWeekdays: false)
|
||||
options: PlannerOptions(
|
||||
replaceExisting: false,
|
||||
respectPreferredWeekdays: true,
|
||||
allowBeyondPreferences: true
|
||||
)
|
||||
)
|
||||
let result = planner.plan()
|
||||
_ = servicesOfDay
|
||||
@@ -471,6 +475,11 @@ final class PlanModel: ObservableObject {
|
||||
do {
|
||||
var beyond = false
|
||||
if let personID, let person = peopleByID[personID], let service = try db.service(id: serviceID) {
|
||||
if absences.contains(where: { $0.personID == personID && $0.overlaps(service.date) }) {
|
||||
alertTitle = "Zuweisung nicht möglich"
|
||||
alertMessage = "\(person.fullName) ist an diesem Tag als abwesend eingetragen."
|
||||
return
|
||||
}
|
||||
let highFeast = liturgicalDays[service.dateKey]?.isHighFeast ?? false
|
||||
let fits = person.matchesWeekdayPreference(
|
||||
weekday: DayMath.weekday(service.date),
|
||||
@@ -514,8 +523,7 @@ final class PlanModel: ObservableObject {
|
||||
|
||||
func candidateSuggestions(
|
||||
for service: ServiceOccurrence,
|
||||
role: Role,
|
||||
ignorePreferredWeekdays: Bool = false
|
||||
role: Role
|
||||
) -> [CandidateSuggestion] {
|
||||
let rangeAssignments = assignments
|
||||
let monthKey = DayMath.monthKey(service.date)
|
||||
@@ -568,22 +576,14 @@ final class PlanModel: ObservableObject {
|
||||
highFeast: highFeast
|
||||
)
|
||||
if !weekdayMatch {
|
||||
if ignorePreferredWeekdays {
|
||||
beyond = true
|
||||
} else if person.allowBeyondPreferences {
|
||||
beyond = true
|
||||
} else {
|
||||
warnings.append("Einsatztag oder Uhrzeit passt nicht")
|
||||
blocked = true
|
||||
}
|
||||
// Manual assignments may always override preferences, but
|
||||
// the UI asks for confirmation before doing so.
|
||||
warnings.append("Einsatztag oder Uhrzeit passt nicht")
|
||||
beyond = true
|
||||
}
|
||||
if person.maxPerMonth > 0, monthlyCounts["\(person.id)|\(monthKey)", default: 0] >= person.maxPerMonth {
|
||||
warnings.append("Monatslimit")
|
||||
if person.allowBeyondPreferences {
|
||||
beyond = true
|
||||
} else {
|
||||
blocked = true
|
||||
}
|
||||
beyond = true
|
||||
}
|
||||
let servicesThisDay = dayServices["\(person.id)|\(service.dateKey)", default: []]
|
||||
if !servicesThisDay.isEmpty, !servicesThisDay.isSubset(of: [service.id]) {
|
||||
|
||||
@@ -8,7 +8,7 @@ struct ServiceDetailSheet: View {
|
||||
let serviceID: String
|
||||
|
||||
@State private var selectedRole: Role = .lector
|
||||
@State private var ignorePreferredWeekdays = false
|
||||
@State private var pendingBeyondCandidate: CandidateSuggestion?
|
||||
@State private var confirmDelete = false
|
||||
|
||||
private var item: ServiceWithAssignments? {
|
||||
@@ -79,6 +79,28 @@ struct ServiceDetailSheet: View {
|
||||
selectedRole = .helper
|
||||
}
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Über Präferenzen einteilen?",
|
||||
isPresented: Binding(
|
||||
get: { pendingBeyondCandidate != nil },
|
||||
set: { if !$0 { pendingBeyondCandidate = nil } }
|
||||
),
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Trotzdem einteilen") {
|
||||
if let candidate = pendingBeyondCandidate {
|
||||
model.assign(serviceID: serviceID, role: selectedRole, personID: candidate.person.id)
|
||||
}
|
||||
pendingBeyondCandidate = nil
|
||||
}
|
||||
Button("Abbrechen", role: .cancel) {
|
||||
pendingBeyondCandidate = nil
|
||||
}
|
||||
} message: {
|
||||
if let candidate = pendingBeyondCandidate {
|
||||
Text("\(candidate.person.fullName) ist bereit, auch über ihre Präferenzen oder ihr Monatslimit hinaus eingeplant zu werden.")
|
||||
}
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Gottesdienst löschen?",
|
||||
isPresented: $confirmDelete,
|
||||
@@ -150,14 +172,6 @@ struct ServiceDetailSheet: View {
|
||||
.font(.system(size: 9, weight: .medium))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
}
|
||||
Toggle(isOn: $ignorePreferredWeekdays) {
|
||||
Text("Präferenztage ignorieren")
|
||||
.font(.system(size: 9, weight: .medium))
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
}
|
||||
.toggleStyle(.switch)
|
||||
.controlSize(.mini)
|
||||
.help("Auch Personen anbieten, deren bevorzugte Einsatztage diesen Termin ausschließen. Ausschlusstermine bleiben gesperrt.")
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 22)
|
||||
@@ -366,8 +380,7 @@ struct ServiceDetailSheet: View {
|
||||
|
||||
let suggestions = model.candidateSuggestions(
|
||||
for: item.service,
|
||||
role: selectedRole,
|
||||
ignorePreferredWeekdays: ignorePreferredWeekdays
|
||||
role: selectedRole
|
||||
)
|
||||
if suggestions.isEmpty {
|
||||
EmptyStateView(
|
||||
@@ -442,7 +455,11 @@ struct ServiceDetailSheet: View {
|
||||
Spacer(minLength: 4)
|
||||
|
||||
Button {
|
||||
model.assign(serviceID: item.service.id, role: selectedRole, personID: candidate.person.id)
|
||||
if candidate.beyondPreferences {
|
||||
pendingBeyondCandidate = candidate
|
||||
} else {
|
||||
model.assign(serviceID: item.service.id, role: selectedRole, personID: candidate.person.id)
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 3) {
|
||||
Image(systemName: "plus")
|
||||
|
||||
Reference in new issue
Block a user