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

Fixing enabling and disabling FileDownload #1834

Merged
merged 2 commits into from
Dec 13, 2020
Merged

Fixing enabling and disabling FileDownload #1834

merged 2 commits into from
Dec 13, 2020

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Dec 12, 2020

Fixes #1510 and #1820

There seems to have been two problems: The first problem is that Button do not have a value property and therefore give the "Uncaught TypeError: t is undefined" as mentioned in #1510 and here.
The second problem was that the change in disabled was not connected to the anchor element.

This is my first time trying to write code in TypeScript, so I think it would be very good if someone with more experience in TypeScript can take a look at it and test that I haven't done something wrong or if there is something which can be done better.

An example of the fix in action can be seen below:

from io import StringIO

import param
import panel as pn


class Download(param.Parameterized):
    enable = param.Action(lambda self: self._enable())
    disable = param.Action(lambda self: self._disable())

    def __init__(self, **params):
        super(Download, self).__init__(**params)
        self.fd = pn.widgets.FileDownload(callback=self.cb, filename='data.txt')
        self.fd.disabled = True

    def cb(self):
        return StringIO('foobar')

    def panel(self):
        return pn.Column(self.fd, *pn.Param(self.param, show_name=False))

    def _enable(self):
        self.fd.disabled = False

    def _disable(self):
        self.fd.disabled = True


dl = Download()
dl.panel().servable()

ezgif-7-a036f5dfebd8

@philippjfr philippjfr merged commit c1812af into holoviz:master Dec 13, 2020
@hoxbro hoxbro deleted the disable_download_button branch December 13, 2020 12:37
philippjfr pushed a commit that referenced this pull request Jan 14, 2021
* Fixing enable and disable file download

* Added comment
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

Successfully merging this pull request may close these issues.

Filedownload enable / disabe bug
2 participants