Gastansicht, Verbesserungen bei Planung
This commit is contained in:
1 parent
b3afa3ef32
commit
c08d43e7dd
38 files changed
+3845
-219
No files matched your search
@@ -68,6 +68,7 @@ enum PlanFilter: String, CaseIterable, Identifiable {
|
||||
case all
|
||||
case services
|
||||
case open
|
||||
case beyond
|
||||
|
||||
var id: String { rawValue }
|
||||
|
||||
@@ -76,6 +77,7 @@ enum PlanFilter: String, CaseIterable, Identifiable {
|
||||
case .all: "Alle Tage"
|
||||
case .services: "Mit Gottesdiensten"
|
||||
case .open: "Nur offene"
|
||||
case .beyond: "Über Präferenzen"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +146,7 @@ struct CandidateSuggestion: Identifiable {
|
||||
var warnings: [String]
|
||||
var blocked: Bool
|
||||
var preferred: Bool
|
||||
var beyondPreferences: Bool
|
||||
var totalAssignments: Int
|
||||
|
||||
var id: String { person.id }
|
||||
@@ -347,6 +350,8 @@ final class PlanModel: ObservableObject {
|
||||
if !row.hasServices { return false }
|
||||
case .open:
|
||||
if row.openSlots == 0 { return false }
|
||||
case .beyond:
|
||||
if !row.hasBeyondPreferences { return false }
|
||||
}
|
||||
guard !query.isEmpty else { return true }
|
||||
if row.liturgicalDay?.title.lowercased().contains(query) == true { return true }
|
||||
@@ -382,7 +387,7 @@ final class PlanModel: ObservableObject {
|
||||
|
||||
// MARK: - Planning
|
||||
|
||||
func autoPlan(replaceExisting: Bool) -> PlanResult? {
|
||||
func autoPlan(replaceExisting: Bool, allowBeyond: Bool = false) -> PlanResult? {
|
||||
guard !isPlanning else { return nil }
|
||||
isPlanning = true
|
||||
defer { isPlanning = false }
|
||||
@@ -390,8 +395,11 @@ final class PlanModel: ObservableObject {
|
||||
let rangeServices = try db.services(in: range)
|
||||
let existing = try db.assignments(in: range)
|
||||
let options = PlannerOptions(
|
||||
replaceExisting: replaceExisting,
|
||||
// A follow-up pass keeps the result of the first pass and only
|
||||
// adds assignments for volunteers who allowed them.
|
||||
replaceExisting: allowBeyond ? false : replaceExisting,
|
||||
respectPreferredWeekdays: db.setting("respectPreferredWeekdays") != "0",
|
||||
allowBeyondPreferences: allowBeyond,
|
||||
weightFairness: Double(db.setting("fairnessWeight") ?? "") ?? 2.2,
|
||||
maxAssignmentsPerDay: 1
|
||||
)
|
||||
@@ -401,11 +409,12 @@ final class PlanModel: ObservableObject {
|
||||
services: rangeServices,
|
||||
existingAssignments: existing,
|
||||
churches: churches,
|
||||
liturgicalDays: Array(liturgicalDays.values),
|
||||
options: options
|
||||
)
|
||||
let result = planner.plan()
|
||||
if result.filledCount > 0 || replaceExisting {
|
||||
try db.savePlan(result.assignments, in: range, replaceUnlocked: replaceExisting)
|
||||
try db.savePlan(result.assignments, in: range, replaceUnlocked: allowBeyond ? false : replaceExisting)
|
||||
}
|
||||
loadAll()
|
||||
planResult = result
|
||||
@@ -429,6 +438,7 @@ final class PlanModel: ObservableObject {
|
||||
services: [service],
|
||||
existingAssignments: existing.filter { $0.serviceID == serviceID },
|
||||
churches: churches,
|
||||
liturgicalDays: Array(liturgicalDays.values),
|
||||
options: PlannerOptions(replaceExisting: false, respectPreferredWeekdays: false)
|
||||
)
|
||||
let result = planner.plan()
|
||||
@@ -448,7 +458,27 @@ final class PlanModel: ObservableObject {
|
||||
|
||||
func assign(serviceID: String, role: Role, personID: String?) {
|
||||
do {
|
||||
try db.setAssignment(serviceID: serviceID, role: role, personID: personID)
|
||||
var beyond = false
|
||||
if let personID, let person = peopleByID[personID], let service = try db.service(id: serviceID) {
|
||||
let highFeast = liturgicalDays[service.dateKey]?.isHighFeast ?? false
|
||||
let fits = person.matchesWeekdayPreference(
|
||||
weekday: DayMath.weekday(service.date),
|
||||
timeMinutes: service.timeMinutes,
|
||||
highFeast: highFeast
|
||||
)
|
||||
beyond = !fits
|
||||
if !beyond, person.maxPerMonth > 0 {
|
||||
let monthAssignments = try db.assignments(in: DayRange.month(containing: service.date))
|
||||
let used = monthAssignments.filter {
|
||||
$0.personID == personID && $0.serviceID != serviceID
|
||||
}.count
|
||||
beyond = used >= person.maxPerMonth
|
||||
}
|
||||
}
|
||||
try db.setAssignment(
|
||||
serviceID: serviceID, role: role, personID: personID,
|
||||
beyondPreferences: beyond
|
||||
)
|
||||
loadAll()
|
||||
if let personID, let person = peopleByID[personID] {
|
||||
showToast("\(person.fullName) als \(role.title) eingetragen.", kind: .success)
|
||||
@@ -501,6 +531,7 @@ final class PlanModel: ObservableObject {
|
||||
assignedRolesByPerson[assignment.personID, default: []].insert(assignment.role)
|
||||
}
|
||||
let weekday = DayMath.weekday(service.date)
|
||||
let highFeast = liturgicalDays[service.dateKey]?.isHighFeast ?? false
|
||||
|
||||
let eligiblePeople = people.filter { person in
|
||||
guard person.active, person.canFill(role) else { return false }
|
||||
@@ -515,19 +546,33 @@ final class PlanModel: ObservableObject {
|
||||
.map { person in
|
||||
var warnings: [String] = []
|
||||
var blocked = false
|
||||
var beyond = false
|
||||
if absences.contains(where: { $0.personID == person.id && $0.overlaps(service.date) }) {
|
||||
warnings.append("abwesend")
|
||||
blocked = true
|
||||
}
|
||||
if !ignorePreferredWeekdays,
|
||||
!person.preferredWeekdays.isEmpty,
|
||||
!person.preferredWeekdays.contains(weekday) {
|
||||
warnings.append("Einsatztag passt nicht")
|
||||
blocked = true
|
||||
let weekdayMatch = person.matchesWeekdayPreference(
|
||||
weekday: weekday,
|
||||
timeMinutes: service.timeMinutes,
|
||||
highFeast: highFeast
|
||||
)
|
||||
if !weekdayMatch {
|
||||
if ignorePreferredWeekdays {
|
||||
beyond = true
|
||||
} else if person.allowBeyondPreferences {
|
||||
beyond = true
|
||||
} else {
|
||||
warnings.append("Einsatztag oder Uhrzeit passt nicht")
|
||||
blocked = true
|
||||
}
|
||||
}
|
||||
if person.maxPerMonth > 0, monthlyCounts["\(person.id)|\(monthKey)", default: 0] >= person.maxPerMonth {
|
||||
warnings.append("Monatslimit")
|
||||
blocked = true
|
||||
if person.allowBeyondPreferences {
|
||||
beyond = true
|
||||
} else {
|
||||
blocked = true
|
||||
}
|
||||
}
|
||||
let servicesThisDay = dayServices["\(person.id)|\(service.dateKey)", default: []]
|
||||
if !servicesThisDay.isEmpty, !servicesThisDay.isSubset(of: [service.id]) {
|
||||
@@ -554,7 +599,7 @@ final class PlanModel: ObservableObject {
|
||||
if !person.preferredChurchIDs.isEmpty && !person.preferredChurchIDs.contains(service.churchID) {
|
||||
score -= 2
|
||||
}
|
||||
if person.preferredWeekdays.contains(weekday) {
|
||||
if weekdayMatch, !person.preferredWeekdays.isEmpty {
|
||||
score += 3
|
||||
preferred = true
|
||||
}
|
||||
@@ -574,6 +619,7 @@ final class PlanModel: ObservableObject {
|
||||
warnings: warnings,
|
||||
blocked: blocked,
|
||||
preferred: preferred,
|
||||
beyondPreferences: beyond,
|
||||
totalAssignments: totalCounts[person.id, default: 0]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -270,24 +270,42 @@ struct PersonMiniChip: View {
|
||||
var person: Person
|
||||
var role: Role
|
||||
var color: Color
|
||||
var beyond: Bool = false
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 4) {
|
||||
Avatar(initials: person.initials, color: color, size: 18)
|
||||
if beyond {
|
||||
Image(systemName: "arrow.up.right")
|
||||
.font(.system(size: 7, weight: .black))
|
||||
.foregroundStyle(LP.burgundy)
|
||||
}
|
||||
Text(person.abbreviatedName)
|
||||
.font(.system(size: 10.5, weight: .medium))
|
||||
.foregroundStyle(LP.ink)
|
||||
.foregroundStyle(beyond ? LP.burgundy : LP.ink)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.padding(.horizontal, 4)
|
||||
.padding(.vertical, 2)
|
||||
.background(
|
||||
Capsule().fill(LP.cardMuted)
|
||||
Capsule().fill(beyond ? LP.burgundySoft.opacity(0.7) : LP.cardMuted)
|
||||
)
|
||||
.overlay(
|
||||
Capsule().strokeBorder(LP.line.opacity(0.5), lineWidth: 0.6)
|
||||
Capsule().strokeBorder(
|
||||
beyond ? LP.burgundy.opacity(0.5) : LP.line.opacity(0.5),
|
||||
style: StrokeStyle(lineWidth: 0.6, dash: beyond ? [2, 1.5] : [])
|
||||
)
|
||||
)
|
||||
.help("\(person.fullName) · \(role.title)\n\(person.preferredChurchIDs.isEmpty ? "Alle Orte" : "Bevorzugte Orte") · max. \(person.maxPerMonth) Einsätze/Monat")
|
||||
.help(chipHelp)
|
||||
}
|
||||
|
||||
private var chipHelp: String {
|
||||
var lines = ["\(person.fullName) · \(role.title)"]
|
||||
lines.append(person.preferredChurchIDs.isEmpty ? "Alle Orte" : "Bevorzugte Orte")
|
||||
lines.append("max. \(person.maxPerMonth) Einsätze/Monat")
|
||||
if beyond { lines.append("Über die Präferenzen hinaus eingeplant") }
|
||||
if !person.preferenceNote.isEmpty { lines.append(person.preferenceNote) }
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,16 @@ struct PersonEditorSheet: View {
|
||||
|
||||
@State private var firstName = ""
|
||||
@State private var lastName = ""
|
||||
@State private var shortCode = ""
|
||||
@State private var email = ""
|
||||
@State private var phone = ""
|
||||
@State private var roles: Set<Role> = [.lector]
|
||||
@State private var preferredChurchIDs: Set<String> = []
|
||||
@State private var preferredWeekdays: Set<Int> = []
|
||||
@State private var weekdayPeriods: [Int: WeekdayPeriod] = [:]
|
||||
@State private var preferredServiceTitles: Set<String> = []
|
||||
@State private var maxPerMonth = 6
|
||||
@State private var allowBeyondPreferences = false
|
||||
@State private var active = true
|
||||
@State private var notes = ""
|
||||
|
||||
@@ -33,6 +36,13 @@ struct PersonEditorSheet: View {
|
||||
["", "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"][max(0, min(7, weekday))]
|
||||
}
|
||||
|
||||
private func periodBinding(_ weekday: Int) -> Binding<WeekdayPeriod> {
|
||||
Binding(
|
||||
get: { weekdayPeriods[weekday] ?? .all },
|
||||
set: { weekdayPeriods[weekday] = $0 }
|
||||
)
|
||||
}
|
||||
|
||||
private var isValid: Bool {
|
||||
!firstName.trimmingCharacters(in: .whitespaces).isEmpty
|
||||
&& !lastName.trimmingCharacters(in: .whitespaces).isEmpty
|
||||
@@ -118,7 +128,15 @@ struct PersonEditorSheet: View {
|
||||
TextField("z. B. Berg", text: $lastName)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}
|
||||
LabeledField(label: "Kürzel") {
|
||||
TextField("optional", text: $shortCode)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.frame(width: 90)
|
||||
}
|
||||
}
|
||||
Text("Das Kürzel erscheint in der Gastansicht. Ohne Kürzel werden die Initialen angezeigt.")
|
||||
.font(.system(size: 9.5))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
HStack(spacing: 12) {
|
||||
LabeledField(label: "E-Mail") {
|
||||
TextField("optional", text: $email)
|
||||
@@ -195,21 +213,39 @@ struct PersonEditorSheet: View {
|
||||
Text("Bevorzugte Einsatztage")
|
||||
.font(.system(size: 9.5, weight: .semibold))
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
HStack(spacing: 5) {
|
||||
HStack(alignment: .top, spacing: 5) {
|
||||
ForEach(weekdayOrder, id: \.self) { weekday in
|
||||
ChipToggle(
|
||||
title: weekdayLabel(weekday),
|
||||
isOn: preferredWeekdays.contains(weekday),
|
||||
tint: weekday == 1 ? LP.burgundy : LP.accent
|
||||
) {
|
||||
VStack(spacing: 3) {
|
||||
ChipToggle(
|
||||
title: weekdayLabel(weekday),
|
||||
isOn: preferredWeekdays.contains(weekday),
|
||||
tint: weekday == 1 ? LP.burgundy : LP.accent
|
||||
) {
|
||||
if preferredWeekdays.contains(weekday) {
|
||||
preferredWeekdays.remove(weekday)
|
||||
weekdayPeriods[weekday] = nil
|
||||
} else {
|
||||
preferredWeekdays.insert(weekday)
|
||||
weekdayPeriods[weekday] = .all
|
||||
}
|
||||
}
|
||||
if preferredWeekdays.contains(weekday) {
|
||||
preferredWeekdays.remove(weekday)
|
||||
} else {
|
||||
preferredWeekdays.insert(weekday)
|
||||
Picker("Tageszeit", selection: periodBinding(weekday)) {
|
||||
ForEach(WeekdayPeriod.allCases) { period in
|
||||
Text(period.shortLabel).tag(period)
|
||||
}
|
||||
}
|
||||
.labelsHidden()
|
||||
.pickerStyle(.menu)
|
||||
.controlSize(.mini)
|
||||
.frame(width: 88)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("Hochfeste gelten zusätzlich als Sonntag. Die Tageszeit grenzt den Einsatztag ein (vormittags 0–12, nachmittags 12–17, abends ab 17 Uhr).")
|
||||
.font(.system(size: 9.5))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
@@ -262,6 +298,21 @@ struct PersonEditorSheet: View {
|
||||
.background(RoundedRectangle(cornerRadius: 7).fill(LP.card))
|
||||
.overlay(RoundedRectangle(cornerRadius: 7).strokeBorder(LP.line.opacity(0.8), lineWidth: 1))
|
||||
}
|
||||
Text("Diese Notiz erscheint in der Dienstplanung bei Einsätzen und Vorschlägen.")
|
||||
.font(.system(size: 9.5))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
Toggle(isOn: $allowBeyondPreferences) {
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
Text("Auch über Präferenzen hinaus planbar")
|
||||
.font(.system(size: 10.5, weight: .medium))
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
Text("Die Person kann nach Rückfrage für Dienste außerhalb ihrer Tage, Zeiten und ihres Monatslimits eingeplant werden.")
|
||||
.font(.system(size: 9.5))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
}
|
||||
}
|
||||
.toggleStyle(.switch)
|
||||
.controlSize(.small)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,13 +401,16 @@ struct PersonEditorSheet: View {
|
||||
}
|
||||
firstName = person.firstName
|
||||
lastName = person.lastName
|
||||
shortCode = person.shortCode
|
||||
email = person.email
|
||||
phone = person.phone
|
||||
roles = person.roles
|
||||
preferredChurchIDs = person.preferredChurchIDs
|
||||
preferredWeekdays = person.preferredWeekdays
|
||||
weekdayPeriods = Dictionary(uniqueKeysWithValues: person.preferredWeekdayPeriods.map { ($0.weekday, $0.period) })
|
||||
preferredServiceTitles = Set(person.preferredServiceTitles)
|
||||
maxPerMonth = person.maxPerMonth
|
||||
allowBeyondPreferences = person.allowBeyondPreferences
|
||||
active = person.active
|
||||
notes = person.notes
|
||||
}
|
||||
@@ -378,6 +432,7 @@ struct PersonEditorSheet: View {
|
||||
private func save() {
|
||||
let person = Person(
|
||||
id: personID ?? UUID().uuidString,
|
||||
shortCode: shortCode.trimmingCharacters(in: .whitespaces),
|
||||
firstName: firstName.trimmingCharacters(in: .whitespaces),
|
||||
lastName: lastName.trimmingCharacters(in: .whitespaces),
|
||||
roles: roles,
|
||||
@@ -385,8 +440,12 @@ struct PersonEditorSheet: View {
|
||||
phone: phone.trimmingCharacters(in: .whitespaces),
|
||||
preferredChurchIDs: preferredChurchIDs,
|
||||
preferredWeekdays: preferredWeekdays,
|
||||
preferredWeekdayPeriods: preferredWeekdays.sorted().map {
|
||||
WeekdayPeriodPreference(weekday: $0, period: weekdayPeriods[$0] ?? .all)
|
||||
},
|
||||
preferredServiceTitles: Array(preferredServiceTitles).sorted(),
|
||||
maxPerMonth: maxPerMonth,
|
||||
allowBeyondPreferences: allowBeyondPreferences,
|
||||
active: active,
|
||||
notes: notes.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
)
|
||||
|
||||
@@ -8,6 +8,9 @@ struct PlanResultSheet: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
if let result = model.planResult {
|
||||
let canOfferBeyond = !result.unfilled.isEmpty
|
||||
&& !result.assignments.contains(where: \.beyondPreferences)
|
||||
&& model.people.contains { $0.active && $0.allowBeyondPreferences }
|
||||
SheetHeader(
|
||||
icon: result.unfilled.isEmpty ? "checkmark.seal" : "exclamationmark.triangle",
|
||||
title: result.unfilled.isEmpty ? "Planung abgeschlossen" : "Planung mit Lücken",
|
||||
@@ -98,12 +101,31 @@ struct PlanResultSheet: View {
|
||||
.clipShape(RoundedRectangle(cornerRadius: 9))
|
||||
.overlay(RoundedRectangle(cornerRadius: 9).strokeBorder(LP.line.opacity(0.55), lineWidth: 0.8))
|
||||
}
|
||||
|
||||
if canOfferBeyond {
|
||||
let flagged = model.people.filter { $0.active && $0.allowBeyondPreferences }
|
||||
HStack(alignment: .top, spacing: 9) {
|
||||
Image(systemName: "arrow.up.right.circle")
|
||||
.foregroundStyle(LP.burgundy)
|
||||
Text("\(flagged.count) \(flagged.count == 1 ? "Person hat" : "Personen haben") sich bereit erklärt, nach Rückfrage auch über die eigenen Präferenzen hinaus eingeplant zu werden. Diese Einsätze werden im Plan besonders gekennzeichnet.")
|
||||
.font(.system(size: 10.5))
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.padding(12)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(LP.burgundySoft.opacity(0.5)))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(22)
|
||||
}
|
||||
|
||||
SheetFooter {
|
||||
if canOfferBeyond {
|
||||
PrimaryActionButton(title: "Über Präferenzen hinaus planen", icon: "arrow.up.right") {
|
||||
_ = model.autoPlan(replaceExisting: false, allowBeyond: true)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
SecondaryActionButton(title: "Statistik ansehen", icon: "chart.xyaxis.line") {
|
||||
model.planResult = nil
|
||||
|
||||
@@ -158,6 +158,7 @@ private struct CalendarTable: View {
|
||||
private let horizontalPadding: CGFloat = 12
|
||||
private let dateWidth: CGFloat = 86
|
||||
private let liturgyWidth: CGFloat = 240
|
||||
private let actionWidth: CGFloat = 22
|
||||
private let churchMinWidth: CGFloat = 186
|
||||
|
||||
var body: some View {
|
||||
@@ -166,9 +167,9 @@ private struct CalendarTable: View {
|
||||
toolbar
|
||||
Hairline()
|
||||
GeometryReader { geo in
|
||||
let minimum = horizontalPadding * 2 + dateWidth + liturgyWidth + churchMinWidth * 4 + gap * 5
|
||||
let minimum = horizontalPadding * 2 + dateWidth + liturgyWidth + actionWidth + churchMinWidth * 4 + gap * 6
|
||||
let width = max(geo.size.width, minimum)
|
||||
let churchWidth = (width - horizontalPadding * 2 - dateWidth - liturgyWidth - gap * 5) / 4
|
||||
let churchWidth = (width - horizontalPadding * 2 - dateWidth - liturgyWidth - actionWidth - gap * 6) / 4
|
||||
if model.churches.isEmpty {
|
||||
EmptyStateView(
|
||||
icon: "building.columns",
|
||||
@@ -201,6 +202,7 @@ private struct CalendarTable: View {
|
||||
churchWidth: churchWidth,
|
||||
dateWidth: dateWidth,
|
||||
liturgyWidth: liturgyWidth,
|
||||
actionWidth: actionWidth,
|
||||
gap: gap,
|
||||
horizontalPadding: horizontalPadding
|
||||
)
|
||||
@@ -317,6 +319,14 @@ private struct CalendarTable: View {
|
||||
}
|
||||
.font(.system(size: 8.5, weight: .medium))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
HStack(spacing: 3) {
|
||||
Image(systemName: "arrow.up.right")
|
||||
.font(.system(size: 8, weight: .bold))
|
||||
.foregroundStyle(LP.burgundy)
|
||||
Text("über Präferenzen")
|
||||
}
|
||||
.font(.system(size: 8.5, weight: .medium))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +355,8 @@ private struct CalendarTable: View {
|
||||
ForEach(model.churches) { church in
|
||||
ChurchColumnHeader(church: church, width: churchWidth)
|
||||
}
|
||||
Text("")
|
||||
.frame(width: actionWidth)
|
||||
}
|
||||
.padding(.horizontal, horizontalPadding)
|
||||
.padding(.vertical, 10)
|
||||
@@ -369,7 +381,7 @@ private struct CalendarTable: View {
|
||||
}
|
||||
.padding(.horizontal, horizontalPadding)
|
||||
.padding(.vertical, 7)
|
||||
.frame(width: horizontalPadding * 2 + dateWidth + liturgyWidth + churchWidth * 4 + gap * 5, alignment: .leading)
|
||||
.frame(width: horizontalPadding * 2 + dateWidth + liturgyWidth + actionWidth + churchWidth * 4 + gap * 6, alignment: .leading)
|
||||
.background(LP.paperDeep.opacity(0.55))
|
||||
.overlay(alignment: .top) { Hairline() }
|
||||
.overlay(alignment: .bottom) { Hairline().opacity(0.55) }
|
||||
@@ -440,6 +452,7 @@ private struct DayRow: View {
|
||||
var churchWidth: CGFloat
|
||||
var dateWidth: CGFloat
|
||||
var liturgyWidth: CGFloat
|
||||
var actionWidth: CGFloat
|
||||
var gap: CGFloat
|
||||
var horizontalPadding: CGFloat
|
||||
|
||||
@@ -459,6 +472,16 @@ private struct DayRow: View {
|
||||
churchCell(church: church)
|
||||
.frame(width: churchWidth, alignment: .topLeading)
|
||||
}
|
||||
Button {
|
||||
model.specialServiceEditor = SpecialServiceRequest(churchID: nil, date: row.date)
|
||||
} label: {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundStyle(LP.burgundy.opacity(0.6))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Sondergottesdienst an diesem Tag hinzufügen")
|
||||
.frame(width: actionWidth, alignment: .trailing)
|
||||
}
|
||||
.padding(.horizontal, horizontalPadding)
|
||||
.padding(.vertical, 9)
|
||||
@@ -526,17 +549,6 @@ private struct DayRow: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Button {
|
||||
model.specialServiceEditor = SpecialServiceRequest(churchID: nil, date: row.date)
|
||||
} label: {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
.font(.system(size: 11, weight: .semibold))
|
||||
.foregroundStyle(LP.burgundy.opacity(0.62))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Sondergottesdienst an diesem Tag hinzufügen")
|
||||
}
|
||||
}
|
||||
|
||||
private var liturgyCell: some View {
|
||||
@@ -624,6 +636,7 @@ private struct ServiceCard: View {
|
||||
@EnvironmentObject private var model: PlanModel
|
||||
var service: ServiceWithAssignments
|
||||
var liturgy: LiturgicalDay?
|
||||
@State private var confirmDelete = false
|
||||
|
||||
private var churchColor: Color { LP.churchColor(service.church.colorHex) }
|
||||
|
||||
@@ -674,6 +687,7 @@ private struct ServiceCard: View {
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 7)
|
||||
.padding(.trailing, 10)
|
||||
.padding(.vertical, 6)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(
|
||||
@@ -693,6 +707,30 @@ private struct ServiceCard: View {
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help(helpText)
|
||||
.overlay(alignment: .bottomTrailing) {
|
||||
Button {
|
||||
confirmDelete = true
|
||||
} label: {
|
||||
Image(systemName: "trash")
|
||||
.font(.system(size: 8, weight: .semibold))
|
||||
.foregroundStyle(LP.danger.opacity(0.65))
|
||||
.padding(3)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Gottesdienst löschen")
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Gottesdienst löschen?",
|
||||
isPresented: $confirmDelete,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Endgültig löschen", role: .destructive) {
|
||||
model.deleteService(service.service)
|
||||
}
|
||||
Button("Abbrechen", role: .cancel) {}
|
||||
} message: {
|
||||
Text("Der Termin und alle zugehörigen Einsätze werden entfernt. Die Gottesdienstordnung bleibt unverändert.")
|
||||
}
|
||||
}
|
||||
|
||||
private func roleLine(role: Role) -> some View {
|
||||
@@ -713,7 +751,12 @@ private struct ServiceCard: View {
|
||||
} else {
|
||||
ForEach(assigned) { assignment in
|
||||
if let person = model.peopleByID[assignment.personID] {
|
||||
PersonMiniChip(person: person, role: role, color: churchColor)
|
||||
PersonMiniChip(
|
||||
person: person,
|
||||
role: role,
|
||||
color: churchColor,
|
||||
beyond: assignment.beyondPreferences
|
||||
)
|
||||
}
|
||||
}
|
||||
if open > 0 {
|
||||
@@ -742,6 +785,9 @@ private struct ServiceCard: View {
|
||||
if !liturgy.remark.isEmpty { lines.append(liturgy.remark) }
|
||||
}
|
||||
if !service.service.notes.isEmpty { lines.append(service.service.notes) }
|
||||
if service.assignments.contains(where: \.beyondPreferences) {
|
||||
lines.append("Mindestens ein Einsatz geht über die Präferenzen hinaus")
|
||||
}
|
||||
lines.append("Klicken zum Bearbeiten")
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
@@ -45,17 +45,18 @@ struct ServiceDetailSheet: View {
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
Button {
|
||||
confirmDelete = true
|
||||
} label: {
|
||||
Image(systemName: "trash")
|
||||
.font(.system(size: 11.5, weight: .medium))
|
||||
.foregroundStyle(LP.danger)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Sondergottesdienst löschen")
|
||||
}
|
||||
|
||||
Button {
|
||||
confirmDelete = true
|
||||
} label: {
|
||||
Image(systemName: "trash")
|
||||
.font(.system(size: 11.5, weight: .medium))
|
||||
.foregroundStyle(LP.danger)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Gottesdienst löschen")
|
||||
|
||||
Spacer()
|
||||
SecondaryActionButton(title: "Schließen", icon: "xmark") { dismiss() }
|
||||
PrimaryActionButton(title: "Automatisch besetzen", icon: "wand.and.stars") {
|
||||
@@ -79,11 +80,11 @@ struct ServiceDetailSheet: View {
|
||||
}
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Sondergottesdienst löschen?",
|
||||
"Gottesdienst löschen?",
|
||||
isPresented: $confirmDelete,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Löschen", role: .destructive) {
|
||||
Button("Endgültig löschen", role: .destructive) {
|
||||
if let item {
|
||||
model.deleteService(item.service)
|
||||
}
|
||||
@@ -91,7 +92,7 @@ struct ServiceDetailSheet: View {
|
||||
}
|
||||
Button("Abbrechen", role: .cancel) {}
|
||||
} message: {
|
||||
Text("Der Termin und alle zugehörigen Einsätze werden entfernt.")
|
||||
Text("Der Termin und alle zugehörigen Einsätze werden entfernt. Die Gottesdienstordnung bleibt unverändert.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,12 +287,24 @@ struct ServiceDetailSheet: View {
|
||||
HStack(spacing: 8) {
|
||||
Avatar(initials: person.initials, color: LP.churchColor(item.church.colorHex), size: 24)
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
Text(person.fullName)
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundStyle(LP.ink)
|
||||
HStack(spacing: 5) {
|
||||
Text(person.fullName)
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundStyle(LP.ink)
|
||||
if assignment.beyondPreferences {
|
||||
TinyBadge(text: "ÜBER PRÄFERENZEN", color: LP.burgundy)
|
||||
}
|
||||
}
|
||||
Text(person.roleLabel)
|
||||
.font(.system(size: 8.5))
|
||||
.foregroundStyle(LP.inkTertiary)
|
||||
if !person.preferenceNote.isEmpty {
|
||||
Text(person.preferenceNote)
|
||||
.font(.system(size: 8.5))
|
||||
.italic()
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button {
|
||||
@@ -400,6 +413,16 @@ struct ServiceDetailSheet: View {
|
||||
if candidate.person.roles.contains(.lector) && candidate.person.roles.contains(.helper) {
|
||||
TinyBadge(text: "L+K", color: LP.accent)
|
||||
}
|
||||
if candidate.beyondPreferences {
|
||||
TinyBadge(text: "ÜBER PRÄFERENZEN", color: LP.burgundy)
|
||||
}
|
||||
}
|
||||
if !candidate.person.preferenceNote.isEmpty {
|
||||
Text(candidate.person.preferenceNote)
|
||||
.font(.system(size: 8.5))
|
||||
.italic()
|
||||
.foregroundStyle(LP.inkSecondary)
|
||||
.lineLimit(2)
|
||||
}
|
||||
HStack(spacing: 6) {
|
||||
Text("\(candidate.totalAssignments) Einsätze im Zeitraum")
|
||||
|
||||
Reference in new issue
Block a user