Page MenuHomePhabricator

[OOUI] Is there a DateInputWidget in OOUI to be consumed by on-wiki gadgets?
Closed, ResolvedPublic

Description

I've looked around including T91148: Consolidate MediaWiki core's date and time input widgets; consider moving (one of?) them upstream and didn't see a DateInputWidget to be used outside of MW core (in an on-wiki gadget for example).

Looking at: https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui, I do not see a DateInputWidget available and also TextInputWidget types doesn't support the 'date' type.

In addition, when I check the live preview of code on the MediaWiki DateInputWidget, I get the error that says:

Uncaught TypeError: undefined is not a constructor (evaluating 'new mw.widgets.DateInputWidget()')

Is there a way to make TextInputWidget work with a 'date' type or have DateInputWidget work on OOUI form in on-wiki gadgets?

Event Timeline

There isn't one in OOUI, there's only mw.widgets.DateInputWidget.

However, you can use mw.widgets.DateInputWidget in an on-wiki gadget. You need to add a dependency on the module 'mediawiki.widgets.DateInputWidget' to your code (in the same place where you presumably have a dependency on 'oojs-ui' – in the dependencies option in the gadget definition, or in some mw.loader.using call if it's a script and not a gadget).

@matmarex: I get this error TypeError: undefined is not a constructor (evaluating 'new mw.widgets.DateInputWidget()') when I try this: https://www.mediawiki.org/wiki/User:DAlangi_(WMF)/common.js.

Are my missing something?

Took me a while to spot… mw.loader.using takes an array, not multiple arguments. Should be like this:

mw.loader.using( [
	'oojs-ui',
	'oojs-ui-core',
	'mediawiki.widgets.DateInputWidget'
] ).done( function () { ...

Oh my! Wow, thanks a lot @matmarex. This is awesome! I just made that change and it works now!

DAlangi_WMF assigned this task to matmarex.