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 story filter feature #168

Merged
merged 2 commits into from
Jan 10, 2022
Merged

Add story filter feature #168

merged 2 commits into from
Jan 10, 2022

Conversation

mateusdeap
Copy link
Member

@mateusdeap mateusdeap commented Dec 10, 2021

Description:

This PR adds a search bar at the top of the stories table that allows us to filter the stories by their names, using a debounce function @fbuys graciously taught me to implement.

I believe there might be some usability questions so I'd be grateful for some feedback in that area.

So, before, we had this:
image

And here's the search bar:
image

Should this be merged, it closes #49


I will abide by the code of conduct.

@mateusdeap mateusdeap requested review from arielj and fbuys December 10, 2021 22:45
@mateusdeap mateusdeap requested a review from a team as a code owner December 10, 2021 22:45
@mateusdeap mateusdeap requested review from bronzdoc and lubc and removed request for a team December 10, 2021 22:45
@mateusdeap mateusdeap force-pushed the feature/filter-stories branch from d8c0c5b to b4ba298 Compare December 10, 2021 23:15
@mateusdeap mateusdeap changed the title Feature/filter stories Add story filter feature Dec 10, 2021
@mateusdeap
Copy link
Member Author

So the build is failing when it runs bundle update rails for the next rails version. However, I tried running the same command locally and it worked fine. On monday I'll try to debug what might be going on.

@kindoflew
Copy link
Contributor

hey @mateusdeap! should we add WIP to the title in the meantime or do you think it'll be a quick fix? thanks!

@mateusdeap
Copy link
Member Author

I believe you're right @kindoflew. I'm not really sure whether this is a quickfix or not.

@mateusdeap mateusdeap added the WIP label Dec 14, 2021
Copy link
Contributor

@fbuys fbuys left a comment

Choose a reason for hiding this comment

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

It seems like we should replace app/views/projects/_project_table.html.erb with app/views/projects/_stories_table.html.erb?

Could we potentially hide the search bar while it is not being used?
Perhaps similar to how the export settings are hidden.

I tested it locally and it seems to work really well. 🚀

@@ -59,8 +59,13 @@ def destroy

def show
@project = Project.find(params[:id])
@stories = @project.stories.by_position.includes(:estimates)
@q = @project.stories.by_position.includes(:estimates).ransack(params[:q])
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think calling it query would add any clarity?

Suggested change
@q = @project.stories.by_position.includes(:estimates).ransack(params[:q])
@query = @project.stories.by_position.includes(:estimates).ransack(params[:q])

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say to call it stories as it was before, since it's querying stories, q or query are too generic

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case might be better to call it stories, but I have to add a call to .result at the end. Or we can just change it to @query, since I assign @stories in the line below

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, query.result reads better than stories.result And then you assign to @stories like you said.

</table>
<%= search_form_for @q, url: project_path(id: @project.id) do |f| %>
<div class="field">
<%= f.label :title_cont, "Filter by title" %>
Copy link
Contributor

Choose a reason for hiding this comment

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

What does :title_cont stand for?

Copy link
Member Author

@mateusdeap mateusdeap Dec 15, 2021

Choose a reason for hiding this comment

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

That's how ransack matches fields. Here they explain what suffixes we can add. In this case it just means title contains

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.

I think it would be better to map something like search_term to title_cont in the backend.
I might be wrong, but it seems like we are putting some implementation details that don't belong in a view here.

I think a future developer might not understand what _cont stands for and making it more explicit could be useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just read Ariel's response, so we can ignore my reply above :-)

</tfoot>

</table>
<%= search_form_for @q, url: project_path(id: @project.id) do |f| %>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should try to add local: false?

Suggested change
<%= search_form_for @q, url: project_path(id: @project.id) do |f| %>
<%= search_form_for @q, url: project_path(id: @project.id), local: false do |f| %>

Right now I can hit enter/return and it reloads the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely

Copy link
Contributor

@arielj arielj left a comment

Choose a reason for hiding this comment

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

Is this only searching on the title? if so maybe we can have an implementation to filter the table in place with javascript?

