Shpigford / plylst

Smart playlists for Spotify! Stop relying on fancy pants algorithms to organize your library and instead build playlists the way you want.
https://plylst.app
MIT License
331 stars 52 forks source link

feat(playlist/genres): Allow in & contains #99

Closed jamischarles closed 4 years ago

jamischarles commented 4 years ago

Adds support for adding contains operator to genres rule. Now you can dogenres in [multi-select] and genres in [input]. Support for the latter is what this commit adds.

Solves #60 .

Happy path working: demo

The only bug I'm aware of (on edit page). See more details below the video: bug When you edit a playlist with a contains rule, it renders it with the operator on in (with the select dropdown), then switches to contains without firing any events (as far as I can tell). Very annoying. Simplest way to fix it is probably to call $("#builder").trigger('afterUpdateRuleOperator.queryBuilder', rule) after the page loads. That would auto-trigger the event handler and everything should re-render properly. Or in the rails template logic you could check for a "contains" rule for genres, and switch the genres filter config before the client side code runs.


This was a fun project. Would love to fix the bug, but it's been about 10 hrs and I need to step away from this.

First 2 hours was just getting re-acclimated to Rails & jQuery (it's been about 10 years). Other 8 hours was looking at various ways to make queryBuilder do what it didn't want to do. It basically fought me the whole time.

I'll leave more comments & details inline.

Related issues for helpful context: https://github.com/mistic100/jQuery-QueryBuilder/issues/688 https://github.com/mistic100/jQuery-QueryBuilder/issues/284

https://github.com/mistic100/jQuery-QueryBuilder/issues/688#issuecomment-385454539 is basically the technique I used but he's very vague with how to set up and tear down the plugins.

jamischarles commented 4 years ago

@Shpigford Prepping another PR to fix the edit page bug. Should be up in a few min.