feat(iace): surface OSHA distance anchor in Maßnahmen tab (name-resolved)

Makes the OSHA minimum-distance anchor visible per measure in a project
without a DB schema change or re-seed: persisted mitigations store the
measure NAME verbatim (not the catalog ID), and measure names are unique
across the 578-entry library (pinned by test), so a name→ID resolver
bridges the gap.

Backend: MeasureIDByName + MinimumDistancesForMeasureName/LinksForMeasureName;
/iace/minimum-distances now accepts ?measure_name=; link table enriched with
measure_name for one-request UI matching.
Frontend: useMinimumDistances loads the link table once and keys it by name;
OshaDistanceNote renders the anchor (value/CFR/license/EU-hint/relation) on the
matching measure group in the Maßnahmen tab.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-11 13:39:48 +02:00
parent 76be96556d
commit 6b41eec176
6 changed files with 226 additions and 8 deletions
@@ -10,15 +10,22 @@ import (
// ListMinimumDistances handles GET /minimum-distances.
// Read-only OSHA safety-distance reference (29 CFR 1910, US public domain)
// plus the curated measure→distance link table, so an auditor can see WHERE a
// measure's mm figure comes from. Optional ?measure_id= returns only the
// distances (and links) tied to that protective measure.
// measure's mm figure comes from. Scope to one measure via ?measure_id= or
// ?measure_name= (the latter lets a persisted mitigation — which stores the
// name, not the catalog ID — resolve its anchor without a schema change).
func (h *IACEHandler) ListMinimumDistances(c *gin.Context) {
if mid := c.Query("measure_id"); mid != "" {
mid := c.Query("measure_id")
mname := c.Query("measure_name")
if mid == "" && mname != "" {
mid, _ = iace.MeasureIDByName(mname) // "" if unknown → empty scoped result
}
if mid != "" || mname != "" {
c.JSON(http.StatusOK, gin.H{
"measure_id": mid,
"distances": iace.MinimumDistancesForMeasure(mid),
"links": iace.LinksForMeasure(mid),
"note": iace.MinimumDistanceNote,
"measure_id": mid,
"measure_name": mname,
"distances": iace.MinimumDistancesForMeasure(mid),
"links": iace.LinksForMeasure(mid),
"note": iace.MinimumDistanceNote,
})
return
}