manager: switch time selection to the html5 time input widget (#13603)

This commit is contained in:
Frédéric Péters 2018-11-13 21:33:55 +01:00
parent 12d99d5193
commit 86861aa28f
1 changed files with 9 additions and 18 deletions

View File

@ -130,27 +130,18 @@ class DateTimeWidget(PickerWidgetMixin, DateTimeInput):
super(DateTimeWidget, self).__init__(attrs, options, usel10n)
class TimeWidget(PickerWidgetMixin, TimeInput):
class TimeWidget(TimeInput):
"""
TimeWidget is the corresponding widget for Time field, it renders only the time section of
datetime picker.
TimeWidget is a widget for time selection, it uses the HTML5 "time"
input type and has a bit of a fallback mechanism with the presence
of the pattern attribute in case a standard text input is used.
"""
input_type = 'time'
format_name = 'TIME_INPUT_FORMATS'
glyphicon = 'glyphicon-time'
def __init__(self, attrs=None, options=None, usel10n=None):
if options is None:
options = {}
# Set the default options to show only the timepicker object
options['startView'] = options.get('startView', 1)
options['minView'] = options.get('minView', 0)
options['maxView'] = options.get('maxView', 1)
options['format'] = options.get('format', 'hh:ii')
super(TimeWidget, self).__init__(attrs, options, usel10n)
def __init__(self, **kwargs):
super(TimeWidget, self).__init__(**kwargs)
self.attrs['step'] = '300' # 5 minutes
self.attrs['pattern'] = '[0-9]{2}:[0-9]{2}'
class WeekdaysWidget(SelectMultiple):