Aug 17 - Update customer inspector can update issue status

This commit is contained in:
2026-08-17 16:46:26 -04:00
parent 436ef5dafb
commit 607da7ae47
4 changed files with 72 additions and 7 deletions
+40
View File
@@ -76,4 +76,44 @@ nonisolated enum Constants {
}
static let tokenRefreshBufferMinutes: Double = 5
// MARK: - Roles
//
// The server's role strings, and the ONE definition of which of them the
// app treats as an inspector. This mirrors `User.INSPECTOR_ROLES` /
// `User.is_inspector` in the Flask app (see server rule 87).
//
// Why this exists: `external_inspector` (displayed as "Customer Inspector"
// an inspector employed by the customer) has exactly the same powers as
// our own `inspector`, and the API scopes it identically. The views here
// were hand-written as `role == "admin" || role == "director" || role ==
// "inspector"`, so every one of them silently locked customer inspectors
// out of actions the SERVER was perfectly willing to accept Update
// Status, Handled By, Start Follow-up. The failure is invisible: no error,
// the control simply isn't drawn.
//
// Add a role in ONE place here; never re-write the literals in a view.
nonisolated enum Roles {
static let admin = "admin"
static let director = "director"
static let projectManager = "project_manager"
static let auditor = "auditor"
static let inspector = "inspector"
/// "Customer Inspector" employed by the customer, same powers as
/// `inspector`, scoped to their assigned contracts.
static let externalInspector = "external_inspector"
/// Both inspector roles. Test membership of this, never `== inspector`.
static let inspectorRoles: Set<String> = [inspector, externalInspector]
/// May change an issue's status / handler, and start a follow-up.
/// Matches what the API actually accepts for these actions; the server
/// remains the authority and additionally enforces facility scope.
static let issueActors: Set<String> =
[admin, director, projectManager].union(inspectorRoles)
static func isInspector(_ role: String) -> Bool {
inspectorRoles.contains(role)
}
}
}