-
Notifications
You must be signed in to change notification settings - Fork 921
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
Conversation
5670d46
to
0d0045e
Compare
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.
In addition to the inline comment this could do with tests at the controller or system level rather than just testing the model method.
app/models/note.rb
Outdated
else | ||
all | ||
end | ||
} |
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.
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.
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.
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? |
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.
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.
337d37e
to
b56dc10
Compare
app/views/notes/index.html.erb
Outdated
@@ -6,6 +6,20 @@ | |||
:commented => tag.span(t(".subheading_commented"), :class => "px-2 py-1 bg-body") %></p> | |||
<% end %> | |||
|
|||
<%= form_with :url => url_for(:controller => "notes", :action => "index"), :method => :get, :data => { :turbo => true } do %> |
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.
Why :url => url_for(:controller => ...)
and not :url => user_notes_path(@user)
?
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.
Missed this one. Refactored. Thank you.
app/views/notes/index.html.erb
Outdated
:class => "form-select" %> | ||
</div> | ||
<div class="col-sm-auto mb-3"> | ||
<%= submit_tag t(".apply"), :class => "btn btn-primary" %> |
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.
We have this in issues search form to avoid adding &commit=...
to urls:
<%= submit_tag t(".apply"), :class => "btn btn-primary" %> | |
<%= submit_tag t(".apply"), :name => nil, :class => "btn btn-primary" %> |
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.
Couldn't realize why this was happening, I didn't like it either. Fixed now. Thank you.
b56dc10
to
738e66a
Compare
Merged, thanks. |
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 theNote
model, and theNotesController
is updated accordingly. Default behavior remains unchanged since the status preselected value is set toAll
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