v0.1.7: delete companies for re-evaluation

- DELETE /api/companies/{slug}: wipes the ledger (deck records, scorecard,
  report md), sweeps per-job report and processed-deck copies; optional
  restore_decks moves the graded originals from /data/processed back into
  the inbox for a fresh Grade Decks run; 409 while a job is running;
  config-registered companies reappear as empty rows (aliases + pinned
  targets kept)
- Dashboard: "delete company…" danger button on the company card with a
  two-step confirm (delete, then restore-decks choice)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jonathan Kirkwood
2026-07-30 14:25:44 -05:00
co-authored by Claude Fable 5
parent 32d5d7f373
commit 7ec5222834
5 changed files with 105 additions and 5 deletions
+23 -1
View File
@@ -34,6 +34,8 @@
padding:8px 12px;font-size:13px;cursor:pointer} button:hover{background:#2c3650}
button.primary{background:#3a2f12;border-color:#6b551f;color:#ffdf9a}
button.mini{padding:2px 8px;font-size:11px;border-radius:7px}
button.danger{background:#2c1416;border-color:#552222;color:var(--bad)}
button.danger:hover{background:#3b1414}
a.mini{display:inline-block;background:#222a3a;border:1px solid var(--edge);border-radius:7px;
padding:2px 8px;font-size:11px;color:var(--ink);text-decoration:none;cursor:pointer}
a.mini:hover{background:#2c3650}
@@ -127,7 +129,8 @@
<h2 style="display:flex;align-items:center;gap:10px">Company —
<span id="coName" style="color:var(--ink);letter-spacing:0;text-transform:none;font-size:15px"></span>
<span id="coBadges"></span>
<button class="mini" style="margin-left:auto" onclick="closeCompany()">close</button>
<button class="mini danger" style="margin-left:auto" onclick="deleteCompany()">delete company…</button>
<button class="mini" onclick="closeCompany()">close</button>
</h2>
<div id="coTrend"></div>
<div class="detail-grid">
@@ -471,6 +474,25 @@ function renderDetail(d,changed){
document.getElementById('scBtn').textContent='View SCORECARD.md';
}
}
async function deleteCompany(){
if(!currentSlug) return;
const name=(companiesCache.find(c=>c.slug===currentSlug)||{}).name||currentSlug;
if(!confirm(`Delete "${name}"?\n\nThis wipes its graded history: all deck records, `+
`the scorecard, and report copies. A company registered in Configure Companies `+
`reappears as an empty row (aliases and pinned targets kept), ready to re-grade.`)) return;
const restore=confirm('Move its already-graded deck files back into the inbox '+
'so they can be re-graded?\n\nOK = yes, put decks back · Cancel = no, just delete');
try{
const r=await fetch('/api/companies/'+encodeURIComponent(currentSlug)+
(restore?'?restore_decks=true':''),{method:'DELETE'});
const t=await r.text();
if(!r.ok){ alert('Delete failed: '+t.slice(0,300)); return; }
const d=JSON.parse(t);
alert(`Deleted ${name}.`+(d.restored_decks?` ${d.restored_decks} deck file(s) `+
`restored to the inbox — hit "Grade decks" to re-run.`:''));
closeCompany(); refresh(); loadCompanies();
}catch(e){ alert('Delete failed: '+(e.message||e)); }
}
function deckBase(deckId){
return '/api/companies/'+encodeURIComponent(currentSlug)+'/decks/'+encodeURIComponent(deckId);
}