Skip to content
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

feat(todo): enhance todo functionality and error handling #198

Merged
merged 15 commits into from
Sep 16, 2024

Conversation

psyray
Copy link
Contributor

@psyray psyray commented Sep 10, 2024

Fixes #197

  • Refactored the JavaScript code for creating and displaying todo items to use a template-based approach.
  • Improved error handling and user feedback for adding, deleting, and updating todo items.
  • Updated API endpoints and views to include better validation and error messages.
  • Enhanced the UI with search maintained across section, new icons and required fields for better user experience.
  • Added a hidden template for todo items to streamline the creation of new items dynamically.

Preview

image
Screenshot_20240910_102402
Screenshot_20240910_102411
Screenshot_20240910_102721
Screenshot_20240910_102733
Screenshot_20240910_102946
Screenshot_20240910_112806

Summary by Sourcery

Enhance the todo functionality by adopting a template-based approach for item creation, improving error handling, and refining the UI with new icons and required fields. Refactor JavaScript code for better organization and introduce detailed docstrings in the views for improved documentation.

New Features:

  • Introduce a template-based approach for creating and displaying todo items, enhancing the dynamic creation of new items.
  • Add new UI elements, including icons and required fields, to improve user experience when interacting with todo items.

Bug Fixes:

  • Improve error handling and user feedback for operations such as adding, deleting, and updating todo items, ensuring better validation and error messages.

Enhancements:

  • Refactor JavaScript code to streamline event listeners and improve code organization, including the addition of functions for handling button actions and search functionality.
  • Enhance the todo list UI with a hidden template for todo items, allowing for more efficient rendering and updates.

Documentation:

  • Add detailed docstrings to the views in the recon_note app, providing clear explanations of the functions and their parameters.

- Refactored the JavaScript code for creating and displaying todo items to use a template-based approach.
- Improved error handling and user feedback for adding, deleting, and updating todo items.
- Updated API endpoints and views to include better validation and error messages.
- Enhanced the UI with new icons and required fields for better user experience.
- Added a hidden template for todo items to streamline the creation of new items dynamically.
@psyray psyray added the enhancement New feature or request label Sep 10, 2024
@psyray psyray requested a review from a team September 10, 2024 09:49
@psyray psyray self-assigned this Sep 10, 2024
@psyray psyray linked an issue Sep 10, 2024 that may be closed by this pull request
3 tasks
…t validation

- Refactored JavaScript code to use const instead of var for variable declarations.
- Updated event handlers to use async functions for better handling of asynchronous operations.
- Improved input validation in the HTML form for adding todos, including setting minimum and maximum lengths and allowed character patterns.
- Enhanced error handling and user feedback for adding, deleting, and updating todo items.
- Added detailed docstrings to Python view functions for better code documentation and readability.
- Introduced logging for JSON decode errors in the Python views.
- Simplified the button click handling logic in todo.js by removing redundant code and improving readability.
- Enhanced the user interface feedback for important task toggling and deletion confirmation.
- Added autocomplete="on" to the task input field in index.html for better user experience.
- Removed redundant class addition in the todo item creation process.
…nality

- Refactored todo.js to modularize event listeners into separate functions.
- Enhanced search functionality to save and load search terms from local storage.
- Updated the UI to include a clear search button and improved button styling for task actions.
- Adjusted HTML and CSS to support the new search and action button features.
web/recon_note/static/note/js/todo.js Fixed Show fixed Hide fixed
web/recon_note/static/note/js/todo.js Fixed Show fixed Hide fixed
web/recon_note/static/note/js/todo.js Fixed Show fixed Hide fixed
…crollbar instances

- Removed redundant variable assignments for PerfectScrollbar instances in the populateTodofunction.
- Added a missing semicolon in the importantBtnListener function.
- Corrected the function name from populateTodofunction to populateTodo.
- Added a new listener function addTaskPopupListener to handle task popups.
- Renamed addActionsBtnListener to actionsBtnListener and added a call to searchFunction within it.
- Introduced a new property is_important for tasks and updated the template to conditionally display the important badge.
- Enhanced the search functionality to apply the current filter after searching.
- Added a new function applyCurrentFilter to filter tasks based on their status (Todo, Done, Important).
@psyray psyray marked this pull request as ready for review September 11, 2024 12:58
Copy link

