sonata-project / form-extensions

Symfony form extensions
https://docs.sonata-project.org/projects/form-extensions
MIT License
101 stars 26 forks source link

Upgrade Datetime library #320

Closed jordisala1991 closed 1 year ago

jordisala1991 commented 2 years ago

Feature Request

We are somehow stuck with the DateTime form type, since it is coupled with the library we are using at the frontend to render it:

https://github.com/Eonasdan/bootstrap-datetimepicker/ -> version 3.1.3

Not only is outdated (there is a version 4, 5, 6 on that repository), but also it got a name change, at least one major rewrite, some options changed a lot, etc...

Also there is another problem here, the form type is defined here, but the library is added here: https://github.com/sonata-project/SonataAdminBundle/tree/4.x/assets/vendor which is a problem because:

  1. Can't be added via package.json since that older version does not provide the required assets
  2. Can't be upgraded since there is a circular dependency hidden: Form extension requires the js + css on admin, and admin requires the form type here.

I think we should find a solution before release 2.0, wdyt @VincentLanglet ?

There are also some really old PRs and issues on CoreBundle (when everything was together):

https://github.com/sonata-project/SonataCoreBundle/issues/138 https://github.com/sonata-project/SonataCoreBundle/pull/149

VincentLanglet commented 2 years ago

I see two solutions:

I prefer the second solution ; do you think it's possible ?

jordisala1991 commented 2 years ago

The first option involves some / lot of classes, since there are multiple types related to "dates"

The second option I like it, but I am not sure how to do it. Should we expose a raw css/js file and then on the admin we capture it with encore and add it to the build?

I add a third option.

VincentLanglet commented 2 years ago

Make this library agnostic of the css/js part, and have something on AdminBundle that overrides it to show a pretty date picker

I don't see how a DatePickerType will be agnostic of the datepicker library. To me it's the main purpose of this Type.

Should we expose a raw css/js file and then on the admin we capture it with encore and add it to the build?

Cant we have webpack on this project to build css/js, and then we add the file here: https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/DependencyInjection/Configuration.php#L637

jordisala1991 commented 2 years ago

We have to make sure we remain compatible with both v1 and v2 of this bundle, but yes I think it can be done that way.

jordisala1991 commented 2 years ago

First part of the issue is solved (well we need to integrate it with AdminBundle). Now we need to merge to branch v2 and upgrade the library.