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

Custom widgets for canned query forms #1090

Open
simonw opened this issue Nov 12, 2020 · 3 comments
Open

Custom widgets for canned query forms #1090

simonw opened this issue Nov 12, 2020 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Nov 12, 2020

This is an idea that was cut from the first version of writable canned queries:

I really want the option to use a <textarea> for a specific value.

Idea: metadata syntax like this:

{
    "databases": {
       "my-database": {
           "queries": {
               "add_twitter_handle": {
                   "sql": "insert into twitter_handles (username) values (:username)",
                   "write": true,
                   "params": {
                       "username": {
                            "widget": "textarea"
                       }
                   }
               }
           }
       }
    }
}

I can ship with some default widgets and provide a plugin hook for registering extra widgets.

This opens up some really exciting possibilities for things like map widgets that let you draw polygons.

Originally posted by @simonw in #698 (comment)

@simonw
Copy link
Owner Author

simonw commented Jan 24, 2021

Related: I built datasette-leaflet-freedraw which turns any canned query field called freedraw or something_freedraw into an interactive map that you can draw on to create a GeoJSON MultiPolygon.

@simonw simonw added the plugins label Jan 24, 2021
@simonw
Copy link
Owner Author

simonw commented Mar 27, 2021

Idea for these: imitate https://django-sql-dashboard.readthedocs.io/en/latest/widgets.html#custom-widgets and drive them with templates.

So a custom widget type of textarea would look for a template called widgets/textarea.html - which means users could define brand new custom widgets just by creating their own template files.

@simonw
Copy link
Owner Author

simonw commented Mar 27, 2021

Related feature request: ability to set default values for canned queries: #1258

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

1 participant