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

Add status filter to user's note page #5297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kcne
Copy link
Contributor

@kcne kcne commented Oct 30, 2024

Description

This PR partly addresses #832 and serves as a smaller alternative to #5255 as suggested in comments. It aims to enhance user experience on user note pages by providing filtering functionality for notes by status. The with_status scope is added to the Note model, and the NotesController is updated accordingly. Default behavior remains unchanged since the status preselected value is set to All by default.

How has this been tested?

Test for the new scope is added to note model test to ensure functionality is working as expected.

Screenshots

Screenshot 2024-10-30 at 22 07 56 Screenshot 2024-10-30 at 22 07 46

@kcne kcne force-pushed the 832-status-filter branch 2 times, most recently from 5670d46 to 0d0045e Compare October 31, 2024 08:06
@kcne kcne marked this pull request as ready for review October 31, 2024 08:55
Copy link
Member

@tomhughes tomhughes left a comment

Choose a reason for hiding this comment

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

In addition to the inline comment this could do with tests at the controller or system level rather than just testing the model method.

else
all
end
}
Copy link
Member

Choose a reason for hiding this comment

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

Rather than trying to handle the all case specially here I think I would make this much simpler, like the with_status on the issue model, and then add an unless params[:status] == "all" guard in the controller so that the filter isn't applied when all statuses are requested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we even need the scope? A similar scope for issues is not used by the issues controller:

@issues = @issues.where(:status => params[:status]) if params[:status].present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and updated the PR. Since this is the only place using the scope, I removed it to simplify the code and maintain consistency. If a need arises, we can reintroduce it later.

Also, I’ve added a test in the controller to cover the basic status filtering functionality. Let me know if further tests are needed.

@kcne kcne force-pushed the 832-status-filter branch 2 times, most recently from 5b87c90 to 337d37e Compare November 6, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants