@@ -227,71 +227,74 @@ defusedxml.
227227Enable use of native date inputs (optional)
228228-------------------------------------------
229229
230- Roundup now uses native date or datetime-local inputs for Date()
231- properties. These inputs take the place of the text input and
232- calendar popup from earlier Roundup versions. Modern browsers
233- come with a built-in calendar for date selection, so the
234- ``(cal)`` calendar link is no longer needed. These native inputs
235- show the date based on the browser's locale and translate terms
236- into the local language.
237-
238- If you do nothing, simple uses of the field() method will
239- generate date inputs to allow selection of a date. Input fields
240- for Date() properties will not have the ``(cal)`` link
241- anymore. Complex uses will not be upgraded and will operate like
242- earlier Roundup versions.
243-
244- To upgrade all date properties, there are four changes to make:
245-
246- 1. Replace ``field`` calls with ``field_time`` where needed.
247-
248- 2. Remove the format argument from field() calls on Date()
230+ Roundup now can use native ``date`` or ``datetime-local`` inputs for
231+ ``Date()`` properties. These inputs take the place of the text input and
232+ calendar popup from earlier Roundup versions. Modern browsers come with
233+ a built-in calendar for date selection, so the ``(cal)`` calendar link
234+ is no longer needed. These native inputs show the date based on the
235+ browser's locale and translate terms into the local language.
236+
237+ Note that the date format is tied to the language setting in most
238+ browsers, with some browsers you need special configurations to make the
239+ browser use the operating system date format.
240+
241+ By default the old input mechanism (using type=text inputs) is used.
242+ To enable native date input you need to set the config variable ::
243+
244+ use_browser_date_input = yes
245+
246+ in section ``[web]`` in the ``config.ini`` file.
247+
248+ If native date input is used, simple uses of the ``field()`` method will
249+ generate ``datetime-local`` inputs to allow selection of a date and time.
250+ Input fields for ``Date()`` properties will not have the ``(cal)`` link
251+ anymore. If fields should only use a date (without time) you can specify
252+ the parameter ``display_time=no`` in ``schema.py`` for a ``Date()``
253+ property (the default is ``yes``). This will use ``date`` inputs in the
254+ generated html to select a date only. If you need this only for a single
255+ date, the ``field()`` method now has a boolean parameter
256+ ``display_time`` (which by default is set to the ``display_time``
257+ parameter of ``Date()``)
258+
259+ Complex uses using a ``format`` specification in ``field()`` will not be
260+ upgraded and will operate like earlier Roundup versions. In addition the
261+ ``format`` can now also be specified in the ``Date()`` constructor.
262+
263+ To upgrade all date properties, there are five changes to make:
264+
265+ 1. Configure ``use_browser_date_input = yes`` in section ``[web]`` in
266+ ``config.ini``
267+
268+ 2. Optionally add ``display_time = no`` in the schema for Date()
269+ properties that should have no time displayed
270+
271+ 3. Remove the format argument from field() calls on Date()
249272 properties.
250273
251- 3. Remove popcal() calls.
274+ 4. Remove popcal() calls.
275+
276+ 5. Include datecopy.js in page.html.
252277
253- 4. Include datecopy.js in page.html.
278+ The ``display_time`` option
279+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
254280
255- Use field_time() where needed
256- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281+ Both the ``Date()`` constructor and the ``field`` call take a
282+ ``display_time`` option which by default is ``yes`` in the ``Date()``
283+ constructor and ``True`` in ``field``. The ``display_time`` setting of
284+ ``Date()`` is inherited by the html property, so it doesn't need to be
285+ specified in each ``field()`` call for this property.
257286
258- The format used by ``field`` does not include hours, minutes or
259- seconds. If your users need to enter times, you should change
260- these calls to use ``field_time``. The arguments are the same as
261- for field.
287+ When ``display_time`` is off, the date field does not include hours,
288+ minutes or seconds.
262289
263290Remove format argument
264291~~~~~~~~~~~~~~~~~~~~~~
265292
266- Speaking of arguments, avoid setting the date format if you want
267- to use native date inputs. The date value needs a specific format
268- for date or datetime-local inputs. If you include the `format`
269- argument in the `field` method, it should be removed.
270-
271- The `field` method uses the format ``%Y-%m-%d``. The
272- ``field_time`` method uses the format ``%Y-%m-%dT%H:%M:%S``. If
273- you use these exact formats, Roundup will accept them and use a
274- native date input.
275-
276- .. highlight:: text
277-
278- If you use an format that doesn't match, you will see a text
279- input and a logged warning message like::
280-
281- Format '%Y-%m' prevents use of modern date input.
282- Remove format from field() call in template test.item.
283- Using text input.
284-
285- .. highlight:: default
293+ Speaking of arguments, avoid setting the date ``format`` if you want to
294+ use native date inputs. If you include the `format` argument in the
295+ `field` method, it should be removed.
286296
287- The log message will appear if your logging level is set to
288- WARNING or lower. (Refer to your tracker's :ref:`config.ini
289- logging section <config-ini-section-logging>` for details on
290- logging levels.)
291-
292- If you want to use a text input for a specific date format, you
293- can add ``type="text"`` to the field() argument list to suppress
294- the warning. By default using a format argument will show the
297+ By default using a format argument will show the
295298popup calendar link. You can disable the link by setting
296299``popcal=False`` in the field() call. If you have::
297300
@@ -301,38 +304,26 @@ popup calendar link. You can disable the link by setting
301304changing it to::
302305
303306 tal:content="structure python:context.duedate.field(
304- type='text',
305307 placeholder='YYYY-MM, format='%Y-%m',
306308 popcal=False)"
307309
308310will generate the input as in Roundup 2.4 or earlier without a
309311popcal link.
310312
311- .. _revert_input_to_text:
312-
313- If you are using a path expression like::
314-
315- tal:content="context/duedate/field"
316-
317- change it to::
318-
319- tal:content="structure python:context.duedate.field(
320- type='text')"
321-
322- to get the input from before Roundup 2.5 with a popcal link.
323-
324313Remove popcal
325314~~~~~~~~~~~~~
326315
327- If you use the ``popcal()`` method directly in your templates, you
328- can remove them. The browser's native date selection calendar can
316+ if you have enabled date input types in the configuration and you
317+ use the ``popcal()`` method directly in your templates, you
318+ should remove them. The browser's native date selection calendar should
329319be used instead.
330320
331321Add copy/paste/edit on double-click using datecopy.js
332322~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333323
334- There is no way to copy/paste using a native datetime-local or
335- date input. With the datecopy.js file installed, double-clicking
324+ When using date input types,
325+ there is no way to copy/paste using a native ``datetime-local`` or
326+ ``date`` input. With the ``datecopy.js`` file installed, double-clicking
336327on the input turns it into a normal text input with the ability
337328to copy, paste, or manually edit the date.
338329
@@ -371,18 +362,19 @@ double-tap to activate text mode input. Firefox does not.
371362Revert native number inputs for Number() and Integer() (optional)
372363-----------------------------------------------------------------
373364
374- Roundup's field() method for properties of type Number() or
375- Integer() now use a native browser number input.
365+ Roundup's ``field()`` method for properties of type ``Number()`` or
366+ ``Integer()`` now use a native browser number input by default.
367+
368+ This is configurable for *all* ``Number()`` and ``Integer()`` properties
369+ with the config option ``use_browser_number_input`` in section ``[web]``.
376370
377- You can use the old style text inputs by calling the field
378- method with ``type="text"``. You can :ref:`follow the example
379- for setting the text argument on a Date()
380- property. <revert_input_to_text>` for details.
371+ You can use the old style text inputs for individual fields
372+ by calling the field method with ``type="text"``.
381373
382- Note that the Integer() type also uses ``step="1"`` by default to
374+ Note that the `` Integer()`` type also uses ``step="1"`` by default to
383375add a stepper control and try to constrain the input to
384376integers. This can be overridden by passing a new step
385- (e.g. ``step="50"``) to the field() method.
377+ (e.g. ``step="50"``) to the `` field()`` method.
386378
387379Change in REST response for invalid CORS requests (info)
388380--------------------------------------------------------
0 commit comments