UI verbessert, 2. PDF als kompakte Variante

This commit is contained in:
concierge committed 2026-11-12 19:59:51 +01:00
1 parent 1bf3283029
commit f9e3e94629
23 files changed
+1009 -146

No files matched your search

+28
View File
@@ -35,6 +35,15 @@ public enum Role: String, Codable, CaseIterable, Identifiable, Sendable, Hashabl
case .helper: "hand.raised.fill"
}
}
/// The other role a service may need. Lector and communion helper do not
/// exclude each other, so one person can fill both at the same service.
public var complementary: Role {
switch self {
case .lector: .helper
case .helper: .lector
}
}
}
// MARK: - Church
@@ -155,6 +164,12 @@ public struct Person: Identifiable, Codable, Hashable, Sendable {
return "\(firstName) \(initial)."
}
/// Compact display for the calendar: surname in full, first name abbreviated.
public var abbreviatedName: String {
guard let initial = firstName.first else { return lastName }
return "\(initial). \(lastName)"
}
public var roleLabel: String {
let ordered = Role.allCases.filter { roles.contains($0) }
return ordered.map(\.title).joined(separator: " · ")
@@ -292,6 +307,9 @@ public enum ServiceKind: String, Codable, CaseIterable, Sendable {
public struct ServiceOccurrence: Identifiable, Codable, Hashable, Sendable {
public var id: String
public var churchID: String
/// Free-text location for special services (e.g. open-air worship).
/// `nil` means the service takes place in the assigned church.
public var location: String?
public var templateID: String?
public var date: Date
public var timeMinutes: Int
@@ -306,6 +324,7 @@ public struct ServiceOccurrence: Identifiable, Codable, Hashable, Sendable {
public init(
id: String = UUID().uuidString,
churchID: String,
location: String? = nil,
templateID: String? = nil,
date: Date,
timeMinutes: Int,
@@ -319,6 +338,8 @@ public struct ServiceOccurrence: Identifiable, Codable, Hashable, Sendable {
) {
self.id = id
self.churchID = churchID
let trimmedLocation = location?.trimmingCharacters(in: .whitespacesAndNewlines)
self.location = (trimmedLocation?.isEmpty ?? true) ? nil : trimmedLocation
self.templateID = templateID
self.date = DayMath.normalize(date)
self.timeMinutes = timeMinutes
@@ -331,6 +352,10 @@ public struct ServiceOccurrence: Identifiable, Codable, Hashable, Sendable {
self.createdAt = createdAt
}
public func placeName(church: Church) -> String {
location ?? church.name
}
public var timeLabel: String { DayMath.timeString(minutes: timeMinutes) }
public var dateKey: String { DayMath.key(date) }
public var requiredSlots: Int { lectorsNeeded + helpersNeeded }
@@ -877,6 +902,7 @@ public struct PlannerOptions: Codable, Hashable, Sendable {
public var weightChurchPreference: Double
public var weightServicePreference: Double
public var weightFairness: Double
public var weightDualRolePreference: Double
public var maxAssignmentsPerDay: Int
public init(
@@ -886,6 +912,7 @@ public struct PlannerOptions: Codable, Hashable, Sendable {
weightChurchPreference: Double = 8,
weightServicePreference: Double = 4,
weightFairness: Double = 2.2,
weightDualRolePreference: Double = 14,
maxAssignmentsPerDay: Int = 1
) {
self.replaceExisting = replaceExisting
@@ -894,6 +921,7 @@ public struct PlannerOptions: Codable, Hashable, Sendable {
self.weightChurchPreference = weightChurchPreference
self.weightServicePreference = weightServicePreference
self.weightFairness = weightFairness
self.weightDualRolePreference = weightDualRolePreference
self.maxAssignmentsPerDay = maxAssignmentsPerDay
}
}