orocrmorocommerce

OroPlatform: how to override datetimepicker js widget


Context

I have a datetime attribute on an entity on my OroPlatform project. It is displayed correctly in the form:

enter image description here

Issue

Let's imagine the current time is 7pm. If I click on the "Today" button, the time field is filled with 7pm20 value instead of 7pm.

I have found that it came from the method getDefaultTime in the public/bundles/oroui/js/app/views/datepicker/datetimepicker-view-mixin.js file.

So, if I change the method in the original file and run the command symfony console oro:assets:build it works as expected.

But I can't find in the Oro documentation the proper way to "override" a method of a js component.


Solution

  • You can override a JavaScript module using the map section of jsmodules.yml configuration file. E.g.:

    map:
        '*':
            'jquery': 'oroui/js/jquery-extend'
        'oroui/js/jquery-extend':
            'jquery': 'jquery'
    

    For more details see the official documentation: https://doc.oroinc.com/backend/configuration/yaml/jsmodules/#map