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

Add directory upload and clear input to FileInput #13873

Draft
wants to merge 2 commits into
base: branch-3.5
Choose a base branch
from

Conversation

hoxbro
Copy link
Contributor

@hoxbro hoxbro commented May 6, 2024

All pull requests must have an associated issue in the issue tracker. If there
isn't one, please go open an issue describing the defect, deficiency or desired
feature. You can read more about our issue and PR processes in the
wiki.

This is WIP.

Personally todos:

  • Add tests
  • Update Python docstrings with more information
  • Some design questions (I will leave those as comments in the code)

Current test script:

from bokeh.models import FileInput, Button
from bokeh.io import curdoc

file_input = FileInput(directory=True)
button = Button(label="Clear file input")
button.on_click(lambda *e: setattr(file_input, "_clear_input",  file_input._clear_input + 1))

curdoc().add_root(file_input)
curdoc().add_root(button)
screenrecord-2024-05-06_15.51.00.mp4

value: [ Or(Str, List(Str)), p.unset, {readonly: true} ],
mime_type: [ Or(Str, List(Str)), p.unset, {readonly: true} ],
filename: [ Or(Str, List(Str)), p.unset, {readonly: true} ],
accept: [ Or(Str, List(Str)), "" ],
multiple: [ Bool, false ],
directory: [ Bool, false ],
_clear_input: [ Int, 0],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not the final design (I hope).

I need help figuring out how to tell the input to be cleared from Python to BokehJS. Can an event be used?

One of the problems, at least for me, is that value is read-only from the Python side.

mime_types.push(mime_type)
if (directory) {
const ext = file.name.split(".").pop()
if ((!is_nullish(accept) && isString(ext)) ? accept.includes(`.${ext}`) : true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check will likely need some more thought.

What comes to mind is that it should also check the mime_type.

@mattpap mattpap added this to the 3.5 milestone May 6, 2024
@mattpap mattpap changed the title [WIP] Add directory upload and clear input to FileInput Add directory upload and clear input to FileInput May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Support directory upload and clearing inputs from Python for FileInput widget
2 participants