Page MenuHomePhabricator

Flags can only be applied to buttons
Closed, ResolvedPublic1 Story Points

Description

I tried to create a flagged IconWidget for demonstrating icons with different intentions.

It turns out that the MediaWiki theme only adds intentions to icons on buttons (I am assuming this is a Duck Typing test for a ButtonWidget or similar):

if ( element.supports( [ 'isFramed', 'isDisabled', 'hasFlag' ] ) ) {
    if ( element.isFramed() && ( element.isDisabled() || element.hasFlag( 'primary' ) ) ) {
        // Don't show intention, just invert
    } else {
        // Show intention
    }
}

How can I extend this to also work on flaggable elements other than buttons?

Event Timeline

werdna claimed this task.
werdna raised the priority of this task from to High.
werdna updated the task description. (Show Details)
werdna set Security to None.
werdna removed werdna as the assignee of this task.Mar 26 2015, 12:44 PM

Whole snippet:

	if ( element.supports( [ 'isFramed', 'isDisabled', 'hasFlag' ] ) ) {
		if ( element.isFramed() && ( element.isDisabled() || element.hasFlag( 'primary' ) ) ) {
			variants.invert = true;
		} else {
			variants.progressive = element.hasFlag( 'progressive' );
			variants.constructive = element.hasFlag( 'constructive' );
			variants.destructive = element.hasFlag( 'destructive' );
			variants.warning = element.hasFlag( 'warning' );
		}
	}

(I am assuming this is a Duck Typing test for a ButtonWidget or similar)

It is, and it is wrong. 'isFramed' matches ButtonElement only, 'hasFlag' matches FlaggedElement. 'isDisabled' matches all Widgets, so could be removed. The problem is that we check for the support of 'isFramed' even if we don't care about it and only call 'hasFlag'. Fixing this should make this code work for all kinds of widgets, as long as they have FlaggedElement mixed in.

Change 201147 had a related patch set uploaded (by Werdna):
T93890: Allow intention flags for non-buttons

https://gerrit.wikimedia.org/r/201147

Change 201147 had a related patch set uploaded (by Bartosz Dziewoński):
MediaWiki theme: Allow intention flags for non-buttons

https://gerrit.wikimedia.org/r/201147

Change 201147 merged by jenkins-bot:
MediaWiki theme: Allow intention flags for non-buttons

https://gerrit.wikimedia.org/r/201147

Jdforrester-WMF closed this task as Resolved.Apr 2 2015, 3:04 PM
Jdforrester-WMF assigned this task to werdna.
Jdforrester-WMF edited a custom field.
Jdforrester-WMF moved this task from Nominated to Done on the VisualEditor 2014/15 Q4 blockers board.
Jdforrester-WMF moved this task from Backlog to Reviewing on the OOUI board.Apr 29 2015, 9:36 PM
Danny_B moved this task from Unsorted to OOUI on the UI-Standardization board.May 20 2016, 8:59 PM