Add full category & metric management in Settings

- New Settings editor: rename categories (emoji/color too), rename
  metrics, change unit and type, add/remove metrics, set step + record
  tracking, archive/unarchive, and permanently delete categories.
- Settings now lists archived categories so they can be restored/deleted.
- Backend: add DELETE /api/categories/:id (cascades metrics, entries,
  entry_values, plans, goals).
- Bump StartOS package to 0.1.6:0; service worker cache to v6.
This commit is contained in:
Keysat
2026-06-04 08:43:11 -05:00
parent cf64a2dc50
commit 284c5ff079
7 changed files with 89 additions and 27 deletions
+10
View File
@@ -54,6 +54,16 @@ export default async function categoryRoutes(app) {
return categoriesWithMetrics({ includeArchived: true }).find((c) => c.id === id);
});
// Permanently delete a category and everything under it (metrics, entries,
// entry values, plans, goals) via ON DELETE CASCADE.
app.delete('/api/categories/:id', async (req, reply) => {
const id = Number(req.params.id);
const cat = db.prepare('SELECT id FROM categories WHERE id = ?').get(id);
if (!cat) return reply.code(404).send({ error: 'Not found' });
db.prepare('DELETE FROM categories WHERE id = ?').run(id);
return reply.send({ ok: true });
});
// Add a metric to an existing category.
app.post('/api/categories/:id/metrics', async (req, reply) => {
const id = Number(req.params.id);