Aug 17 - Update for customer inspector contract scope
This commit is contained in:
@@ -1089,11 +1089,19 @@ struct StandaloneIssueView: View {
|
||||
}
|
||||
private var remainingSlots: Int { maxPhotos - photos.count }
|
||||
|
||||
/// Facilities this user may file a new issue against.
|
||||
/// Excludes rows SyncManager retained purely so an unsynced draft could
|
||||
/// still show its facility name — see StartInspectionView for the full
|
||||
/// explanation. Out-of-scope facilities must not be offered for new work.
|
||||
private var availableFacilities: [LocalFacility] {
|
||||
facilities.filter { $0.isActive }
|
||||
}
|
||||
|
||||
/// Unique contracts derived from cached facilities, sorted by name.
|
||||
private var contracts: [(id: Int, name: String)] {
|
||||
var seen = Set<Int>()
|
||||
var result: [(id: Int, name: String)] = []
|
||||
for f in facilities {
|
||||
for f in availableFacilities {
|
||||
if seen.insert(f.projectId).inserted {
|
||||
result.append((id: f.projectId, name: f.projectName))
|
||||
}
|
||||
@@ -1106,7 +1114,7 @@ struct StandaloneIssueView: View {
|
||||
private var filteredFacilities: [LocalFacility] {
|
||||
guard let pid = selectedProjectId else { return [] }
|
||||
var seen = Set<Int>()
|
||||
return facilities
|
||||
return availableFacilities
|
||||
.filter { $0.projectId == pid }
|
||||
.filter { seen.insert($0.serverId).inserted }
|
||||
}
|
||||
|
||||
@@ -39,12 +39,23 @@ struct StartInspectionView: View {
|
||||
|
||||
// ── Derived lists ─────────────────────────────────────────────────────
|
||||
|
||||
/// Facilities this inspector may actually start work at.
|
||||
///
|
||||
/// The cache can hold a facility that is no longer in scope — SyncManager
|
||||
/// keeps such a row (marked inactive) when an unsynced draft still needs
|
||||
/// its name, rather than deleting it and showing "Unknown Facility". It
|
||||
/// must not be offered for NEW work, and neither must its contract, so
|
||||
/// every derived list below starts here rather than from `facilities`.
|
||||
private var availableFacilities: [LocalFacility] {
|
||||
facilities.filter { $0.isActive }
|
||||
}
|
||||
|
||||
/// Unique contracts (projectId, projectName) sorted by name.
|
||||
/// Facilities with projectId == 0 are grouped under "No Contract".
|
||||
private var contracts: [(id: Int, name: String)] {
|
||||
var seen = Set<Int>()
|
||||
var result: [(id: Int, name: String)] = []
|
||||
for f in facilities {
|
||||
for f in availableFacilities {
|
||||
if seen.insert(f.projectId).inserted {
|
||||
result.append((id: f.projectId, name: f.projectName))
|
||||
}
|
||||
@@ -58,7 +69,7 @@ struct StartInspectionView: View {
|
||||
private var filteredFacilities: [LocalFacility] {
|
||||
guard let pid = selectedProjectId else { return [] }
|
||||
var seen = Set<Int>()
|
||||
return facilities
|
||||
return availableFacilities
|
||||
.filter { $0.projectId == pid }
|
||||
.filter { seen.insert($0.serverId).inserted }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user