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

Feature idea: ability to pass chore input values via URL query parameters on an opt-in basis as part of the inputs options spec. #13

Open
sherbondy opened this issue Jul 21, 2023 · 0 comments

Comments

@sherbondy
Copy link

sherbondy commented Jul 21, 2023

Hey Chris & co,

Love the library and have found it invaluable to create custom one-off admin job tooling with papertrail and the likes baked in.

One little feature idea we had recently was to make it possible to pass in chore input values via URL query string params, as this would allow us to set up nicely deep-linked shortcuts to open a chore from another admin page with some job details pre-filled.

Example use-case:

If we have some admin page with a list of users, and need to run a one-off chore for a particular user, amazing to be able to link to the relevant chore job with the user's id input argument pre-filled in the chore, to avoid us making one-off copy-pasta mistakes when running the job.

Would be great to be able to opt-in as part of the chore inputs options DSL, which ones we want to be pre-fillable via query parameter.

Then from the chore URL in the route, the values for those inputs could be pre-filled based on the decoded corresponding query param from the URL.

Concrete example, say I have a chore called TopupUserPointsBalance and it takes a user_id as one of its inputs.

In the inputs DSL I could specify eg (placeholder name proposal of a new allow_query_param option to specify opt-in to this behavior, although I personally wouldn't mind if it was default supported for all input fields that are expressible in query params!):

  def inputs,
    do: [
      string(:user_id, validators: [&check_user_id/1], allow_query_param: true),
    ]

Then say my chore runner route is specified as /chores/, I could visit this URL then to have the user_id input pre-filled on the job:

/chores?chore=TopupUserPointsBalance&user_id=the_user_id

to have the_user_id prefilled in the user_id input field.

Thanks & LMK if you / others would see value in this addition!

Understand the project cannot take PRs directly due to licensing/corporate constraints, but would still be happy to contribute a reference PR if this would be helpful.

Think possible to keep the changes very narrowly scoped with a small helper fn addition to ChoreLive and the Input.input_options spec.

All the best & thanks again for sharing this project with the broader community,
Ethan

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

No branches or pull requests

1 participant