Jul 27 - Update for scheduled task instruction
This commit is contained in:
@@ -266,6 +266,11 @@ struct DashboardStatsView: View {
|
||||
) private var draftInspections: [LocalInspection]
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
/// Schedule the inspector tapped in ScheduledInspectionsCard. Held here, not
|
||||
/// in the card: the card self-hides, and submitting the last scheduled
|
||||
/// inspection empties its @Query while the start form is still presented.
|
||||
@State private var scheduledStartTarget: ScheduledStartTarget? = nil
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
@@ -279,7 +284,9 @@ struct DashboardStatsView: View {
|
||||
// Planned/recurring assignments for this inspector. Self-hides
|
||||
// when there are none. Tap a row to start it (facility +
|
||||
// template preselected).
|
||||
ScheduledInspectionsCard()
|
||||
ScheduledInspectionsCard(onStart: { target in
|
||||
scheduledStartTarget = target
|
||||
})
|
||||
|
||||
if let stats = sync.dashboardStats {
|
||||
// ── Today ──────────────────────────────────────────────
|
||||
@@ -407,6 +414,19 @@ struct DashboardStatsView: View {
|
||||
.refreshable {
|
||||
await sync.fetchDashboardStats()
|
||||
}
|
||||
// Start cover for a tapped scheduled inspection. Owned here rather than
|
||||
// by ScheduledInspectionsCard because that card self-hides the instant
|
||||
// its last row is removed — which is exactly when this cover is on
|
||||
// screen (submit deletes the cached schedule row). The ScrollView is
|
||||
// always present, so the form is never torn down mid-submit.
|
||||
.fullScreenCover(item: $scheduledStartTarget) { t in
|
||||
StartInspectionView(
|
||||
preFillTemplateId: t.templateServerId,
|
||||
preFillFacilityId: t.facilityServerId,
|
||||
preFillScheduleId: t.id,
|
||||
preFillScheduleInstructions: t.instructions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Helpers ────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user