since we have no pagination or anything, filter in place should be simple (go over all the rows and hide any row that doesn't match the search term) and then we don't need ransack or an ajax request

if we keep the server filtering, do we need ransack for this? I'd say to just use a simple where("title LIKE :q OR description LIKE :q", "%#{params[:q]}%") (it can be a named scope in Story also), so we don't have an extra gem for something like this, ransack is more useful when we need to do comples searches with variable fields and such, but I think it's overkill for this

@mateusdeap
Copy link
Member Author

@arielj Thanks for the suggestion. I'll go for an implementation then. I just used ransack because I was used to it from the past hahaha

@fbuys Only now I noticed that both files were kept. I wanted to have only a projects_table since that was more in line with all the classes in the divs and whatnot. But, originally, I had made it a stories_table because that's what it was. What would be your take on this?

@mateusdeap mateusdeap force-pushed the feature/filter-stories branch 3 times, most recently from 535ed08 to 7f38029 Compare December 16, 2021 19:54
@mateusdeap
Copy link
Member Author

Still pending advice on the UX for this. @arielj already shared his thoughts, but I want to wait for a bit more. Fixed many issues and the filtering is now done in the frontend.

@mateusdeap mateusdeap force-pushed the feature/filter-stories branch 2 times, most recently from a2ea6c3 to 2d6a210 Compare January 3, 2022 14:32
@mateusdeap mateusdeap requested review from arielj and fbuys January 3, 2022 14:33
Copy link
Contributor

@arielj arielj left a comment

Choose a reason for hiding this comment

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

Looks good to me, I think the input should be aligned to the right instead of using the full width of the screen

I'm looking at this design
image

though that would break a feature (having the add story button always visible) unless we make that part also sticky like the table header which feels weird to me

I'd say to just move the input to the right side (but above the add story / delete buttons, not inline)

@mateusdeap
Copy link
Member Author

@arielj It would? Is it not possible to implement that design without hiding the add_story button? Not sure I got that part. But I completely forgot about this design discussion hahaha Will work on it in the afternoon

@natsubau
Copy link

natsubau commented Jan 4, 2022

@arielj, I think adding the buttons and search to the sticky area would be fine, not weird. I think it would just be different to what has been there for a while. Is there a specific reason you think it would be weird?

@mateusdeap mateusdeap force-pushed the feature/filter-stories branch from 2d6a210 to 3d4f11c Compare January 4, 2022 21:00
@mateusdeap mateusdeap requested a review from arielj January 4, 2022 21:01
@arielj
Copy link
Contributor

arielj commented Jan 4, 2022

Sorry, what I mean is that we already have the table header sticky at the top and we were using that space to keep the Add story button always visible. If we move the Add story button above the header we'll have to make 2 things sticky: the search+button and the table header. I imagine a lot of empty spaces used by both sticky elements (empty space at the left of the search, empty space on the last column header). Or do you imagine the search+button and the table header overlapping in the same space? or something different? maybe I'm just imagining something different, an example of the scrolled design with how the sticky elements look would be great (though don't consider this is a priority or anything over other projects).

Anyway, doing that change involves extra css and html changes, for 2 sticky elements to work together we'll have to change some things that I think may be outside of the scope of this story, we can handle the position of the search field in this one and moving the buttons in another story too.

Or maybe the Add story button should be in a different place completely. We wanted it to be always visible because it's the most used action.

I think it's a good idea to rethink the position of everything in this app though. Maybe it's something to plan over the year?

Copy link
Contributor

@arielj arielj left a comment

Choose a reason for hiding this comment

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

this looks good to me

@lubc lubc added Ready to QA This PR is ready to be tested in staging and removed WIP labels Jan 7, 2022
@lubc lubc requested a review from kaysiz January 7, 2022 20:57
@lubc
Copy link
Contributor

lubc commented Jan 7, 2022

@kaysiz hey could you please QA this PR? Thank you!

Copy link
Contributor

@kaysiz kaysiz left a comment

Choose a reason for hiding this comment

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

Looks good!

@kindoflew kindoflew merged commit 73dccc2 into main Jan 10, 2022
@kindoflew kindoflew deleted the feature/filter-stories branch January 10, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to QA This PR is ready to be tested in staging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to Filter/Search stories
7 participants