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

Merged
merged 1 commit into from
Nov 18, 2024

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 3 times, most recently from 337d37e to b56dc10 Compare November 6, 2024 15:49
@kcne kcne requested a review from tomhughes November 7, 2024 08:54
@@ -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 %>
Copy link
Collaborator

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)?

Copy link
Contributor Author

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.

:class => "form-select" %>
</div>
<div class="col-sm-auto mb-3">
<%= submit_tag t(".apply"), :class => "btn btn-primary" %>
Copy link
Collaborator

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:

Suggested change
<%= submit_tag t(".apply"), :class => "btn btn-primary" %>
<%= submit_tag t(".apply"), :name => nil, :class => "btn btn-primary" %>

Copy link
Contributor Author

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.

@AntonKhorev AntonKhorev added the notes Related to the notes feature label Nov 13, 2024
@kcne kcne force-pushed the 832-status-filter branch from b56dc10 to 738e66a Compare November 18, 2024 14:22
@AntonKhorev AntonKhorev merged commit a25b795 into openstreetmap:master Nov 18, 2024
22 checks passed
@AntonKhorev
Copy link
Collaborator

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes Related to the notes feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants