joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] New Date and Datetime fields

Open Fedik opened this issue 2 years ago • 38 comments

Summary of Changes

Add 2 new input date (DateField class), and datetime-local (DatetimeField class). Fix Time field to support filter.

Links to MDN docs: datetime-local: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local date: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date

Testing Instructions

Add fields in some XML, example in to mod_custom params:

<field type="date" name="date" label="Date"/>
<field type="time" name="time" label="Time" filter="SERVER_UTC"/>
<field type="datetime" name="datetime" label="Date Time" filter="SERVER_UTC"/>

Expected result AFTER applying this Pull Request

Edit the fields, make sure the input works and values stored/displayed corectly

Documentation Changes Required

Add new fields info to list of fields: https://docs.joomla.org/Standard_form_field_types

Fedik avatar Apr 02 '22 10:04 Fedik

Nice one. Not necessarily something for this PR but would be good to have support for these native inputs:

  • datetime-local: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
  • month: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month
  • week: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/week

Oh date time is deprecated: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime#browser_compatibility

dgrammatiko avatar Apr 02 '22 10:04 dgrammatiko

Oh date time is deprecated

yes

datetime-local

This is DateTime here

Unfortunately month and week have bad support by Browsers, probably for another time :wink: Or maybe I make another PR for them, will see.

Fedik avatar Apr 02 '22 10:04 Fedik

Could you update the description please to be datetime not datetimelocal

brianteeman avatar Apr 02 '22 11:04 brianteeman

What happens with non gregorian calendars?

brianteeman avatar Apr 02 '22 11:04 brianteeman

What happens with non gregorian calendars?

It only gregorian. It is standart date and datetime-local input, works as described in HTML specs. No more no less :wink:

Fedik avatar Apr 02 '22 11:04 Fedik

Could you update the description please to be datetime not datetimelocal

Wich description do you mean? It actualy displaing datetime-local, because datetime is deprecated (see @dgrammatiko coment)

Fedik avatar Apr 02 '22 11:04 Fedik

image

brianteeman avatar Apr 02 '22 16:04 brianteeman

@brianteeman that is correct. Xml <field type="datetime"/> (wich is DatetimeField class in PHP), will render <input type="datetime-local">

Fedik avatar Apr 02 '22 17:04 Fedik

nice and confusing

brianteeman avatar Apr 02 '22 18:04 brianteeman

I would also deprecate our calendar field in favor of this one.

laoneo avatar Apr 04 '22 07:04 laoneo

I would also deprecate our calendar field in favor of this one.

it not replacement, because it does not support non gregorian calendars

Fedik avatar Apr 04 '22 07:04 Fedik

How do we handle gregorian calendars then?

laoneo avatar Apr 04 '22 08:04 laoneo

How do we handle gregorian calendars then?

I assume you mean "non gregorian". There a helper JS depend from language, one for jalali https://github.com/joomla/joomla-cms/blob/4.1-dev/build/media_source/system/js/fields/calendar-locales/date/jalali/date-helper.es5.js

Fedik avatar Apr 04 '22 08:04 Fedik

Is this loaded then in this field?

laoneo avatar Apr 04 '22 08:04 laoneo

Is this loaded then in this field?

Nope, that coded specificaly for calendar.js, it cannot be used somwhere else. Only calendar field support "gregorian" and "non gregorian" calendars, that why it cannot be as replacement.

Also see my answer to Brian https://github.com/joomla/joomla-cms/pull/37456#issuecomment-1086619145

Fedik avatar Apr 04 '22 09:04 Fedik

If this pr can't be used in core, then I doubt we should add it. Especially when the fields can't be used all the languages we are supporting.

laoneo avatar Apr 09 '22 08:04 laoneo

The fields is part of HTML5, that was missed in Form API.

Especially when the fields can't be used all the languages we are supporting.

They can be used, they translated by Browser. It offers what HTML specification offers.

Support for different Calendars format it a huge different topic.

