From b0118a7091bf74acd9c183600267f04b018fff1a Mon Sep 17 00:00:00 2001 From: Andrew <15331990+ahuang11@users.noreply.github.com> Date: Mon, 10 Aug 2020 22:41:01 -0500 Subject: [PATCH] Enabled disabled dates (#1524) * Allow embedding local file * Remove is_url check * Reverse logic * Add disabled_dates and enabled_dates to DatePicker * Add docs Co-authored-by: ahuang11 --- examples/reference/widgets/DatePicker.ipynb | 2 ++ panel/widgets/input.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/reference/widgets/DatePicker.ipynb b/examples/reference/widgets/DatePicker.ipynb index 6a4514fbde..2766019c79 100644 --- a/examples/reference/widgets/DatePicker.ipynb +++ b/examples/reference/widgets/DatePicker.ipynb @@ -31,6 +31,8 @@ "\n", "* **``disabled``** (boolean): Whether the widget is editable\n", "* **``name``** (str): The title of the widget\n", + "* **``disabled_dates``** (list): dates to make unavailable for selection; others will be available\n", + "* **``enabled_dates``** (list): dates to make available for selection; others will be unavailable\n", "\n", "___" ] diff --git a/panel/widgets/input.py b/panel/widgets/input.py index 1e4e1aeacf..34cbe7ccf5 100644 --- a/panel/widgets/input.py +++ b/panel/widgets/input.py @@ -8,7 +8,7 @@ import json from base64 import b64decode -from datetime import datetime +from datetime import datetime, date from six import string_types import param @@ -137,6 +137,10 @@ class DatePicker(Widget): end = param.CalendarDate(default=None) + disabled_dates = param.List(default=None, class_=(date, str)) + + enabled_dates = param.List(default=None, class_=(date, str)) + _source_transforms = {'value': None, 'start': None, 'end': None} _rename = {'start': 'min_date', 'end': 'max_date', 'name': 'title'}