Page MenuHomePhabricator

Convert instances of the social tools TagCloud class in FanBoxes and BlogPage to use CapsuleMultiselectWidget
Open, Stalled, Needs TriagePublic

Description

There's a good chance that there's a huge amount of categories on a wiki, having autocompletion for adding such a thing would help. :)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 19 2016, 1:28 AM
SamanthaNguyen moved this task from Backlog to BlogPage on the Social-Tools board.

A proof-of-concept is now live on the development wiki (currently only for the MonoBook skin because it's implemented via MediaWiki:Monobook.js instead of in the extension). Please try it out and let me know if it's what you wanted and we can then merge it into the codebase or alternatively tweak it some more.

Testing it out, I'll let you know how it goes it in a bit!

This could use the available OOJS-UI CapsuleMiniWidget also (I'm not sure if this works for textarea elements, however). There's no way to permalink to widgets on the OOJS UI demo page, but it's on here (just Ctrl+F the element):

https://doc.wikimedia.org/oojs-ui/master/demos/#widgets-mediawiki-ltr

Filip added a subscriber: Filip.Jan 21 2017, 9:19 PM

@SamanthaNguyen: @ashley: Hmm, why do not use Jquery suggestions?

SamanthaNguyen added a comment.EditedJan 21 2017, 9:42 PM

@FilipGCI It looks like it backfired after skimming through it, I'm still not quite sure why though?

I'm sure it could work, there's also jquery.ui.autocomplete as well :) (see https://jqueryui.com/autocomplete/) @ashley implemented jquery.ui.autocomplete in a script and showed it to me a while ago which I tested and found that it worked, I forgot why it wasn't uploaded as a patch though. Before you think of submitting a patch with that, you should probably wait for her response.

Note: You might also be interested in looking at T154855, which (indirectly) considers using OOUI CapsuleMultiselectWidget as an option

$( function() {
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'CreateBlogPost' ) { // temp
mw.loader.using( 'jquery.ui.autocomplete', function() { // more temp crap
	$( '#pageCtg' ).autocomplete( {
		minLength: 3,
		source: function( request, response ) {
			$.ajax( {
				type: 'GET',
				dataType: 'json',
				url: mw.util.wikiScript( 'api' ),
				data: {
					action: 'query',
					list: 'allcategories',
					acprefix: request.term,
					format: 'json'
				},
			} ).done( function( data ) {
				response( data.query.allcategories.map( function ( c ) { return c['*']; } ) );
			} ).fail( function() {} );
		},
		select: function( value, data ) {
			if ( typeof data === 'undefined' ) {
				$( '#pageCtg' ).val( value );
			} else {
				$( '#pageCtg' ).val( data.item.value );
			}
		}
	} );
} ); // temp
} // temp
} );
Filip claimed this task.Jan 21 2017, 9:46 PM

Will take a look on it.

@FilipGCI I meant to mention T131492 in the past as well since it uses chips, I was considering that BlogPage could perhaps implement a similar solution?

@SamanthaNguyen @ashley: Working on solution using 'CapsuleMultiselectWidget'. If we're converting this extension to OOjsUI, this will be better solution.

Found the ticket: T135340: Create a PHP-only pendant for TagMultiselectWidget

Also posting relevant IRC convo (took out unrelated messages):

[16:58:07] <rlot> MatmaRex: Hmm, is there way to directly create CapsuleMultiselectWidget in PHP?
[16:58:21] <rlot> new OOUI\CapsuleMultiSelectWidget();
[17:00:43] <MatmaRex> rlot: no. there's a task for it somewhere
[17:01:21] <MatmaRex> rlot: it's impossible to implement it without any JS, though. so i'm not really sure what that would do, myself
[17:01:53] <rlot> MatmaRex: Hmm, what if I want to add this widget to my specialpage?
[17:02:12] <rlot> I need to append it via JS script to output?
[17:02:26] <rlot> Or in some holder
[17:07:28] <MatmaRex> rlot_: yeah :/
[17:07:54] <MatmaRex> rlot_: if you're using HTMLForm, it was some fallback to a list of checkboxes. (or you could implement something like that yourself)
[17:07:58] <MatmaRex> it has*
[17:10:23] <rlot_> MatmaRex: Hmm. Is there any better widget for autocompletion/adding tags/etc?
[17:11:31] <SamanthaNguyen> MatmaRex: If you're interested, the tickets directly related to rlot's questions are T146000 and T154855 (you might already be aware of that, though)
[17:11:31] <stashbot> T146000: FeatureRequest: BlogPage's Special:CreateBlogPost should have autocompletion for adding categories - https://phabricator.wikimedia.org/T146000
[17:11:32] <stashbot> T154855: Impossible to remove a category after adding one with the social tools TagCloud function (e.g in Special:CreateBlogPost) - https://phabricator.wikimedia.org/T154855

This ticket is basically blocked by T152267 unless if we're only going to convert half of the form to OOUI but that seems kinda weird, doesn't it?

Filip added a comment.Jan 22 2017, 4:45 PM

@SamanthaNguyen: Yes, we will wait with this. We don't want to have mixed pure html/ooui interface.

SamanthaNguyen renamed this task from FeatureRequest: BlogPage's Special:CreateBlogPost should have autocompletion for adding categories to Convert instances of the social tools TagCloud class in FanBoxes and BlogPage to use CapsuleMultiselectWidget.Jan 22 2017, 5:10 PM
SamanthaNguyen updated the task description. (Show Details)
SamanthaNguyen moved this task from Unsorted to Migrate / Replace on the Technical-Debt board.
SamanthaNguyen moved this task from Backlog to Feature Request on the FanBoxes board.