2023-12-01

Goal

Sort tasks so that checked in tasks are top ranked, unchecked tasks are in the middle, and completed tasks are put at the bottom of the page. Prevent users from resetting tasks that are already in the ready state.

Notes

Sort tasks by State

I started today by sorting the tasks in order of

1) Checked in tasks 2) Incomplete tasks 3) Complete tasks

This is easy enough with the Django QuerySet object in the Django View section of the Taskmaster App. Specifically, I can adjust the order_by argument in the get_queryset_by_user method of the TaskListView, making the returned value: Task.objects.filter(created_by=username).order_by('is_complete', '-is_checked_in')

So that was easy to implement. I decided to Git commit these changes then move on to the next goal.

Prevent users from Resetting unchecked / incomplete tasks

I don't want a user to refresh a task that hasn't been checked in or completed, so I wanted to add a way to prevent unnecessary refreshing (refreshment?). I decided to use this shake animation to shake the lil arrow when a user cannot refresh their task. I ended up using a Logical AND to check that both buttons were enabled and if they were then the function would return nothing and end the code before executing the AJAX command for a POST request. This worked as intended on first refresh, but if the user checked in then reset again it played the incorrect animation.

ChatGPT let me know that I needed to manually bind the newly cloned refresh arrow to the document by using

$(document).on('click', '.refresh-arrow', function()

instead of

$('.refresh-arrow').click(function()

but that didn't work. ChatGPT suggested the following logic which mostly worked:

(checkInButton.length > 0 && completeButton.length > 0 && !checkInButton[0].disabled && !completeButton[0].disabled)

Either way I'll add it to Issues Pending and solve it later because it still applies the POST request, it just doesn't play the correct animation for the arrow.

Either way I accomplished both of my goals for the day! Since I didn't get much sleep last night I'm going to try and get some rest before work but I'm glad I got this out of the way!

Results

  • Sorted tasks to surface most relevant tasks to the top of the page by ordering the Django QuerySet object
  • Added a failure to refresh animation in CSS

Next Time

  • Implement auto-reset on tasks based on timezone
  • Add functionality to alter other parts of an individual task (whether it's private or public, whether it has been retired, etc.)
  • Add ability to create new tasks to the UI
  • Add ability for user to download their tasks from the site

Previous Note 2023-11-30 Next Note 2023-12-02