[web] Make the time separator configurable in JQueryDateTimePicker
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 09 Jul 2019 14:20:30 +0200
changeset 12680 30a98fd4ce31
parent 12672 2c7499bc675b
child 12681 42afaaf708d8
[web] Make the time separator configurable in JQueryDateTimePicker We add a "separator" argument to JQueryDateTimePicker which will be used when creating the underlying JQueryTimePicker instance so that the user can control how time is displayed by the widget. This is very similar to the "timesteps" argument that's already present.
cubicweb/web/formwidgets.py
--- a/cubicweb/web/formwidgets.py	Wed Jun 26 13:19:30 2019 +0200
+++ b/cubicweb/web/formwidgets.py	Tue Jul 09 14:20:30 2019 +0200
@@ -755,10 +755,11 @@
     :class:`JQueryTimePicker` widgets to define a date and time picker. Will
     return the date and time as python datetime instance.
     """
-    def __init__(self, initialtime=None, timesteps=15, **kwargs):
+    def __init__(self, initialtime=None, timesteps=15, separator=u':', **kwargs):
         super(JQueryDateTimePicker, self).__init__(**kwargs)
         self.initialtime = initialtime
         self.timesteps = timesteps
+        self.separator = separator
 
     def _render(self, form, field, renderer):
         """render the widget for the given `field` of `form`.
@@ -784,7 +785,7 @@
                 timestr = req.format_time(self.initialtime)
         datepicker = JQueryDatePicker(datestr=datestr, suffix='date')
         timepicker = JQueryTimePicker(timestr=timestr, timesteps=self.timesteps,
-                                      suffix='time')
+                                      separator=self.separator, suffix='time')
         return u'<div id="%s">%s%s</div>' % (field.dom_id(form),
                                              datepicker.render(form, field, renderer),
                                              timepicker.render(form, field, renderer))