Page 1 of 1

Remove time selection in oxy_datePicker

Posted: Tue Jul 30, 2024 11:51 pm
by vitorhugovm
Hello!

I'm in need of using oxy_datePicker to allow date selection inside a node. I need to allow selection only for the date so I can intercept the inserted text and add the current time and timezone.
I tried to use the "format" property with "yyyy-MM-dd", but it keeps showing the time selection. I read that it is supposed to work only when a format is not detected in the associated document schema. Is there a way I can surpass the schema format in this case or force the time selection to not appear?

Thanks!
Vitor

Re: Remove time selection in oxy_datePicker

Posted: Wed Jul 31, 2024 11:28 am
by cristi_talau
Hello,
One way to avoid datePicker use the format from the schema, is to use a SchemaManagerFilter and override the getAttributeDescription method [1] to return no format. Then, to intercept the setting of the form-control you can use an AuthorDocumentFilter [2].
Another option is to implement a custom form control [3] and implement the entire behavior yourself.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... teContext)
[2] https://www.oxygenxml.com/InstData/Edit ... ilter.html
[3] https://www.oxygenxml.com/maven/com/oxy ... ntrol.html

Re: Remove time selection in oxy_datePicker

Posted: Wed Jul 31, 2024 11:39 pm
by vitorhugovm
Hello Cristian!

Instead of overriding getAttributeDescription method, I overwritten the getElementDescription method, because I'm editing the text inside the node and not an attribute. In the schema the element has the type xs:dateTime.
I tried to use setTypeDescription inside the new method, but it didn't change the behavior.

I have another question. Is there a way to call the oxy_datePicker component inside JavaScript or Java?

Thanks!
Vitor

Re: Remove time selection in oxy_datePicker

Posted: Thu Aug 01, 2024 11:12 am
by cristi_talau
Hello,

You should try to call setModelDescription to make simulate that the date has no specified format in the schema.
Regarding your second question, there is no way to reuse the code of the builtin date picker if you implement your own. On the other hand, the builtin date picker just uses the browser's <input type="date"> element.

Best,
Cristian