sourcery-ai bot commented Sep 11, 2024

Reviewer's Guide by Sourcery

This pull request enhances the todo functionality and error handling in the recon_note app. It introduces a template-based approach for creating and displaying todo items, improves error handling and user feedback, updates API endpoints with better validation, and enhances the UI with new icons and required fields. The changes span across JavaScript, Python, and HTML files, focusing on improving the overall user experience and code quality.

File-Level Changes

Change Details Files
Refactored JavaScript code for todo functionality
  • Implemented a template-based approach for creating todo items
  • Added new event listeners for various todo actions
  • Improved search functionality with local storage integration
  • Enhanced UI interactions and dynamic updates
web/recon_note/static/note/js/todo.js
Enhanced error handling and input validation in Python views
  • Added input validation for required fields in API views
  • Improved error responses with more detailed messages
  • Refactored view functions for better organization and error handling
web/recon_note/views.py
web/api/views.py
Updated HTML template for improved UI and accessibility
  • Added a hidden template for dynamic todo item creation
  • Updated UI elements with new icons and improved layout
  • Enhanced form inputs with validation attributes
web/recon_note/templates/note/index.html
Added CSS styles for new UI elements
  • Added styles for priority dropdown in todo items
web/static/custom/custom.css

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @psyray - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider optimizing the updateBadgeCounts() function to reduce potential performance impact, especially if it's called frequently.
  • Ensure that server-side validation is in place to complement the client-side validation for todo title and description.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

};

// Updated search function
const searchFunction = function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Optimize search function for performance

The searchFunction might be called frequently. Consider optimizing it, perhaps by debouncing the input or using more efficient DOM manipulation techniques.

const searchFunction = _.debounce(function() {
  const searchTerm = $('.input-search').val();
  const rex = new RegExp(searchTerm, 'i');
  // ... rest of the function
}, 300);

Copy link
Member

@AnonymousWP AnonymousWP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. A general but important suggestion though: please change it to 'to-do'. 'Todo' isn't a word at all.

web/static/custom/custom.css Outdated Show resolved Hide resolved
web/recon_note/static/note/js/todo.js Show resolved Hide resolved
- Updated key names in todo.js to ensure consistency with backend expectations.
- Adjusted CSS styles in todolist.css for better alignment and spacing.
- Updated various HTML templates and JavaScript files to standardize the terminology from "Todo" to "to-do".
… placeholder

- Updated test cases to include content_type='application/json' in POST requests.
- Modified error messages in AddReconNote view to remove checks for scan_history_id and subdomain_id.
- Corrected the placeholder text in the HTML input field for adding a to-do.
…x elements

- Simplified the logic for updating badge notifications in the todo list by consolidating repeated code into a single function.
- Removed unused checkbox elements from the todo item template and related HTML.
@AnonymousWP
Copy link
Member

It also misses two crucial things:

  1. There's no 'close' button anywhere:
    image
  2. You can't edit notes. Pretty much a must to me, if I'm going to be honest.

- Added a "Close" button to the modal footer in the note index template.
- Implemented functionality to hide the modal when the "Close" button is clicked.
@psyray
Copy link
Contributor Author

psyray commented Sep 16, 2024

It also misses two crucial things:

1. There's no 'close' button anywhere:

2. You can't edit notes. Pretty much a must to me, if I'm going to be honest.

Done for 1.
image

  1. will be done later

@AnonymousWP AnonymousWP merged commit 09b837a into release/2.1.0 Sep 16, 2024
5 checks passed
@AnonymousWP AnonymousWP deleted the 197-fix-todo-note branch September 16, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(note): Recon note system is completely buggy
2 participants