Fedik avatar Apr 09 '22 08:04 Fedik

agree with @fedik

brianteeman avatar Apr 09 '22 08:04 brianteeman

Is this issue still open? If yes, can I contribute to it?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37456.

attreyee-muk avatar Apr 09 '22 14:04 attreyee-muk

@a-muk sure, everyone can contribute :) I'll assign this to you for now.

chmst avatar Apr 09 '22 16:04 chmst

If yes, can I contribute to it?

All is needed for this PR is to be tested :wink:

Fedik avatar Apr 09 '22 16:04 Fedik

so sorry - i have too many tasks.:) @a-muk yes - now the work means testing

chmst avatar Apr 09 '22 16:04 chmst

Okay. Thank you @Fedik @chmst

attreyee-muk avatar Apr 09 '22 16:04 attreyee-muk

@laoneo could you elaborate on your thumbs down? Shouldn't Joomla implement the full HTML5 specs, and if so why?

dgrammatiko avatar Apr 13 '22 16:04 dgrammatiko

@laoneo could you elaborate on your thumbs down? Shouldn't Joomla implement the full HTML5 specs, and if so why?

You answered it here perfectly https://github.com/joomla/joomla-cms/issues/36346#issuecomment-997437474. The core can never use this field, because we want to support also none gregorian calendars.

laoneo avatar Apr 19 '22 13:04 laoneo

You answered it here perfectly https://github.com/joomla/joomla-cms/issues/36346#issuecomment-997437474. The core can never use this field, because we want to support also none gregorian calendars.

You're mixing different things here. My comment that you are mentioning is about a tables sorting functionality that is totally a Joomla invented/created/coded thing but this PR is about adding some of the W3C platfrom's missing input types. So, yes Joomla shouldn't roll functionality about imaginary use cases (in the case of my comment the dev was going against the Joomla's architecture: items are direct descendants of a single category and asking to extend the functionality to cover their case) but also Joomla should FULLY support the HTML5 elements. Also Joomla rolls a few more input types that aren't actually used by the core, so that's not even an argument against, eg:

  • https://github.com/joomla/joomla-cms/blob/4.1-dev/layouts/joomla/form/field/color/simple.php
  • https://github.com/joomla/joomla-cms/blob/4.1-dev/layouts/joomla/form/field/tel.php
  • https://github.com/joomla/joomla-cms/blob/4.1-dev/layouts/joomla/form/field/time.php

dgrammatiko avatar Apr 20 '22 12:04 dgrammatiko

Joomla should FULLY support the HTML5 elements

Why? All I see here is a maintenance burden (even when it is small).

Color is used on many places, tel is used in contact and time in scheduler. Perhaps you should search other examples. Even then, when something can't be used in core, we should not add it.

Perhaps I miss here something, but from a maintainer point of view this looks like something which should be either published as custom field or in the respective extension, but not in core.

laoneo avatar Apr 20 '22 13:04 laoneo

, tel is used in contact

No its not

https://github.com/joomla/joomla-cms/blob/1ee64271a331317331a86ced18d012342b7b3a86/components/com_contact/forms/form.xml#L169-L171

brianteeman avatar Apr 20 '22 13:04 brianteeman

Honestly @laoneo its a pathetic argument that you are making. I'm sure we all have better things to do

brianteeman avatar Apr 20 '22 13:04 brianteeman

but not in core.

Here is were I strongly disagree. For me ALL the HTML5 input fields should be provided from Joomla core for 2 reasons:

  • Joomla's byproduct IS HTML5
  • the core SHOULD roll those input types so devs cannot use their names for their own fields to prevent collisions (actually every dev should prefixing their input types/names so that won't ever be a thing)

But anyways, that's my point of view. Also one more thought here, if the maintainers of the project feeling intimidated to actually implement the full HTML5 specs then probably they shouldn't be maintainers of a WEB CMS...

dgrammatiko avatar Apr 20 '22 13:04 dgrammatiko