Per-Anbieter default VO with auto-select in the schaltung wizard

- New nullable anbieter.default_vo_id column (migration adds it to
  existing DBs); deleting a VO that some provider points at clears
  the reference automatically.
- GET /api/anbieter now includes default_vo_id + default_vo_nummer
  + default_vo_bezeichnung so the wizard can preselect without an
  extra round-trip.
- New PUT /api/anbieter/:id/default-vo endpoint. Validates the VO
  belongs to the given provider; accepts vo_id=null to clear.
- VO admin table grew a "Standard" column and an "Als Standard" /
  "Standard entfernen" button on each row.
- When the user picks a provider in step 1 of the wizard, the VO
  dropdown now preselects the default VO (falling back to the only
  VO if there is exactly one), and immediately loads the
  matching tariffs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
kerimatilganandClaude Opus 4.7 committed 2026-05-15 16:46:03 +02:00
1 parent 97ff779bcf
commit 041df61b24
5 files changed
+82 -16

No files matched your search

+2
View File
@@ -84,6 +84,8 @@ router.delete('/:id', asyncHandler(async (req, res) => {
if (used.n_schaltungen > 0) parts.push(`${used.n_schaltungen} Schaltung(en)`);
return res.status(400).json({ error: `VO kann nicht gelöscht werden: ${parts.join(', ')} verwenden diese VO` });
}
// Clear any anbieter pointing at this VO as their default before removing it.
await db.run('UPDATE anbieter SET default_vo_id = NULL WHERE default_vo_id = ?', [id]);
const result = await db.run('DELETE FROM vos WHERE id = ?', [id]);
if (result.changes === 0) return res.status(404).json({ error: 'VO nicht gefunden' });
res.json({ message: 'VO erfolgreich gelöscht' });