forked from CMU-17313Q/cmu-17313q-f24-nodebb-f24-NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement controller and backend logic for isApproved
feature
#53
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jdufitum
reviewed
Oct 20, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me. we need to fix the bug which is causing the test fail
Fix the UI for isApproved attribute in post object
Fix the server (casting) for isApproved attribute in post obj
jdufitum
approved these changes
Oct 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: This PR implements a feature that allows users to approve or disapprove posts using a toggle button. The changes ensure that the UI reflects the current approval state immediately after an action is taken, without needing to reload the page.
Changes Made:
Added an AJAX call to handle the approval status of posts via a PUT request to the API endpoint /api/v3/posts/:pid/approve.
The request includes the post ID, current approval status, and CSRF token for security.
Implemented logic to update the button icon and text based on the approval state returned from the server.
The toggle button's icon will switch between fa-toggle-on and fa-toggle-off, and the accompanying text will change between "Approve Post" and "Disapprove Post".
The click event listener is set up to handle clicks on the toggle button, ensuring that the correct post ID is targeted for approval changes.
Used jQuery to manage DOM interactions, ensuring clean and readable code.
Added console logging to track the approval process and response data for easier debugging.
Included error handling to notify users of issues that may arise during the approval process.