From 53bc48a52a56040387e4ab8b7dd2e6b26f9df063 Mon Sep 17 00:00:00 2001 From: Paul Lizer Date: Mon, 9 Feb 2026 13:29:10 -0500 Subject: [PATCH] removed duplicate code causing bugs --- application/single_app/config.py | 2 +- .../static/js/group/manage_group.js | 62 +++++++------------ docs/explanation/release_notes.md | 14 +++++ 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/application/single_app/config.py b/application/single_app/config.py index ee1bc63d..47eebf17 100644 --- a/application/single_app/config.py +++ b/application/single_app/config.py @@ -88,7 +88,7 @@ EXECUTOR_TYPE = 'thread' EXECUTOR_MAX_WORKERS = 30 SESSION_TYPE = 'filesystem' -VERSION = "0.237.009" +VERSION = "0.237.010" SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production') diff --git a/application/single_app/static/js/group/manage_group.js b/application/single_app/static/js/group/manage_group.js index a6b00cc4..d6372838 100644 --- a/application/single_app/static/js/group/manage_group.js +++ b/application/single_app/static/js/group/manage_group.js @@ -92,39 +92,6 @@ $(document).ready(function () { rejectRequest(requestId); }); - // Add event delegation for select user button in search results - $(document).on("click", ".select-user-btn", function () { - const id = $(this).data("user-id"); - const name = $(this).data("user-name"); - const email = $(this).data("user-email"); - selectUserForAdd(id, name, email); - }); - - // Add event delegation for remove member button - $(document).on("click", ".remove-member-btn", function () { - const userId = $(this).data("user-id"); - removeMember(userId); - }); - - // Add event delegation for change role button - $(document).on("click", ".change-role-btn", function () { - const userId = $(this).data("user-id"); - const currentRole = $(this).data("user-role"); - openChangeRoleModal(userId, currentRole); - $("#changeRoleModal").modal("show"); - }); - - // Add event delegation for approve/reject request buttons - $(document).on("click", ".approve-request-btn", function () { - const requestId = $(this).data("request-id"); - approveRequest(requestId); - }); - - $(document).on("click", ".reject-request-btn", function () { - const requestId = $(this).data("request-id"); - rejectRequest(requestId); - }); - // CSV Bulk Upload Events $("#addBulkMemberBtn").on("click", function () { $("#csvBulkUploadModal").modal("show"); @@ -504,11 +471,21 @@ function setRole(userId, newRole) { data: JSON.stringify({ role: newRole }), success: function () { $("#changeRoleModal").modal("hide"); + showToast("success", "Role updated successfully"); loadMembers(); }, error: function (err) { - console.error(err); - alert("Failed to update role."); + console.error("Error updating role:", err); + let errorMsg = "Failed to update role."; + if (err.status === 404) { + errorMsg = "Member not found. They may have been removed."; + loadMembers(); // Refresh the member list + } else if (err.status === 403) { + errorMsg = "You don't have permission to change this member's role."; + } else if (err.responseJSON && err.responseJSON.message) { + errorMsg = err.responseJSON.message; + } + showToast("error", errorMsg); }, }); } @@ -519,11 +496,21 @@ function removeMember(userId) { url: `/api/groups/${groupId}/members/${userId}`, method: "DELETE", success: function () { + showToast("success", "Member removed successfully"); loadMembers(); }, error: function (err) { - console.error(err); - alert("Failed to remove member."); + console.error("Error removing member:", err); + let errorMsg = "Failed to remove member."; + if (err.status === 404) { + errorMsg = "Member not found. They may have already been removed."; + loadMembers(); // Refresh the member list + } else if (err.status === 403) { + errorMsg = "You don't have permission to remove this member."; + } else if (err.responseJSON && err.responseJSON.message) { + errorMsg = err.responseJSON.message; + } + showToast("error", errorMsg); }, }); } @@ -631,7 +618,6 @@ function searchUsers() { }); } -// Render user-search results in add-member modal // Render user-search results in add-member modal function renderUserSearchResults(users) { let html = ""; diff --git a/docs/explanation/release_notes.md b/docs/explanation/release_notes.md index 384d44bc..2381fa68 100644 --- a/docs/explanation/release_notes.md +++ b/docs/explanation/release_notes.md @@ -2,6 +2,20 @@ # Feature Release +### **(v0.237.010)** + +#### Bug Fixes + +* **Manage Group Page Duplicate Code and Error Handling Fix** + * Fixed multiple code quality and user experience issues in the Manage Group page JavaScript. + * **Duplicate Event Handlers**: Removed duplicate event handler registrations (lines 96-127) for `.select-user-btn`, `.remove-member-btn`, `.change-role-btn`, `.approve-request-btn`, and `.reject-request-btn` that were causing multiple event firings. + * **Duplicate HTML in Actions Column**: Fixed member action buttons rendering duplicate attributes as visible text instead of functional buttons, causing raw HTML/CSS class names to display in the Actions column. + * **Duplicate Pending Request Buttons**: Removed duplicate Approve and Reject buttons in pending requests table that were appearing twice per request. + * **Enhanced Error Handling**: Improved `setRole()` and `removeMember()` functions with specific error messages for 404 (member not found) and 403 (permission denied) errors, automatic member list refresh on 404, and user-friendly toast notifications instead of generic alerts. + * **Removed Duplicate Comment**: Cleaned up duplicate "Render user-search results" comment. + * **Impact**: Member management buttons now render and function correctly, provide better error feedback, and auto-recover from stale member data. + * (Ref: `manage_group.js`, event handler deduplication, error handling improvements, toast notifications) + ### **(v0.237.009)** #### New Features