v0.12.28 new modal window for event edit/delete

This commit is contained in:
2026-03-25 13:00:43 -04:00
parent 2b2e98fa48
commit ba91fce44c
8 changed files with 130 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "rosterchirp-backend",
"version": "0.12.27",
"version": "0.12.28",
"description": "RosterChirp backend server",
"main": "src/index.js",
"scripts": {

View File

@@ -273,7 +273,7 @@ router.patch('/:id', authMiddleware, teamManagerMiddleware, async (req, res) =>
await applyEventUpdate(req.schema, req.params.id, fields, userGroupIds);
// Recurring future scope — update all future occurrences
// Recurring future scope — update this and all future occurrences
if (recurringScope === 'future' && event.recurrence_rule) {
const futureEvents = await query(req.schema, `
SELECT id FROM events WHERE id!=$1 AND created_by=$2 AND recurrence_rule IS NOT NULL
@@ -282,6 +282,14 @@ router.patch('/:id', authMiddleware, teamManagerMiddleware, async (req, res) =>
for (const fe of futureEvents)
await applyEventUpdate(req.schema, fe.id, fields, userGroupIds);
}
// Recurring all scope — update every occurrence
if (recurringScope === 'all' && event.recurrence_rule) {
const allEvents = await query(req.schema, `
SELECT id FROM events WHERE id!=$1 AND created_by=$2 AND recurrence_rule IS NOT NULL AND title=$3
`, [req.params.id, event.created_by, event.title]);
for (const ae of allEvents)
await applyEventUpdate(req.schema, ae.id, fields, userGroupIds);
}
// Clean up availability for users removed from groups
if (Array.isArray(userGroupIds)) {
@@ -311,9 +319,23 @@ router.patch('/:id', authMiddleware, teamManagerMiddleware, async (req, res) =>
router.delete('/:id', authMiddleware, teamManagerMiddleware, async (req, res) => {
try {
if (!(await queryOne(req.schema, 'SELECT id FROM events WHERE id=$1', [req.params.id])))
return res.status(404).json({ error: 'Not found' });
await exec(req.schema, 'DELETE FROM events WHERE id=$1', [req.params.id]);
const event = await queryOne(req.schema, 'SELECT * FROM events WHERE id=$1', [req.params.id]);
if (!event) return res.status(404).json({ error: 'Not found' });
const { recurringScope } = req.body || {};
if (recurringScope === 'future' && event.recurrence_rule) {
// Delete this event and all future occurrences with same creator/title
await exec(req.schema, `
DELETE FROM events WHERE created_by=$1 AND recurrence_rule IS NOT NULL
AND title=$2 AND start_at >= $3
`, [event.created_by, event.title, event.start_at]);
} else if (recurringScope === 'all' && event.recurrence_rule) {
// Delete every occurrence
await exec(req.schema, `
DELETE FROM events WHERE created_by=$1 AND recurrence_rule IS NOT NULL AND title=$2
`, [event.created_by, event.title]);
} else {
await exec(req.schema, 'DELETE FROM events WHERE id=$1', [req.params.id]);
}
res.json({ success: true });
} catch (e) { res.status(500).json({ error: e.message }); }
});