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

Show foreign key label when filtering #1696

Open
simonw opened this issue Mar 30, 2022 · 2 comments
Open

Show foreign key label when filtering #1696

simonw opened this issue Mar 30, 2022 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Mar 30, 2022

For example here:

image

3 corresponds to "Human Related: Other" - it would be neat to display this in this area of the page somehow.

@simonw
Copy link
Owner Author

simonw commented Mar 30, 2022

Maybe like this:

image

<h3>283 rows
  where dcode = 3 <span style="color: #aaa; font-size: 0.9em">(Human Related: Other)</span>
    </h3>

@cldellow
Copy link
Contributor

I did some horrible things in cldellow/datasette-ui-extras#2 to enable this in my plugin -- example here: https://dux-demo.fly.dev/cooking/posts?_facet=owner_user_id&owner_user_id=67

The implementation relies on two things:

  • a filters_from_request hook that adds a good human description (unfortunately, without the benefit of the CSS styling you mention)
  • doing something evil to hijack the exact and not operators in the Filters class. We can't leave them as is, or we'll get 2 human descriptions -- the built-in Datasette one and the one from my plugin. We can't remove them, or the filters UI will stop supporting the = and != operators

This got me thinking: it'd be neat if the list of operators that the filters UI supported wasn't a closed set.

A motivating example: adding a geospatial NEAR operator. Ideally it'd take two arguments - a target point and a radius, so you could express a filter like find me all rows whose lat/lng are within 10km of 43.4516° N, 80.4925° W. (Optionally, the UI could be enhanced if the geonames database was loaded and queried, so a user could say find me all rows whose lat/lng are within 10km of Kitchener, ON, and the city gets translated to a lat/lng for them)

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

No branches or pull requests

2 participants