v.0.9.66 UI changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jama-backend",
|
||||
"version": "0.9.65",
|
||||
"version": "0.9.66",
|
||||
"description": "TeamChat backend server",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -195,6 +195,29 @@ router.patch('/:id', authMiddleware, teamManagerMiddleware, (req, res) => {
|
||||
req.params.id
|
||||
);
|
||||
if (Array.isArray(userGroupIds)) {
|
||||
// Find which groups are being removed
|
||||
const prevGroupIds = db.prepare('SELECT user_group_id FROM event_user_groups WHERE event_id = ?')
|
||||
.all(req.params.id).map(r => r.user_group_id);
|
||||
const newGroupSet = new Set(userGroupIds.map(Number));
|
||||
const removedGroupIds = prevGroupIds.filter(id => !newGroupSet.has(id));
|
||||
|
||||
// Remove availability responses for users who are only in removed groups
|
||||
for (const removedGid of removedGroupIds) {
|
||||
const removedUserIds = db.prepare('SELECT user_id FROM user_group_members WHERE user_group_id = ?')
|
||||
.all(removedGid).map(r => r.user_id);
|
||||
for (const uid of removedUserIds) {
|
||||
// Check if user is still in ANY remaining group for this event
|
||||
const stillAssigned = newGroupSet.size > 0 && db.prepare(`
|
||||
SELECT 1 FROM user_group_members
|
||||
WHERE user_id = ? AND user_group_id IN (${[...newGroupSet].map(()=>'?').join(',')})
|
||||
`).get(uid, ...[...newGroupSet]);
|
||||
if (!stillAssigned) {
|
||||
db.prepare('DELETE FROM event_availability WHERE event_id = ? AND user_id = ?')
|
||||
.run(req.params.id, uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db.prepare('DELETE FROM event_user_groups WHERE event_id = ?').run(req.params.id);
|
||||
for (const ugId of userGroupIds)
|
||||
db.prepare('INSERT OR IGNORE INTO event_user_groups (event_id, user_group_id) VALUES (?, ?)').run(req.params.id, ugId);
|
||||
|
||||
Reference in New Issue
Block a user