manager: switch time selection to the html5 time input widget (#13603)
This commit is contained in:
parent
12d99d5193
commit
86861aa28f
|
@ -130,27 +130,18 @@ class DateTimeWidget(PickerWidgetMixin, DateTimeInput):
|
||||||
super(DateTimeWidget, self).__init__(attrs, options, usel10n)
|
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
|
TimeWidget is a widget for time selection, it uses the HTML5 "time"
|
||||||
datetime picker.
|
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'
|
def __init__(self, **kwargs):
|
||||||
glyphicon = 'glyphicon-time'
|
super(TimeWidget, self).__init__(**kwargs)
|
||||||
|
self.attrs['step'] = '300' # 5 minutes
|
||||||
def __init__(self, attrs=None, options=None, usel10n=None):
|
self.attrs['pattern'] = '[0-9]{2}:[0-9]{2}'
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
class WeekdaysWidget(SelectMultiple):
|
class WeekdaysWidget(SelectMultiple):
|
||||||
|
|
Loading…
Reference in New Issue