feat(viz): helpers puros para dod_evidence_panel (issue 0117)

DodItem/DodEvidence/DodPanelState + count_status/find_evidence/
status_icon_id/status_color_token. Sin ImGui — testeable en aislamiento.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 18:30:16 +02:00
parent 4eb4c1cf98
commit b21adb40c9
2 changed files with 122 additions and 0 deletions
@@ -0,0 +1,47 @@
#include "dod_evidence_panel_helpers.h"
namespace fn_viz {
namespace dod_panel {
StatusCounts count_status(const DodPanelState& state) {
StatusCounts c;
c.total = static_cast<int>(state.items.size());
for (const auto& it : state.items) {
if (it.status == "pending") ++c.pending;
else if (it.status == "done") ++c.done;
else if (it.status == "validated") ++c.validated;
else if (it.status == "failed") ++c.failed;
else ++c.pending; // unknown treated as pending
if (it.required) {
const DodEvidence* ev = find_evidence(state, it.id);
const bool resolved = (it.status == "done" || it.status == "validated");
if (ev == nullptr && !resolved) ++c.missing_required;
}
}
return c;
}
const DodEvidence* find_evidence(const DodPanelState& state, const std::string& item_id) {
for (const auto& ev : state.evidences) {
if (ev.item_id == item_id) return &ev;
}
return nullptr;
}
std::string status_icon_id(const std::string& status) {
if (status == "done") return "circle-dot";
if (status == "validated") return "circle-check";
if (status == "failed") return "circle-x";
return "circle-dashed"; // pending / unknown
}
int status_color_token(const std::string& status) {
if (status == "done") return 1;
if (status == "validated") return 2;
if (status == "failed") return 3;
return 0;
}
} // namespace dod_panel
} // namespace fn_viz