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

feat: Rewrite partner filter #2561

Merged
merged 25 commits into from
Aug 26, 2024
Merged

feat: Rewrite partner filter #2561

merged 25 commits into from
Aug 26, 2024

Conversation

kimadactyl
Copy link
Member

@kimadactyl kimadactyl commented Aug 15, 2024

Rewritten Partner filter using Stimulus and view_component.

Screen.Recording.2024-08-22.at.16.01.18.mov

Progress

  • Started migration to view_component
  • Made clicking label tags select the radio buttons
  • Make filter work
  • Remove old mountain view code
  • Rewire up routes
  • Reset/exclude/include functionality
  • Fix tests
  • Deal with both menus being open better (they just overlay rn)
  • Make width of dropdown set based on contents rather than magic number
  • Make partners reload in turbo frame rather than triggering page reload

I have removed the exclude functionality as it's too confusing and wasn't working properly anyway.

Left to do

  • Refactor menu dropdown JS and remove old file
  • Final CSS tweaks
  • Consider how the reset UI works

Future improvements

  • The eagle-eyed might note that this sacrifices some performance for maintainability and clarity of code by doing 2 simpler database queries instead of 1 very convoluted one (that doesn't work). I don't think this will have any real performance implications but obviously ideally we would get it back to 1.
  • This should be a select box not radio buttons. Mark's new design has a layout for this but I think best to leave this to a future ticket.
  • Add in testing - the tests present clearly don't work and I'm concerned that our integration tests in general are neither stopping bugs creep in nor helping to document desired behaviour, so rn it seems like more harm than good.
  • Store javascript and css with components #2562 - I don't know why this isn't set up already but I've done my best to untangle some things without fully getting into it

Fixes #2544
Fixes #2081
Fixes #2087
Fixes #1780
Fixes #1906

  • "If there are no results from a partner filter, there is some text indicating no partners found" - should now be impossible

@kimadactyl kimadactyl marked this pull request as ready for review August 16, 2024 19:47
@kimadactyl kimadactyl requested a review from katjam August 16, 2024 19:47
<div class="preview__details">
<%= content_tag :p, description %>
<%= content_tag :p, @partner.summary %>
<!-- Categories: <%= @partner.categories.map(&:name).join(", ") %> -->
Copy link
Member Author

Choose a reason for hiding this comment

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

Leaving this in for debugging purposes in the future

@kimadactyl
Copy link
Member Author

kimadactyl commented Aug 19, 2024

added a turbo frame - speeds up performance significantly by only updating the changed content

Screen.Recording.2024-08-19.at.14.52.09.mov

@kimadactyl
Copy link
Member Author

kimadactyl commented Aug 19, 2024

Unfortunately I had to take out turbo loading as I can't work out how to get the filter options to reload properly when selected, so I'm leaving that for another ticket - this one is already big enough. Leaving in how to do it commented out as it nearly works I just can't get it over the line.

I've tidied up the CSS, made it set the width dynamically, and hopefully made it easier to read. The width between the two is not dynamically set though, so future improvement for someone.

Screenshot 2024-08-19 at 15 42 57

@kimadactyl
Copy link
Member Author

All working! Original post updated with info about status. I would like to merge this now and then start tackling some of the structural problems, like the state of the components folder, before improving this further.

this.submitForm();
}

toggleCategory() {
Copy link
Member Author

Choose a reason for hiding this comment

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

this should be spun into its own stimulus controller but waiting on sorting the components directory out first

Copy link
Member

@katjam katjam left a comment

Choose a reason for hiding this comment

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

A few comments and questions - but I think let's give this a go and do some thorough verifying once it's on staging.

@@ -1,16 +1,18 @@
<li class="preview">
<div class="preview__header">
<h3><%= link_to name, link %></h3>
<% if show_service_area? || show_neighbourhood? %>
Copy link
Member

Choose a reason for hiding this comment

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

Just checking since the code is a little scattered - we've not removed showing of service area it's just that it is now incorporated into the neighbourhood property?

Copy link
Member Author

@kimadactyl kimadactyl Aug 26, 2024

Choose a reason for hiding this comment

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

a partner can have a neighbourhood 2 ways: either because of its address, or because of its service area :)

i think for sure the partner.rb file should do a better job of explaning its API

Copy link
Member

Choose a reason for hiding this comment

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

Is there a setting that this is checking on the partner - for whether they want their address / service area to be visible?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think it prioritises service area if set and address if not, assumption is that if a service area is set, its not being delivered at the address. again - we should have cucumber tests for this.


updateLabels() {
// Find the associated label for each selected param and get the text contents
// If params are selected, they show up instead of "Category" and "Neighbourhood" text
Copy link
Member

Choose a reason for hiding this comment

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

I found this confusing in the UI. but I guess it's a way to show something is selected and can only select one thing at a time from each list now, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes - i think we need to replace this whole thing with a <select> box - its in marks' new design but obvi getting v out of scope

Copy link
Member

Choose a reason for hiding this comment

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

Agree. Do we bother making sure there's an issue for future us? Or will it naturally arise?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think its covered under #1812

@kimadactyl kimadactyl enabled auto-merge (squash) August 26, 2024 16:24
@kimadactyl kimadactyl merged commit e1cdf3e into main Aug 26, 2024
2 checks passed
@kimadactyl kimadactyl deleted the refactor-partner-filter branch August 26, 2024 16:26
@kimadactyl
Copy link
Member Author

working on staging

Screen.Recording.2024-09-02.at.19.01.46.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment