Dieser Commit ist enthalten in:
hendrik_gebhardt@gmx.de
2026-01-06 21:49:26 +00:00
committet von Server Deploy
Ursprung 623bbdf5dd
Commit 7d67557be4
34 geänderte Dateien mit 21416 neuen und 2367 gelöschten Zeilen

Datei anzeigen

@ -110,13 +110,13 @@ router.post('/categories', (req, res) => {
return res.status(400).json({ error: 'Eine Kategorie mit diesem Namen existiert bereits' });
}
// Position ermitteln
const lastPosition = db.prepare(
'SELECT MAX(position) as max_pos FROM knowledge_categories'
).get();
const position = (lastPosition.max_pos ?? -1) + 1;
// Alle bestehenden Kategorien um 1 nach unten verschieben
db.prepare(`
UPDATE knowledge_categories
SET position = position + 1
`).run();
// Einfügen
// Neue Kategorie an Position 0 (ganz oben) einfügen
const result = db.prepare(`
INSERT INTO knowledge_categories (name, description, color, icon, position, created_by)
VALUES (?, ?, ?, ?, ?, ?)
@ -125,7 +125,7 @@ router.post('/categories', (req, res) => {
description ? stripHtml(description) : null,
color || '#3B82F6',
icon || null,
position,
0, // Neue Kategorien immer an Position 0 (oben)
req.user.id
);
@ -473,13 +473,14 @@ router.post('/entries', (req, res) => {
return res.status(404).json({ error: 'Kategorie nicht gefunden' });
}
// Position ermitteln
const lastPosition = db.prepare(
'SELECT MAX(position) as max_pos FROM knowledge_entries WHERE category_id = ?'
).get(categoryId);
const position = (lastPosition.max_pos ?? -1) + 1;
// Alle bestehenden Einträge um 1 nach unten verschieben
db.prepare(`
UPDATE knowledge_entries
SET position = position + 1
WHERE category_id = ?
`).run(categoryId);
// Einfügen
// Neuen Eintrag an Position 0 (ganz oben) einfügen
const result = db.prepare(`
INSERT INTO knowledge_entries (category_id, title, url, notes, position, created_by)
VALUES (?, ?, ?, ?, ?, ?)
@ -488,7 +489,7 @@ router.post('/entries', (req, res) => {
stripHtml(title),
url || null,
notes || null,
position,
0, // Neue Einträge immer an Position 0 (oben)
req.user.id
);